Make sure to setup the language defaults normally when outputting a PCH.

This commit is contained in:
Frederich Munch 2017-06-28 04:54:33 -04:00 committed by sftnight
parent 4739761b89
commit e90cfd8b4f
3 changed files with 22 additions and 3 deletions

View File

@ -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
@ -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;

View File

@ -421,7 +421,7 @@ namespace {
Opts.FastMath = 1;
#endif
if (CompilerOpts.DefaultLanguage()) {
if (CompilerOpts.DefaultLanguage(Opts)) {
#ifdef __STRICT_ANSI__
Opts.GNUMode = 0;
#else
@ -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()) {

View File

@ -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"
@ -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) {