forked from OSchip/llvm-project
When building a module on-demand, clear out the "non-modular" language
and preprocessor options (such as macro definitions) first. llvm-svn: 139638
This commit is contained in:
parent
e3a6a82f16
commit
f1312a828a
|
@ -58,16 +58,16 @@ BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1,
|
||||||
LANGOPT(Trigraphs , 1, 0,"trigraphs")
|
LANGOPT(Trigraphs , 1, 0,"trigraphs")
|
||||||
LANGOPT(BCPLComment , 1, 0, "BCPL-style '//' comments")
|
LANGOPT(BCPLComment , 1, 0, "BCPL-style '//' comments")
|
||||||
LANGOPT(Bool , 1, 0, "bool, true, and false keywords")
|
LANGOPT(Bool , 1, 0, "bool, true, and false keywords")
|
||||||
BENIGN_LANGOPT(DollarIdents , 1, 0, "'$' in identifiers")
|
BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers")
|
||||||
BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
|
BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
|
||||||
BENIGN_LANGOPT(GNUMode , 1, 0, "GNU extensions")
|
BENIGN_LANGOPT(GNUMode , 1, 1, "GNU extensions")
|
||||||
LANGOPT(GNUKeywords , 1, 0, "GNU keywords")
|
LANGOPT(GNUKeywords , 1, 1, "GNU keywords")
|
||||||
BENIGN_LANGOPT(ImplicitInt, 1, 0, "C89 implicit 'int'")
|
BENIGN_LANGOPT(ImplicitInt, 1, !C99 && !CPlusPlus, "C89 implicit 'int'")
|
||||||
LANGOPT(Digraphs , 1, 0, "digraphs")
|
LANGOPT(Digraphs , 1, 0, "digraphs")
|
||||||
BENIGN_LANGOPT(HexFloats , 1, 0, "C99 hexadecimal float constants")
|
BENIGN_LANGOPT(HexFloats , 1, C99, "C99 hexadecimal float constants")
|
||||||
LANGOPT(CXXOperatorNames , 1, 0, "C++ operator name keywords")
|
LANGOPT(CXXOperatorNames , 1, 0, "C++ operator name keywords")
|
||||||
LANGOPT(AppleKext , 1, 0, "Apple kext support")
|
LANGOPT(AppleKext , 1, 0, "Apple kext support")
|
||||||
BENIGN_LANGOPT(PascalStrings , 1, 0, "Pascal string support")
|
BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support")
|
||||||
LANGOPT(WritableStrings , 1, 0, "writable string support")
|
LANGOPT(WritableStrings , 1, 0, "writable string support")
|
||||||
LANGOPT(ConstStrings , 1, 0, "const-qualified string support")
|
LANGOPT(ConstStrings , 1, 0, "const-qualified string support")
|
||||||
LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions")
|
LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions")
|
||||||
|
@ -80,12 +80,12 @@ LANGOPT(TraditionalCPP , 1, 0, "traditional CPP emulation")
|
||||||
LANGOPT(RTTI , 1, 1, "run-time type information")
|
LANGOPT(RTTI , 1, 1, "run-time type information")
|
||||||
LANGOPT(MSBitfields , 1, 0, "Microsoft-compatible structure layout")
|
LANGOPT(MSBitfields , 1, 0, "Microsoft-compatible structure layout")
|
||||||
LANGOPT(NeXTRuntime , 1, 1, "NeXT Objective-C runtime")
|
LANGOPT(NeXTRuntime , 1, 1, "NeXT Objective-C runtime")
|
||||||
BENIGN_LANGOPT(Freestanding , 1, 0, "freestanding implementation")
|
LANGOPT(Freestanding, 1, 0, "freestanding implementation")
|
||||||
LANGOPT(NoBuiltin , 1, 0, "disable builtin functions")
|
LANGOPT(NoBuiltin , 1, 0, "disable builtin functions")
|
||||||
|
|
||||||
BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
|
BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
|
||||||
LANGOPT(POSIXThreads , 1, 0, "POSIX thread support")
|
LANGOPT(POSIXThreads , 1, 0, "POSIX thread support")
|
||||||
BENIGN_LANGOPT(Blocks , 1, 0, "blocks extension to C")
|
LANGOPT(Blocks , 1, 0, "blocks extension to C")
|
||||||
BENIGN_LANGOPT(EmitAllDecls , 1, 0, "support for emitting all declarations")
|
BENIGN_LANGOPT(EmitAllDecls , 1, 0, "support for emitting all declarations")
|
||||||
LANGOPT(MathErrno , 1, 1, "errno support for math functions")
|
LANGOPT(MathErrno , 1, 1, "errno support for math functions")
|
||||||
BENIGN_LANGOPT(HeinousExtensions , 1, 0, "Extensions that we really don't like and may be ripped out at any time")
|
BENIGN_LANGOPT(HeinousExtensions , 1, 0, "Extensions that we really don't like and may be ripped out at any time")
|
||||||
|
|
|
@ -66,6 +66,10 @@ public:
|
||||||
bool isSignedOverflowDefined() const {
|
bool isSignedOverflowDefined() const {
|
||||||
return getSignedOverflowBehavior() == SOB_Defined;
|
return getSignedOverflowBehavior() == SOB_Defined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Reset all of the options that are not considered when building a
|
||||||
|
/// module.
|
||||||
|
void resetNonModularOptions();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Floating point control options
|
/// Floating point control options
|
||||||
|
|
|
@ -190,6 +190,16 @@ public:
|
||||||
RemappedFiles.clear();
|
RemappedFiles.clear();
|
||||||
RemappedFileBuffers.clear();
|
RemappedFileBuffers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Reset any options that are not considered when building a
|
||||||
|
/// module.
|
||||||
|
void resetNonModularOptions() {
|
||||||
|
Macros.clear();
|
||||||
|
MacroIncludes.clear();
|
||||||
|
DumpDeserializedPCHDecls = false;
|
||||||
|
TokenCache.clear();
|
||||||
|
RetainRemappedFileBuffers = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace clang
|
} // end namespace clang
|
||||||
|
|
|
@ -19,3 +19,9 @@ LangOptions::LangOptions() {
|
||||||
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
|
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
|
||||||
#include "clang/Basic/LangOptions.def"
|
#include "clang/Basic/LangOptions.def"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LangOptions::resetNonModularOptions() {
|
||||||
|
#define LANGOPT(Name, Bits, Default, Description)
|
||||||
|
#define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = Default;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -654,6 +654,9 @@ static void compileModule(CompilerInstance &ImportingInstance,
|
||||||
// Construct a compiler invocation for creating this module.
|
// Construct a compiler invocation for creating this module.
|
||||||
llvm::IntrusiveRefCntPtr<CompilerInvocation> Invocation
|
llvm::IntrusiveRefCntPtr<CompilerInvocation> Invocation
|
||||||
(new CompilerInvocation(ImportingInstance.getInvocation()));
|
(new CompilerInvocation(ImportingInstance.getInvocation()));
|
||||||
|
Invocation->getLangOpts().resetNonModularOptions();
|
||||||
|
Invocation->getPreprocessorOpts().resetNonModularOptions();
|
||||||
|
|
||||||
FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
|
FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
|
||||||
FrontendOpts.OutputFile = ModuleFile.str();
|
FrontendOpts.OutputFile = ModuleFile.str();
|
||||||
FrontendOpts.DisableFree = false;
|
FrontendOpts.DisableFree = false;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
const char *getModuleVersion(void);
|
const char *getModuleVersion(void);
|
||||||
|
|
||||||
|
#ifdef FOO
|
||||||
|
# error Module should have been built without -DFOO
|
||||||
|
#endif
|
||||||
|
|
||||||
@interface Module
|
@interface Module
|
||||||
+(const char *)version;
|
+(const char *)version; // retrieve module version
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: mkdir -p %t
|
// RUN: mkdir -p %t
|
||||||
// RUN: rm -f %t/Module.pcm
|
// RUN: rm -f %t/Module.pcm
|
||||||
// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -verify %s
|
// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -DFOO -verify %s
|
||||||
|
|
||||||
__import_module__ Module;
|
__import_module__ Module;
|
||||||
void test_getModuleVersion() {
|
void test_getModuleVersion() {
|
||||||
|
|
Loading…
Reference in New Issue