aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-13 18:26:39 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-13 18:26:39 +0000
commit7d5e81bf24dbfd334a7c62a7ae51043c79a69aa9 (patch)
tree7fa299a801302ef70333df754223e2829d34af51
parente87158dfbca01577810f301543c3cdcfc955d8b0 (diff)
Switch the serialization of LangOptions over to use the .def file. We
should no longer have the serialization of LangOptions out of sync with the structure itself (yay). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139613 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticFrontendKinds.td150
-rw-r--r--include/clang/Basic/LangOptions.def187
-rw-r--r--include/clang/Basic/LangOptions.h4
-rw-r--r--lib/Serialization/ASTReader.cpp194
-rw-r--r--lib/Serialization/ASTWriter.cpp92
-rw-r--r--test/Modules/load_failure.c2
-rw-r--r--test/PCH/arc.m4
7 files changed, 142 insertions, 491 deletions
diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td
index 7ca1f30bb1..fffa42feb2 100644
--- a/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -112,139 +112,11 @@ def err_relocatable_without_isysroot : Error<
def warn_pch_target_triple : Error<
"PCH file was compiled for the target '%0' but the current translation "
"unit is being compiled for target '%1'">;
-def warn_pch_c99 : Error<
- "C99 support was %select{disabled|enabled}0 in PCH file but is "
- "currently %select{disabled|enabled}1">;
-def warn_pch_c1x : Error<
- "C1X support was %select{disabled|enabled}0 in PCH file but is "
- "currently %select{disabled|enabled}1">;
-def warn_pch_cplusplus : Error<
- "C++ support was %select{disabled|enabled}0 in PCH file but is "
- "currently %select{disabled|enabled}1">;
-def warn_pch_cplusplus0x : Error<
- "C++0x support was %select{disabled|enabled}0 in PCH file but is "
- "currently %select{disabled|enabled}1">;
-def warn_pch_objective_c : Error<
- "Objective-C support was %select{disabled|enabled}0 in PCH file but is "
- "currently %select{disabled|enabled}1">;
-def warn_pch_objective_c2 : Error<
- "Objective-C 2.0 support was %select{disabled|enabled}0 in PCH file but "
- "is currently %select{disabled|enabled}1">;
-def warn_pch_nonfragile_abi : Error<
- "PCH file was compiled with the %select{32-bit|non-fragile}0 Objective-C "
- "ABI but the %select{32-bit|non-fragile}1 Objective-C ABI is selected">;
-def warn_pch_nonfragile_abi2 : Error<
- "PCH file was compiled with the %select{32-bit|enhanced non-fragile}0 "
- "Objective-C ABI but the %select{32-bit|enhanced non-fragile}1 "
- "Objective-C ABI is selected">;
-def warn_pch_auto_ref_count : Error<
- "PCH file was compiled %select{without|with}0 automated reference counting,"
- " which is currently %select{disabled|enabled}1">;
-def warn_pch_apple_kext : Error<
- "PCH file was compiled %select{with|without}0 support for Apple's kernel "
- "extensions ABI but it is currently %select{disabled|enabled}1">;
-def warn_pch_objc_auto_properties : Error<
- "PCH file was compiled %select{with|without}0 support for auto-synthesized "
- "@properties but it is currently %select{disabled|enabled}1">;
-def warn_pch_no_constant_cfstrings : Error<
- "Objctive-C NSstring generation support was %select{disabled|enabled}0 "
- "in PCH file but currently %select{disabled|enabled}1">;
-def warn_pch_extensions : Error<
- "extensions were %select{enabled|disabled}0 in PCH file but are "
- "currently %select{enabled|disabled}1">;
-def warn_pch_gnu_extensions : Error<
- "GNU extensions were %select{disabled|enabled}0 in PCH file but are "
- "currently %select{disabled|enabled}1">;
-def warn_pch_gnu_keywords : Error<
- "GNU keywords were %select{disabled|enabled}0 in PCH file but are "
- "currently %select{disabled|enabled}1">;
-def warn_pch_microsoft_extensions : Error<
- "Microsoft extensions were %select{disabled|enabled}0 in PCH file but are "
- "currently %select{disabled|enabled}1">;
-def warn_pch_ms_bitfields : Error<
- "Microsoft-compatible structure layout was %select{disabled|enabled}0 in "
- "PCH file but is currently %select{disabled|enabled}1">;
-def warn_pch_heinous_extensions : Error<
- "heinous extensions were %select{disabled|enabled}0 in PCH file but are "
- "currently %select{disabled|enabled}1">;
-def warn_pch_lax_vector_conversions : Error<
- "lax vector conversions were %select{disabled|enabled}0 in PCH file but "
- "are currently %select{disabled|enabled}1">;
-def warn_pch_altivec : Error<
- "AltiVec initializers were %select{disabled|enabled}0 in PCH file but "
- "are currently %select{disabled|enabled}1">;
-def warn_pch_opencl : Error<
- "OpenCL language extensions were %select{disabled|enabled}0 in PCH file "
- "but are currently %select{disabled|enabled}1">;
-def warn_pch_cuda : Error<
- "CUDA language extensions were %select{disabled|enabled}0 in PCH file "
- "but are currently %select{disabled|enabled}1">;
-def warn_pch_elide_constructors : Error<
- "Elidable copy constructors were %select{disabled|enabled}0 in PCH file "
- "but are currently %select{disabled|enabled}1">;
-def warn_pch_exceptions : Error<
- "exceptions were %select{disabled|enabled}0 in PCH file but "
- "are currently %select{disabled|enabled}1">;
-def warn_pch_objc_exceptions : Error<
- "Objective-C exceptions were %select{disabled|enabled}0 in PCH file but "
- "are currently %select{disabled|enabled}1">;
-def warn_pch_cxx_exceptions : Error<
- "C++ exceptions were %select{disabled|enabled}0 in PCH file but "
- "are currently %select{disabled|enabled}1">;
-def warn_pch_sjlj_exceptions : Error<
- "sjlj-exceptions were %select{disabled|enabled}0 in PCH file but "
- "are currently %select{disabled|enabled}1">;
-def warn_pch_objc_runtime : Error<
- "PCH file was compiled with the %select{NeXT|GNU}0 runtime but the "
- "%select{NeXT|GNU}1 runtime is selected">;
-def warn_pch_freestanding : Error<
- "PCH file was compiled with a %select{hosted|freestanding}0 "
- "implementation but a %select{hosted|freestanding}1 implementation "
- "is selected">;
-def warn_pch_builtins : Error<
- "PCH file was compiled with builtins %select{enabled|disabled}0 but "
- "builtins are currently %select{enabled|disabled}1">;
-def warn_pch_thread_safe_statics : Error<
- "PCH file was compiled %select{without|with}0 thread-safe statics but "
- "thread-safe statics are currently %select{disabled|enabled}1">;
-def warn_pch_posix_threads : Error<
- "PCH file was compiled %select{without|with}0 POSIX thread support but "
- "POSIX threads are currently %select{disabled|enabled}1">;
-def warn_pch_stack_protector : Error<
- "stack protector was %select{off|on|required}0 in PCH file but "
- "is currently %select{off|on|required}1">;
-def warn_pch_blocks : Error<
- "blocks were %select{disabled|enabled}0 in PCH file but "
- "are currently %select{disabled|enabled}1">;
-def warn_pch_math_errno : Error<
- "math functions %select{do not respect|respect}0 'errno' in PCH "
- "file but they are currently set to %select{not respect|respect}1 "
- "'errno'">;
-def warn_pch_optimize : Error<
- "the macro '__OPTIMIZE__' was %select{not defined|defined}0 in "
- "the PCH file but is currently %select{undefined|defined}1">;
-def warn_pch_optimize_size : Error<
- "the macro '__OPTIMIZE_SIZE__' was %select{not defined|defined}0 in "
- "the PCH file but is currently %select{undefined|defined}1">;
-def warn_pch_static : Error<
- "the PCH file was compiled %select{dynamic|static}0 but the "
- "current translation unit is being compiled as %select{dynamic|static}1">;
-def warn_pch_pic_level : Error<
- "PCH file was compiled with PIC level %0, but the current translation "
- "unit will be compiled with PIC level %1">;
-def warn_pch_gnu_inline : Error<
- "PCH file was compiled with %select{C99|GNU|}0 inline semantics but "
- "%select{C99|GNU}1 inline semantics are currently selected">;
-def warn_pch_no_inline : Error<
- "the macro '__NO_INLINE__' was %select{not defined|defined}0 in "
- "the PCH file but is currently %select{undefined|defined}1">;
-def warn_pch_deprecated : Error<
- "the macro '__DEPRECATED' was %select{not defined|defined}0 in "
- "the PCH file but is currently %select{undefined|defined}1">;
-def warn_pch_gc_mode : Error<
- "the PCH file was built with %select{no||hybrid}0 garbage collection but "
- "the current translation unit will compiled with %select{no||hybrid}1 "
- "garbage collection">;
+def err_pch_langopt_mismatch : Error<"%0 was %select{disabled|enabled}1 in "
+ "PCH file but is currently %select{disabled|enabled}2">;
+def err_pch_langopt_value_mismatch : Error<
+ "%0 differs in PCH file vs. current file">;
+
def warn_pch_version_too_old : Error<
"PCH file uses an older PCH format that is no longer supported">;
def warn_pch_version_too_new : Error<
@@ -266,18 +138,6 @@ def warn_macro_name_used_in_pch : Error<
def warn_pch_compiler_options_mismatch : Error<
"compiler options used when building the precompiled header differ from "
"the options used when using the precompiled header">;
-def warn_pch_access_control : Error<
- "C++ access control was %select{disabled|enabled}0 in the PCH file but "
- "is currently %select{disabled|enabled}1">;
-def warn_pch_char_signed : Error<
- "char was %select{unsigned|signed}0 in the PCH file but "
- "is currently %select{unsigned|signed}1">;
-def warn_pch_short_wchar : Error<
- "-fshort-wchar was %select{disabled|enabled}0 in the PCH file but "
- "is currently %select{disabled|enabled}1">;
-def warn_pch_short_enums : Error<
- "-fshort-enums was %select{disabled|enabled}0 in the PCH file but "
- "is currently %select{disabled|enabled}1">;
def err_not_a_pch_file : Error<
"'%0' does not appear to be a precompiled header file">, DefaultFatal;
diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def
index bc559d8098..381d44beb5 100644
--- a/include/clang/Basic/LangOptions.def
+++ b/include/clang/Basic/LangOptions.def
@@ -12,14 +12,20 @@
// Optionally, the user may also define BENIGN_LANGOPT
// (for options that don't affect the construction of the AST in an
// incompatible way), ENUM_LANGOPT (for options that have enumeration,
-// rather than unsigned, type), and BENIGN_ENUM_LANGOPT (for benign
-// options that have enumeration type).
+// rather than unsigned, type), BENIGN_ENUM_LANGOPT (for benign
+// options that have enumeration type), and VALUE_LANGOPT is a language option
+// that describes a value rather than a flag.
//
//===----------------------------------------------------------------------===//
#ifndef LANGOPT
# error Define the LANGOPT macro to handle language options
#endif
+#ifndef VALUE_LANGOPT
+# define VALUE_LANGOPT(Name, Bits, Default, Description) \
+ LANGOPT(Name, Bits, Default, Description)
+#endif
+
#ifndef BENIGN_LANGOPT
# define BENIGN_LANGOPT(Name, Bits, Default, Description) \
LANGOPT(Name, Bits, Default, Description)
@@ -35,113 +41,114 @@
ENUM_LANGOPT(Name, Type, Bits, Default, Description)
#endif
-LANGOPT(Trigraphs , 1, 0,"Trigraphs in source files")
-LANGOPT(BCPLComment , 1, 0, "BCPL-style '//' comments")
-LANGOPT(Bool , 1, 0, "'bool', 'true', 'false' keywords")
-BENIGN_LANGOPT(DollarIdents , 1, 0, "'$' allowed in identifiers")
-BENIGN_LANGOPT(AsmPreprocessor , 1, 0, "Preprocessor in asm mode")
-BENIGN_LANGOPT(GNUMode , 1, 0, "True in gnu99 mode false in c99 mode (etc)")
-LANGOPT(GNUKeywords , 1, 0, "True if GNU-only keywords are allowed")
-BENIGN_LANGOPT(ImplicitInt , 1, 0, "C89 implicit 'int'")
-LANGOPT(Digraphs , 1, 0, "C94, C99 and C++")
-BENIGN_LANGOPT(HexFloats , 1, 0, "C99 Hexadecimal float constants")
-LANGOPT(C99 , 1, 0, "C99 Support")
-LANGOPT(C1X , 1, 0, "C1X Support")
+LANGOPT(C99 , 1, 0, "C99")
+LANGOPT(C1X , 1, 0, "C1X")
LANGOPT(Microsoft , 1, 0, "Microsoft extensions")
LANGOPT(Borland , 1, 0, "Borland extensions")
-LANGOPT(CPlusPlus , 1, 0, "C++ Support")
-LANGOPT(CPlusPlus0x , 1, 0, "C++0x Support")
-LANGOPT(CXXOperatorNames , 1, 0, "Treat C++ operator names as keywords")
-LANGOPT(ObjC1 , 1, 0, "Objective-C 1 support enabled")
-LANGOPT(ObjC2 , 1, 0, "Objective-C 2 support enabled")
-LANGOPT(ObjCNonFragileABI , 1, 0, "Objective-C modern abi enabled")
-LANGOPT(ObjCNonFragileABI2 , 1, 0, "Objective-C enhanced modern abi enabled")
+LANGOPT(CPlusPlus , 1, 0, "C++")
+LANGOPT(CPlusPlus0x , 1, 0, "C++0x")
+LANGOPT(ObjC1 , 1, 0, "Objective-C 1")
+LANGOPT(ObjC2 , 1, 0, "Objective-C 2")
+LANGOPT(ObjCNonFragileABI , 1, 0, "Objective-C modern abi")
+LANGOPT(ObjCNonFragileABI2 , 1, 0, "Objective-C enhanced modern abi")
BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0,
"Objective-C auto-synthesized properties")
BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1,
- "Infer Objective-C related return types")
-LANGOPT(AppleKext , 1, 0, "Allow apple kext features")
-BENIGN_LANGOPT(PascalStrings , 1, 0, "Allow Pascal strings")
-LANGOPT(WritableStrings , 1, 0, "Allow writable strings")
-LANGOPT(ConstStrings , 1, 0,
- "Add const qualifier to strings (-Wwrite-strings)")
-LANGOPT(LaxVectorConversions , 1, 1, "Supprt lax vector conversions")
-LANGOPT(AltiVec , 1, 0, "Support AltiVec-style vector initializers")
-LANGOPT(Exceptions , 1, 0, "Support exception handling")
-LANGOPT(ObjCExceptions , 1, 0, "Support Objective-C exceptions")
-LANGOPT(CXXExceptions , 1, 0, "Support C++ exceptions")
-LANGOPT(SjLjExceptions , 1, 0, "Use setjmp-longjump exception handling")
-LANGOPT(TraditionalCPP , 1, 0, "Enable some traditional CPP emulation")
-LANGOPT(RTTI , 1, 1, "Support RTTI information")
-LANGOPT(MSBitfields , 1, 0, "MS-compatible structure layout")
-LANGOPT(NeXTRuntime , 1, 1, "Use NeXT runtime")
-BENIGN_LANGOPT(Freestanding , 1, 0, "Freestanding implementation")
-LANGOPT(NoBuiltin , 1, 0, "Do not use builtin functions (-fno-builtin)")
-
-BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "Whether static initializers are protected by locks")
-LANGOPT(POSIXThreads , 1, 0, "Compiling with POSIX thread support")
-BENIGN_LANGOPT(Blocks , 1, 0, "Support blocks extension to C")
-BENIGN_LANGOPT(EmitAllDecls , 1, 0, "Emit all declarations, even if they are unused")
-LANGOPT(MathErrno , 1, 1, "Math functions must respect errno (modulo the platform support)")
+ "Objective-C related result type inference")
+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(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'")
+LANGOPT(Digraphs , 1, 0, "digraphs")
+BENIGN_LANGOPT(HexFloats , 1, 0, "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")
+LANGOPT(WritableStrings , 1, 0, "writable string support")
+LANGOPT(ConstStrings , 1, 0, "const-qualified string support")
+LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions")
+LANGOPT(AltiVec , 1, 0, "AltiVec-style vector initializers")
+LANGOPT(Exceptions , 1, 0, "exception handling")
+LANGOPT(ObjCExceptions , 1, 0, "Objective-C exceptions")
+LANGOPT(CXXExceptions , 1, 0, "C++ exceptions")
+LANGOPT(SjLjExceptions , 1, 0, "setjmp-longjump exception handling")
+LANGOPT(TraditionalCPP , 1, 0, "traditional CPP emulation")
+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(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")
+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")
-LANGOPT(Optimize , 1, 0, "Whether __OPTIMIZE__ should be defined")
-LANGOPT(OptimizeSize , 1, 0, "Whether __OPTIMIZE_SIZE__ should be defined")
-LANGOPT(Static , 1, 0, "Should __STATIC__ be defined (as opposed to __DYNAMIC__)")
-LANGOPT(PICLevel , 2, 0, "The value for __PIC__, if non-zero")
-LANGOPT(GNUInline , 1, 0, "Should GNU inline semantics be used (instead of C99 semantics)")
-LANGOPT(NoInline , 1, 0, "Should __NO_INLINE__ be defined")
-LANGOPT(Deprecated , 1, 0, "Should __DEPRECATED be defined")
-
-LANGOPT(ObjCGCBitmapPrint , 1, 0, "Enable printing of gc's bitmap layout for __weak/__strong ivars")
-
-BENIGN_LANGOPT(AccessControl , 1, 1, "Whether C++ access control should be enabled")
-LANGOPT(CharIsSigned , 1, 1, "Whether char is a signed or unsigned type")
-LANGOPT(ShortWChar , 1, 0, "Force wchar_t to be unsigned short int")
-
-LANGOPT(ShortEnums , 1, 0, "The enum type will be equivalent to the smallest integer type with enough room")
-
-LANGOPT(OpenCL , 1, 0, "OpenCL C99 language extensions")
-LANGOPT(CUDA , 1, 0, "CUDA C++ language extensions")
-
-LANGOPT(AssumeSaneOperatorNew , 1, 1, "Whether to add __attribute__((malloc)) to the declaration of C++'s new operators")
-BENIGN_LANGOPT(ElideConstructors , 1, 1, "Whether C++ copy constructors should be elided if possible")
-BENIGN_LANGOPT(CatchUndefined , 1, 0, "Generate code to check for undefined ops")
-BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "Dump the layout of IRgen'd records")
-BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "Dump the layouts of emitted vtables")
-LANGOPT(NoConstantCFStrings , 1, 0, "Do not do CF strings")
-LANGOPT(InlineVisibilityHidden , 1, 0, "Whether inline C++ methods have hidden visibility by default")
-BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "Let the user write __unknown_anytype")
-BENIGN_LANGOPT(DebuggerSupport , 1, 0, "Do things that only make sense when supporting a debugger")
-
-BENIGN_LANGOPT(SpellChecking , 1, 1, "Whether to perform spell-checking for error recovery")
-LANGOPT(SinglePrecisionConstants , 1, 0, "Whether to treat double-precision floating point constants as single precision constants")
-LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math (on its own, defines __FAST_RELAXED_MATH__)")
-LANGOPT(DefaultFPContract , 1, 0, "Default setting for FP_CONTRACT")
-LANGOPT(NoBitFieldTypeAlign , 1, 0, "Temporary option, used for testing purposes")
-LANGOPT(ObjCAutoRefCount , 1, 0, "Objective C automated reference counting")
-LANGOPT(ObjCRuntimeHasWeak , 1, 0, "The ARC runtime supports __weak")
-LANGOPT(FakeAddressSpaceMap , 1, 0, "Use a fake address space map, for testing languages such as OpenCL")
+LANGOPT(Optimize , 1, 0, "__OPTIMIZE__ predefined macro")
+LANGOPT(OptimizeSize , 1, 0, "__OPTIMIZE_SIZE__ predefined macro")
+LANGOPT(Static , 1, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)")
+VALUE_LANGOPT(PICLevel , 2, 0, "__PIC__ level")
+LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
+LANGOPT(NoInline , 1, 0, "__NO_INLINE__ predefined macro")
+LANGOPT(Deprecated , 1, 0, "__DEPRECATED predefined macro")
+
+BENIGN_LANGOPT(ObjCGCBitmapPrint , 1, 0, "printing of GC's bitmap layout for __weak/__strong ivars")
+
+BENIGN_LANGOPT(AccessControl , 1, 1, "C++ access control")
+LANGOPT(CharIsSigned , 1, 1, "signed char")
+LANGOPT(ShortWChar , 1, 0, "unsigned short wchar_t")
+
+LANGOPT(ShortEnums , 1, 0, "short enum types")
+
+LANGOPT(OpenCL , 1, 0, "OpenCL")
+LANGOPT(CUDA , 1, 0, "CUDA")
+
+LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for C++'s new operators")
+BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
+BENIGN_LANGOPT(CatchUndefined , 1, 0, "catching undefined behavior at run time")
+BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records")
+BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted vtables")
+LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")
+BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden default visibility for inline C++ methods")
+BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "__unknown_anytype")
+BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support")
+
+BENIGN_LANGOPT(SpellChecking , 1, 1, "spell-checking")
+LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating point constants as single precision constants")
+LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math")
+LANGOPT(DefaultFPContract , 1, 0, "FP_CONTRACT")
+LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")
+LANGOPT(ObjCAutoRefCount , 1, 0, "Objective-C automated reference counting")
+LANGOPT(ObjCRuntimeHasWeak , 1, 0, "__weak support in the ARC runtime")
+LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
LANGOPT(MRTD , 1, 0, "-mrtd calling convention")
-BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "Delayed template parsing")
-LANGOPT(BlocksRuntimeOptional , 1, 0, "The blocks runtime is not guaranteed")
+BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
+LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
ENUM_LANGOPT(VisibilityMode, Visibility, 3, DefaultVisibility,
"symbol visibility")
ENUM_LANGOPT(StackProtector, StackProtectorMode, 2, SSPOff,
- "Whether stack protectors are on")
+ "stack protector mode")
ENUM_LANGOPT(SignedOverflowBehavior, SignedOverflowBehaviorTy, 2, SOB_Undefined,
- "How to handle signed integer overflow.")
+ "signed integer overflow handling")
-BENIGN_LANGOPT(InstantiationDepth, 32, 1024, "Maximum template instantiation depth")
+BENIGN_LANGOPT(InstantiationDepth, 32, 1024,
+ "maximum template instantiation depth")
BENIGN_LANGOPT(NumLargeByValueCopy, 32, 0,
- "Warn if parameter/return value is larger in bytes than this setting. 0 is no check.")
-BENIGN_LANGOPT(MSCVersion, 32, 0,
- "Version of Microsoft Visual C/C++ we are pretending to be")
+ "if non-zero, warn about parameter or return Warn if parameter/return value is larger in bytes than this setting. 0 is no check.")
+VALUE_LANGOPT(MSCVersion, 32, 0,
+ "version of Microsoft Visual C/C++")
#undef LANGOPT
+#undef VALUE_LANGOPT
#undef BENIGN_LANGOPT
#undef ENUM_LANGOPT
#undef BENIGN_ENUM_LANGOPT
diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h
index 34d836a73e..e8e1afcaef 100644
--- a/include/clang/Basic/LangOptions.h
+++ b/include/clang/Basic/LangOptions.h
@@ -19,12 +19,12 @@
namespace clang {
-class OptionSignature;
-
/// LangOptions - This class keeps track of the various options that can be
/// enabled, which controls the dialect of C that is accepted.
class LangOptions {
public:
+ typedef clang::Visibility Visibility;
+
enum GCMode { NonGC, GCOnly, HybridGC };
enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index dc359c1a00..429edf9dd7 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -65,98 +65,32 @@ ASTReaderListener::~ASTReaderListener() {}
bool
PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts) {
const LangOptions &PPLangOpts = PP.getLangOptions();
-#define PARSE_LANGOPT_BENIGN(Option)
-#define PARSE_LANGOPT_IMPORTANT(Option, DiagID) \
- if (PPLangOpts.Option != LangOpts.Option) { \
- Reader.Diag(DiagID) << LangOpts.Option << PPLangOpts.Option; \
- return true; \
- }
-
- PARSE_LANGOPT_BENIGN(Trigraphs);
- PARSE_LANGOPT_BENIGN(BCPLComment);
- PARSE_LANGOPT_BENIGN(DollarIdents);
- PARSE_LANGOPT_BENIGN(AsmPreprocessor);
- PARSE_LANGOPT_IMPORTANT(GNUMode, diag::warn_pch_gnu_extensions);
- PARSE_LANGOPT_IMPORTANT(GNUKeywords, diag::warn_pch_gnu_keywords);
- PARSE_LANGOPT_BENIGN(ImplicitInt);
- PARSE_LANGOPT_BENIGN(Digraphs);
- PARSE_LANGOPT_BENIGN(HexFloats);
- PARSE_LANGOPT_IMPORTANT(C99, diag::warn_pch_c99);
- PARSE_LANGOPT_IMPORTANT(C1X, diag::warn_pch_c1x);
- PARSE_LANGOPT_IMPORTANT(Microsoft, diag::warn_pch_microsoft_extensions);
- PARSE_LANGOPT_BENIGN(MSCVersion);
- PARSE_LANGOPT_IMPORTANT(CPlusPlus, diag::warn_pch_cplusplus);
- PARSE_LANGOPT_IMPORTANT(CPlusPlus0x, diag::warn_pch_cplusplus0x);
- PARSE_LANGOPT_BENIGN(CXXOperatorName);
- PARSE_LANGOPT_IMPORTANT(ObjC1, diag::warn_pch_objective_c);
- PARSE_LANGOPT_IMPORTANT(ObjC2, diag::warn_pch_objective_c2);
- PARSE_LANGOPT_IMPORTANT(ObjCNonFragileABI, diag::warn_pch_nonfragile_abi);
- PARSE_LANGOPT_IMPORTANT(ObjCNonFragileABI2, diag::warn_pch_nonfragile_abi2);
- PARSE_LANGOPT_IMPORTANT(AppleKext, diag::warn_pch_apple_kext);
- PARSE_LANGOPT_IMPORTANT(ObjCDefaultSynthProperties,
- diag::warn_pch_objc_auto_properties);
- PARSE_LANGOPT_BENIGN(ObjCInferRelatedResultType)
- PARSE_LANGOPT_IMPORTANT(NoConstantCFStrings,
- diag::warn_pch_no_constant_cfstrings);
- PARSE_LANGOPT_BENIGN(PascalStrings);
- PARSE_LANGOPT_BENIGN(WritableStrings);
- PARSE_LANGOPT_IMPORTANT(LaxVectorConversions,
- diag::warn_pch_lax_vector_conversions);
- PARSE_LANGOPT_IMPORTANT(AltiVec, diag::warn_pch_altivec);
- PARSE_LANGOPT_IMPORTANT(Exceptions, diag::warn_pch_exceptions);
- PARSE_LANGOPT_IMPORTANT(ObjCExceptions, diag::warn_pch_objc_exceptions);
- PARSE_LANGOPT_IMPORTANT(CXXExceptions, diag::warn_pch_cxx_exceptions);
- PARSE_LANGOPT_IMPORTANT(SjLjExceptions, diag::warn_pch_sjlj_exceptions);
- PARSE_LANGOPT_IMPORTANT(MSBitfields, diag::warn_pch_ms_bitfields);
- PARSE_LANGOPT_IMPORTANT(NeXTRuntime, diag::warn_pch_objc_runtime);
- PARSE_LANGOPT_IMPORTANT(Freestanding, diag::warn_pch_freestanding);
- PARSE_LANGOPT_IMPORTANT(NoBuiltin, diag::warn_pch_builtins);
- PARSE_LANGOPT_IMPORTANT(ThreadsafeStatics,
- diag::warn_pch_thread_safe_statics);
- PARSE_LANGOPT_IMPORTANT(POSIXThreads, diag::warn_pch_posix_threads);
- PARSE_LANGOPT_IMPORTANT(Blocks, diag::warn_pch_blocks);
- PARSE_LANGOPT_BENIGN(EmitAllDecls);
- PARSE_LANGOPT_IMPORTANT(MathErrno, diag::warn_pch_math_errno);
- PARSE_LANGOPT_BENIGN(getSignedOverflowBehavior());
- PARSE_LANGOPT_IMPORTANT(HeinousExtensions,
- diag::warn_pch_heinous_extensions);
- // FIXME: Most of the options below are benign if the macro wasn't
- // used. Unfortunately, this means that a PCH compiled without
- // optimization can't be used with optimization turned on, even
- // though the only thing that changes is whether __OPTIMIZE__ was
- // defined... but if __OPTIMIZE__ never showed up in the header, it
- // doesn't matter. We could consider making this some special kind
- // of check.
- PARSE_LANGOPT_IMPORTANT(Optimize, diag::warn_pch_optimize);
- PARSE_LANGOPT_IMPORTANT(OptimizeSize, diag::warn_pch_optimize_size);
- PARSE_LANGOPT_IMPORTANT(Static, diag::warn_pch_static);
- PARSE_LANGOPT_IMPORTANT(PICLevel, diag::warn_pch_pic_level);
- PARSE_LANGOPT_IMPORTANT(GNUInline, diag::warn_pch_gnu_inline);
- PARSE_LANGOPT_IMPORTANT(NoInline, diag::warn_pch_no_inline);
- PARSE_LANGOPT_IMPORTANT(Deprecated, diag::warn_pch_deprecated);
- PARSE_LANGOPT_IMPORTANT(AccessControl, diag::warn_pch_access_control);
- PARSE_LANGOPT_IMPORTANT(CharIsSigned, diag::warn_pch_char_signed);
- PARSE_LANGOPT_IMPORTANT(ShortWChar, diag::warn_pch_short_wchar);
- PARSE_LANGOPT_IMPORTANT(ShortEnums, diag::warn_pch_short_enums);
- if ((PPLangOpts.getGC() != 0) != (LangOpts.getGC() != 0)) {
- Reader.Diag(diag::warn_pch_gc_mode)
- << LangOpts.getGC() << PPLangOpts.getGC();
- return true;
+
+#define LANGOPT(Name, Bits, Default, Description) \
+ if (PPLangOpts.Name != LangOpts.Name) { \
+ Reader.Diag(diag::err_pch_langopt_mismatch) \
+ << Description << LangOpts.Name << PPLangOpts.Name; \
+ return true; \
+ }
+
+#define VALUE_LANGOPT(Name, Bits, Default, Description) \
+ if (PPLangOpts.Name != LangOpts.Name) { \
+ Reader.Diag(diag::err_pch_langopt_value_mismatch) \
+ << Description; \
+ return true; \
+}
+
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
+ if (PPLangOpts.get##Name() != LangOpts.get##Name()) { \
+ Reader.Diag(diag::err_pch_langopt_value_mismatch) \
+ << Description; \
+ return true; \
}
- PARSE_LANGOPT_BENIGN(getVisibilityMode());
- PARSE_LANGOPT_IMPORTANT(getStackProtector(),
- diag::warn_pch_stack_protector);
- PARSE_LANGOPT_BENIGN(InstantiationDepth);
- PARSE_LANGOPT_IMPORTANT(OpenCL, diag::warn_pch_opencl);
- PARSE_LANGOPT_IMPORTANT(CUDA, diag::warn_pch_cuda);
- PARSE_LANGOPT_BENIGN(CatchUndefined);
- PARSE_LANGOPT_BENIGN(DefaultFPContract);
- PARSE_LANGOPT_IMPORTANT(ElideConstructors, diag::warn_pch_elide_constructors);
- PARSE_LANGOPT_BENIGN(SpellChecking);
- PARSE_LANGOPT_IMPORTANT(ObjCAutoRefCount, diag::warn_pch_auto_ref_count);
-#undef PARSE_LANGOPT_IMPORTANT
-#undef PARSE_LANGOPT_BENIGN
+#define BENIGN_LANGOPT(Name, Bits, Default, Description)
+#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
+#include "clang/Basic/LangOptions.def"
+
return false;
}
@@ -2989,81 +2923,13 @@ bool ASTReader::ParseLanguageOptions(
const SmallVectorImpl<uint64_t> &Record) {
if (Listener) {
LangOptions LangOpts;
-
- #define PARSE_LANGOPT(Option) \
- LangOpts.Option = Record[Idx]; \
- ++Idx
-
unsigned Idx = 0;
- PARSE_LANGOPT(Trigraphs);
- PARSE_LANGOPT(BCPLComment);
- PARSE_LANGOPT(DollarIdents);
- PARSE_LANGOPT(AsmPreprocessor);
- PARSE_LANGOPT(GNUMode);
- PARSE_LANGOPT(GNUKeywords);
- PARSE_LANGOPT(ImplicitInt);
- PARSE_LANGOPT(Digraphs);
- PARSE_LANGOPT(HexFloats);
- PARSE_LANGOPT(C99);
- PARSE_LANGOPT(C1X);
- PARSE_LANGOPT(Microsoft);
- PARSE_LANGOPT(CPlusPlus);
- PARSE_LANGOPT(CPlusPlus0x);
- PARSE_LANGOPT(CXXOperatorNames);
- PARSE_LANGOPT(ObjC1);
- PARSE_LANGOPT(ObjC2);
- PARSE_LANGOPT(ObjCNonFragileABI);
- PARSE_LANGOPT(ObjCNonFragileABI2);
- PARSE_LANGOPT(AppleKext);
- PARSE_LANGOPT(ObjCDefaultSynthProperties);
- PARSE_LANGOPT(ObjCInferRelatedResultType);
- PARSE_LANGOPT(NoConstantCFStrings);
- PARSE_LANGOPT(PascalStrings);
- PARSE_LANGOPT(WritableStrings);
- PARSE_LANGOPT(LaxVectorConversions);
- PARSE_LANGOPT(AltiVec);
- PARSE_LANGOPT(Exceptions);
- PARSE_LANGOPT(ObjCExceptions);
- PARSE_LANGOPT(CXXExceptions);
- PARSE_LANGOPT(SjLjExceptions);
- PARSE_LANGOPT(MSBitfields);
- PARSE_LANGOPT(NeXTRuntime);
- PARSE_LANGOPT(Freestanding);
- PARSE_LANGOPT(NoBuiltin);
- PARSE_LANGOPT(ThreadsafeStatics);
- PARSE_LANGOPT(POSIXThreads);
- PARSE_LANGOPT(Blocks);
- PARSE_LANGOPT(EmitAllDecls);
- PARSE_LANGOPT(MathErrno);
- LangOpts.setSignedOverflowBehavior((LangOptions::SignedOverflowBehaviorTy)
- Record[Idx++]);
- PARSE_LANGOPT(HeinousExtensions);
- PARSE_LANGOPT(Optimize);
- PARSE_LANGOPT(OptimizeSize);
- PARSE_LANGOPT(Static);
- PARSE_LANGOPT(PICLevel);
- PARSE_LANGOPT(GNUInline);
- PARSE_LANGOPT(NoInline);
- PARSE_LANGOPT(Deprecated);
- PARSE_LANGOPT(AccessControl);
- PARSE_LANGOPT(CharIsSigned);
- PARSE_LANGOPT(ShortWChar);
- PARSE_LANGOPT(ShortEnums);
- LangOpts.setGC((LangOptions::GCMode)Record[Idx++]);
- LangOpts.setVisibilityMode((Visibility)Record[Idx++]);
- LangOpts.setStackProtector((LangOptions::StackProtectorMode)
- Record[Idx++]);
- PARSE_LANGOPT(InstantiationDepth);
- PARSE_LANGOPT(OpenCL);
- PARSE_LANGOPT(CUDA);
- PARSE_LANGOPT(CatchUndefined);
- PARSE_LANGOPT(DefaultFPContract);
- PARSE_LANGOPT(ElideConstructors);
- PARSE_LANGOPT(SpellChecking);
- PARSE_LANGOPT(MRTD);
- PARSE_LANGOPT(ObjCAutoRefCount);
- #undef PARSE_LANGOPT
-
+#define LANGOPT(Name, Bits, Default, Description) \
+ LangOpts.Name = Record[Idx++];
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
+ LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++]));
+#include "clang/Basic/LangOptions.def"
+
return Listener->ReadLanguageOptions(LangOpts);
}
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index a3f0cf7b89..28a69d4bdb 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -1047,93 +1047,11 @@ void ASTWriter::WriteMetadata(ASTContext &Context, StringRef isysroot,
/// \brief Write the LangOptions structure.
void ASTWriter::WriteLanguageOptions(const LangOptions &LangOpts) {
RecordData Record;
- Record.push_back(LangOpts.Trigraphs);
- Record.push_back(LangOpts.BCPLComment); // BCPL-style '//' comments.
- Record.push_back(LangOpts.DollarIdents); // '$' allowed in identifiers.
- Record.push_back(LangOpts.AsmPreprocessor); // Preprocessor in asm mode.
- Record.push_back(LangOpts.GNUMode); // True in gnu99 mode false in c99 mode (etc)
- Record.push_back(LangOpts.GNUKeywords); // Allow GNU-extension keywords
- Record.push_back(LangOpts.ImplicitInt); // C89 implicit 'int'.
- Record.push_back(LangOpts.Digraphs); // C94, C99 and C++
- Record.push_back(LangOpts.HexFloats); // C99 Hexadecimal float constants.
- Record.push_back(LangOpts.C99); // C99 Support
- Record.push_back(LangOpts.C1X); // C1X Support
- Record.push_back(LangOpts.Microsoft); // Microsoft extensions.
- // LangOpts.MSCVersion is ignored because all it does it set a macro, which is
- // already saved elsewhere.
- Record.push_back(LangOpts.CPlusPlus); // C++ Support
- Record.push_back(LangOpts.CPlusPlus0x); // C++0x Support
- Record.push_back(LangOpts.CXXOperatorNames); // Treat C++ operator names as keywords.
-
- Record.push_back(LangOpts.ObjC1); // Objective-C 1 support enabled.
- Record.push_back(LangOpts.ObjC2); // Objective-C 2 support enabled.
- Record.push_back(LangOpts.ObjCNonFragileABI); // Objective-C
- // modern abi enabled.
- Record.push_back(LangOpts.ObjCNonFragileABI2); // Objective-C enhanced
- // modern abi enabled.
- Record.push_back(LangOpts.AppleKext); // Apple's kernel extensions ABI
- Record.push_back(LangOpts.ObjCDefaultSynthProperties); // Objective-C auto-synthesized
- // properties enabled.
- Record.push_back(LangOpts.ObjCInferRelatedResultType);
- Record.push_back(LangOpts.NoConstantCFStrings); // non cfstring generation enabled..
-
- Record.push_back(LangOpts.PascalStrings); // Allow Pascal strings
- Record.push_back(LangOpts.WritableStrings); // Allow writable strings
- Record.push_back(LangOpts.LaxVectorConversions);
- Record.push_back(LangOpts.AltiVec);
- Record.push_back(LangOpts.Exceptions); // Support exception handling.
- Record.push_back(LangOpts.ObjCExceptions);
- Record.push_back(LangOpts.CXXExceptions);
- Record.push_back(LangOpts.SjLjExceptions);
-
- Record.push_back(LangOpts.MSBitfields); // MS-compatible structure layout
- Record.push_back(LangOpts.NeXTRuntime); // Use NeXT runtime.
- Record.push_back(LangOpts.Freestanding); // Freestanding implementation
- Record.push_back(LangOpts.NoBuiltin); // Do not use builtin functions (-fno-builtin)
-
- // Whether static initializers are protected by locks.
- Record.push_back(LangOpts.ThreadsafeStatics);
- Record.push_back(LangOpts.POSIXThreads);
- Record.push_back(LangOpts.Blocks); // block extension to C
- Record.push_back(LangOpts.EmitAllDecls); // Emit all declarations, even if
- // they are unused.
- Record.push_back(LangOpts.MathErrno); // Math functions must respect errno
- // (modulo the platform support).
-
- Record.push_back(LangOpts.getSignedOverflowBehavior());
- Record.push_back(LangOpts.HeinousExtensions);
-
- Record.push_back(LangOpts.Optimize); // Whether __OPTIMIZE__ should be defined.
- Record.push_back(LangOpts.OptimizeSize); // Whether __OPTIMIZE_SIZE__ should be
- // defined.
- Record.push_back(LangOpts.Static); // Should __STATIC__ be defined (as
- // opposed to __DYNAMIC__).
- Record.push_back(LangOpts.PICLevel); // The value for __PIC__, if non-zero.
-
- Record.push_back(LangOpts.GNUInline); // Should GNU inline semantics be
- // used (instead of C99 semantics).
- Record.push_back(LangOpts.NoInline); // Should __NO_INLINE__ be defined.
- Record.push_back(LangOpts.Deprecated); // Should __DEPRECATED be defined.
- Record.push_back(LangOpts.AccessControl); // Whether C++ access control should
- // be enabled.
- Record.push_back(LangOpts.CharIsSigned); // Whether char is a signed or
- // unsigned type
- Record.push_back(LangOpts.ShortWChar); // force wchar_t to be unsigned short
- Record.push_back(LangOpts.ShortEnums); // Should the enum type be equivalent
- // to the smallest integer type with
- // enough room.
- Record.push_back(LangOpts.getGC());
- Record.push_back(LangOpts.getVisibilityMode());
- Record.push_back(LangOpts.getStackProtector());
- Record.push_back(LangOpts.InstantiationDepth);
- Record.push_back(LangOpts.OpenCL);
- Record.push_back(LangOpts.CUDA);
- Record.push_back(LangOpts.CatchUndefined);
- Record.push_back(LangOpts.DefaultFPContract);
- Record.push_back(LangOpts.ElideConstructors);
- Record.push_back(LangOpts.SpellChecking);
- Record.push_back(LangOpts.MRTD);
- Record.push_back(LangOpts.ObjCAutoRefCount);
+#define LANGOPT(Name, Bits, Default, Description) \
+ Record.push_back(LangOpts.Name);
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
+ Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
+#include "clang/Basic/LangOptions.def"
Stream.EmitRecord(LANGUAGE_OPTIONS, Record);
}
diff --git a/test/Modules/load_failure.c b/test/Modules/load_failure.c
index 4685a41ef6..55e3d40a3f 100644
--- a/