[cfe-commits] r139638 - in /cfe/trunk: include/clang/Basic/LangOptions.def include/clang/Basic/LangOptions.h include/clang/Frontend/PreprocessorOptions.h lib/Basic/LangOptions.cpp lib/Frontend/CompilerInstance.cpp test/Modules/Inputs/Module.framework/Headers/Module.h test/Modules/on-demand-build.m
Douglas Gregor
dgregor at apple.com
Tue Sep 13 13:44:41 PDT 2011
Author: dgregor
Date: Tue Sep 13 15:44:41 2011
New Revision: 139638
URL: http://llvm.org/viewvc/llvm-project?rev=139638&view=rev
Log:
When building a module on-demand, clear out the "non-modular" language
and preprocessor options (such as macro definitions) first.
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
cfe/trunk/lib/Basic/LangOptions.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h
cfe/trunk/test/Modules/on-demand-build.m
Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=139638&r1=139637&r2=139638&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Tue Sep 13 15:44:41 2011
@@ -58,16 +58,16 @@
LANGOPT(Trigraphs , 1, 0,"trigraphs")
LANGOPT(BCPLComment , 1, 0, "BCPL-style '//' comments")
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(GNUMode , 1, 0, "GNU extensions")
-LANGOPT(GNUKeywords , 1, 0, "GNU keywords")
-BENIGN_LANGOPT(ImplicitInt, 1, 0, "C89 implicit 'int'")
+BENIGN_LANGOPT(GNUMode , 1, 1, "GNU extensions")
+LANGOPT(GNUKeywords , 1, 1, "GNU keywords")
+BENIGN_LANGOPT(ImplicitInt, 1, !C99 && !CPlusPlus, "C89 implicit 'int'")
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(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(ConstStrings , 1, 0, "const-qualified string support")
LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions")
@@ -80,12 +80,12 @@
LANGOPT(RTTI , 1, 1, "run-time type information")
LANGOPT(MSBitfields , 1, 0, "Microsoft-compatible structure layout")
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")
BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
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")
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")
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=139638&r1=139637&r2=139638&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Tue Sep 13 15:44:41 2011
@@ -66,6 +66,10 @@
bool isSignedOverflowDefined() const {
return getSignedOverflowBehavior() == SOB_Defined;
}
+
+ /// \brief Reset all of the options that are not considered when building a
+ /// module.
+ void resetNonModularOptions();
};
/// Floating point control options
Modified: cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PreprocessorOptions.h?rev=139638&r1=139637&r2=139638&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/PreprocessorOptions.h Tue Sep 13 15:44:41 2011
@@ -190,6 +190,16 @@
RemappedFiles.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
Modified: cfe/trunk/lib/Basic/LangOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/LangOptions.cpp?rev=139638&r1=139637&r2=139638&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/LangOptions.cpp (original)
+++ cfe/trunk/lib/Basic/LangOptions.cpp Tue Sep 13 15:44:41 2011
@@ -19,3 +19,9 @@
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
#include "clang/Basic/LangOptions.def"
}
+
+void LangOptions::resetNonModularOptions() {
+#define LANGOPT(Name, Bits, Default, Description)
+#define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = Default;
+}
+
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=139638&r1=139637&r2=139638&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Sep 13 15:44:41 2011
@@ -654,6 +654,9 @@
// Construct a compiler invocation for creating this module.
llvm::IntrusiveRefCntPtr<CompilerInvocation> Invocation
(new CompilerInvocation(ImportingInstance.getInvocation()));
+ Invocation->getLangOpts().resetNonModularOptions();
+ Invocation->getPreprocessorOpts().resetNonModularOptions();
+
FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
FrontendOpts.OutputFile = ModuleFile.str();
FrontendOpts.DisableFree = false;
Modified: cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h?rev=139638&r1=139637&r2=139638&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h (original)
+++ cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h Tue Sep 13 15:44:41 2011
@@ -1,6 +1,10 @@
const char *getModuleVersion(void);
+#ifdef FOO
+# error Module should have been built without -DFOO
+#endif
+
@interface Module
-+(const char *)version;
++(const char *)version; // retrieve module version
@end
Modified: cfe/trunk/test/Modules/on-demand-build.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/on-demand-build.m?rev=139638&r1=139637&r2=139638&view=diff
==============================================================================
--- cfe/trunk/test/Modules/on-demand-build.m (original)
+++ cfe/trunk/test/Modules/on-demand-build.m Tue Sep 13 15:44:41 2011
@@ -1,6 +1,6 @@
// RUN: mkdir -p %t
// 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;
void test_getModuleVersion() {
More information about the cfe-commits
mailing list