Author: rsmith Date: Thu Apr 7 15:47:37 2016 New Revision: 265718 URL: http://llvm.org/viewvc/llvm-project?rev=265718&view=rev Log: [modules] Allow differences in flags that only affect preprocessor predefines (and __has_feature checks) between explicitly-specified module files and the current compilation.
Modified: cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Modules/explicit-build-flags.cpp Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=265718&r1=265717&r2=265718&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Apr 7 15:47:37 2016 @@ -24,11 +24,15 @@ // // VALUE_LANGOPT: for options that describe a value rather than a flag. // -// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT: combinations of the above. +// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT, +// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the above. // // FIXME: Clients should be able to more easily select whether they want // different levels of compatibility versus how to handle different kinds // of option. +// +// The Description field should be a noun phrase, for instance "frobbing all +// widgets" or "C's implicit blintz feature". //===----------------------------------------------------------------------===// #ifndef LANGOPT @@ -65,6 +69,16 @@ LANGOPT(Name, Bits, Default, Description) #endif +#ifndef COMPATIBLE_VALUE_LANGOPT +# define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \ + VALUE_LANGOPT(Name, Bits, Default, Description) +#endif + +#ifndef BENIGN_VALUE_LANGOPT +# define BENIGN_VALUE_LANGOPT(Name, Bits, Default, Description) \ + COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) +#endif + // FIXME: A lot of the BENIGN_ options should be COMPATIBLE_ instead. LANGOPT(C99 , 1, 0, "C99") LANGOPT(C11 , 1, 0, "C11") @@ -124,32 +138,32 @@ LANGOPT(Coroutines , 1, 0, "C++ c BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers") LANGOPT(POSIXThreads , 1, 0, "POSIX thread support") 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") +BENIGN_LANGOPT(EmitAllDecls , 1, 0, "emitting all declarations") +LANGOPT(MathErrno , 1, 1, "errno in math functions") +BENIGN_LANGOPT(HeinousExtensions , 1, 0, "extensions that we really don't like and may be ripped out at any time") LANGOPT(Modules , 1, 0, "modules extension to C") BENIGN_LANGOPT(CompilingModule, 1, 0, "compiling a module interface") COMPATIBLE_LANGOPT(ModulesDeclUse , 1, 0, "require declaration of module uses") -LANGOPT(ModulesSearchAll , 1, 1, "search even non-imported modules to find unresolved references") -COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "require declaration of module uses and all headers to be in modules") -BENIGN_LANGOPT(ModulesErrorRecovery, 1, 1, "automatically import modules as needed when performing error recovery") -BENIGN_LANGOPT(ImplicitModules, 1, 1, "build modules that are not specified via -fmodule-file") +BENIGN_LANGOPT(ModulesSearchAll , 1, 1, "searching even non-imported modules to find unresolved references") +COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "requiring declaration of module uses and all headers to be in modules") +BENIGN_LANGOPT(ModulesErrorRecovery, 1, 1, "automatically importing modules as needed when performing error recovery") +BENIGN_LANGOPT(ImplicitModules, 1, 1, "building modules that are not specified via -fmodule-file") COMPATIBLE_LANGOPT(ModulesLocalVisibility, 1, 0, "local submodule visibility") COMPATIBLE_LANGOPT(Optimize , 1, 0, "__OPTIMIZE__ predefined macro") COMPATIBLE_LANGOPT(OptimizeSize , 1, 0, "__OPTIMIZE_SIZE__ predefined macro") -LANGOPT(Static , 1, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)") +COMPATIBLE_LANGOPT(Static , 1, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)") VALUE_LANGOPT(PackStruct , 32, 0, "default struct packing maximum alignment") VALUE_LANGOPT(MaxTypeAlign , 32, 0, "default maximum alignment for types") -VALUE_LANGOPT(PICLevel , 2, 0, "__PIC__ level") -VALUE_LANGOPT(PIELevel , 2, 0, "__PIE__ level") -LANGOPT(GNUInline , 1, 0, "GNU inline semantics") +COMPATIBLE_VALUE_LANGOPT(PICLevel , 2, 0, "__PIC__ level") +COMPATIBLE_VALUE_LANGOPT(PIELevel , 2, 0, "__PIE__ level") +COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics") COMPATIBLE_LANGOPT(NoInlineDefine , 1, 0, "__NO_INLINE__ predefined macro") COMPATIBLE_LANGOPT(Deprecated , 1, 0, "__DEPRECATED predefined macro") -LANGOPT(FastMath , 1, 0, "__FAST_MATH__ predefined macro") -LANGOPT(FiniteMathOnly , 1, 0, "__FINITE_MATH_ONLY__ predefined macro") -LANGOPT(UnsafeFPMath , 1, 0, "Unsafe Floating Point Math") +COMPATIBLE_LANGOPT(FastMath , 1, 0, "__FAST_MATH__ predefined macro") +COMPATIBLE_LANGOPT(FiniteMathOnly , 1, 0, "__FINITE_MATH_ONLY__ predefined macro") +COMPATIBLE_LANGOPT(UnsafeFPMath , 1, 0, "Unsafe Floating Point Math") BENIGN_LANGOPT(ObjCGCBitmapPrint , 1, 0, "printing of GC's bitmap layout for __weak/__strong ivars") @@ -246,4 +260,6 @@ LANGOPT(SanitizeAddressFieldPadding, 2, #undef COMPATIBLE_ENUM_LANGOPT #undef BENIGN_ENUM_LANGOPT #undef VALUE_LANGOPT +#undef COMPATIBLE_VALUE_LANGOPT +#undef BENIGN_VALUE_LANGOPT Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=265718&r1=265717&r2=265718&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Apr 7 15:47:37 2016 @@ -217,8 +217,13 @@ static bool checkLanguageOptions(const L if (!AllowCompatibleDifferences) \ ENUM_LANGOPT(Name, Bits, Default, Description) +#define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \ + if (!AllowCompatibleDifferences) \ + VALUE_LANGOPT(Name, Bits, Default, Description) + #define BENIGN_LANGOPT(Name, Bits, Default, Description) #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) +#define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description) #include "clang/Basic/LangOptions.def" if (ExistingLangOpts.ModuleFeatures != LangOpts.ModuleFeatures) { Modified: cfe/trunk/test/Modules/explicit-build-flags.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build-flags.cpp?rev=265718&r1=265717&r2=265718&view=diff ============================================================================== --- cfe/trunk/test/Modules/explicit-build-flags.cpp (original) +++ cfe/trunk/test/Modules/explicit-build-flags.cpp Thu Apr 7 15:47:37 2016 @@ -7,8 +7,7 @@ // Can use the module. // RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s -// Can use the module if an input file is newer. (This happens on -// remote file systems.) +// Can use the module if an input file is newer. (This happens on remote file systems.) // RUN: sleep 1 // RUN: touch %t/tmp.h // RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s @@ -23,6 +22,19 @@ // Can use the module if -I flags change. // RUN: %clang_cc1 -fmodules -DBAR=2 -I. -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s +// Can use the module if -fPIC/-fPIE flags change. +// RUN: %clang_cc1 -fmodules -DBAR=2 -pic-level 2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s +// RUN: %clang_cc1 -fmodules -DBAR=2 -pie-level 1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s + +// Can use the module if -static flag changes. +// RUN: %clang_cc1 -fmodules -DBAR=2 -static-define -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s + +// Can use the module if -fsanitize= flags change. +// RUN: %clang_cc1 -fmodules -DBAR=2 -fsanitize=address -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s +// +// RUN: %clang_cc1 -fmodules -DFOO=1 -fsanitize=address -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp-san.pcm +// RUN: %clang_cc1 -fmodules -DBAR=2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-san.pcm -verify -I%t %s + // Can use the module if -O flags change. // RUN: %clang_cc1 -fmodules -DBAR=2 -Os -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s // _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits