Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make sure to setup the language defaults normally when outputting a PCH.
  • Loading branch information
marsupial authored and Axel-Naumann committed Jun 28, 2017
commit 6e68ec056b0482ab10f7d45839856c3862321c2d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include <string>
#include <vector>

namespace clang {
class LangOptions;
};

namespace cling {

///\brief Class that stores options that are used by both cling and
Expand Down Expand Up @@ -42,7 +46,7 @@ namespace cling {
/// or './cling -x c') that this shouldn't be done. This will return false
/// in those cases.
///
bool DefaultLanguage() const { return !Language && !StdVersion; }
bool DefaultLanguage(const clang::LangOptions&) const;

unsigned Language : 1;
unsigned ResourceDir : 1;
Expand Down
4 changes: 2 additions & 2 deletions interpreter/cling/lib/Interpreter/CIFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ namespace {
Opts.FastMath = 1;
#endif

if (CompilerOpts.DefaultLanguage()) {
if (CompilerOpts.DefaultLanguage(Opts)) {
#ifdef __STRICT_ANSI__
Opts.GNUMode = 0;
#else
Expand All @@ -445,7 +445,7 @@ namespace {
Opts.MicrosoftExt = 0;
}

if (CompilerOpts.DefaultLanguage()) {
if (CompilerOpts.DefaultLanguage(Opts)) {
#if _GLIBCXX_USE_FLOAT128
// We are compiling with libstdc++ with __float128 enabled.
if (!Target.hasFloat128Type()) {
Expand Down
15 changes: 15 additions & 0 deletions interpreter/cling/lib/Interpreter/InvocationOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "cling/Interpreter/ClingOptions.h"
#include "cling/Utils/Output.h"

#include "clang/Basic/LangOptions.h"
#include "clang/Driver/Options.h"

#include "llvm/Option/Arg.h"
Expand Down Expand Up @@ -144,6 +145,20 @@ void CompilerOptions::Parse(int argc, const char* const argv[],
}
}

bool CompilerOptions::DefaultLanguage(const LangOptions& LangOpts) const {
// When StdVersion is set (-std=c++11, -std=gnu++11, etc.) then definitely
// don't setup the defaults, as they may interfere with what the user is doing
if (StdVersion)
return false;

// Also don't set up the defaults when language is explicitly set; unless
// the language was set to generate a PCH, in which case definitely do.
if (Language)
return LangOpts.CompilingPCH || HasOutput;

return true;
}

InvocationOptions::InvocationOptions(int argc, const char* const* argv) :
MetaString("."), ErrorOut(false), NoLogo(false), ShowVersion(false),
Help(false), NoRuntime(false) {
Expand Down