diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/CodeGenOptions.cpp | 48 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 18 |
2 files changed, 33 insertions, 33 deletions
diff --git a/clang/lib/Basic/CodeGenOptions.cpp b/clang/lib/Basic/CodeGenOptions.cpp index 1f899de..9a2aa9b 100644 --- a/clang/lib/Basic/CodeGenOptions.cpp +++ b/clang/lib/Basic/CodeGenOptions.cpp @@ -11,43 +11,39 @@ namespace clang { CodeGenOptions::CodeGenOptions() { -#define CODEGENOPT(Name, Bits, Default) Name = Default; -#define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default); +#define CODEGENOPT(Name, Bits, Default, Compatibility) Name = Default; +#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \ + set##Name(Default); #include "clang/Basic/CodeGenOptions.def" RelocationModel = llvm::Reloc::PIC_; } void CodeGenOptions::resetNonModularOptions(StringRef ModuleFormat) { - // First reset all CodeGen options only. The Debug options are handled later. -#define DEBUGOPT(Name, Bits, Default) -#define VALUE_DEBUGOPT(Name, Bits, Default) -#define ENUM_DEBUGOPT(Name, Type, Bits, Default) -#define CODEGENOPT(Name, Bits, Default) Name = Default; -#define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default); -// Do not reset AST affecting code generation options. -#define AFFECTING_VALUE_CODEGENOPT(Name, Bits, Default) + // FIXME: Replace with C++20 `using enum CodeGenOptions::CompatibilityKind`. + using CK = CompatibilityKind; + + // First reset benign codegen and debug options. +#define CODEGENOPT(Name, Bits, Default, Compatibility) \ + if constexpr (CK::Compatibility == CK::Benign) \ + Name = Default; +#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \ + if constexpr (CK::Compatibility == CK::Benign) \ + set##Name(Default); #include "clang/Basic/CodeGenOptions.def" - // Next reset all debug options that can always be reset, because they never - // affect the PCM. -#define DEBUGOPT(Name, Bits, Default) -#define VALUE_DEBUGOPT(Name, Bits, Default) -#define ENUM_DEBUGOPT(Name, Type, Bits, Default) -#define BENIGN_DEBUGOPT(Name, Bits, Default) Name = Default; -#define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default) Name = Default; -#define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default) set##Name(Default); -#include "clang/Basic/DebugOptions.def" - // Conditionally reset debug options that only matter when the debug info is // emitted into the PCM (-gmodules). if (ModuleFormat == "raw" && !DebugTypeExtRefs) { -#define DEBUGOPT(Name, Bits, Default) Name = Default; -#define VALUE_DEBUGOPT(Name, Bits, Default) Name = Default; -#define ENUM_DEBUGOPT(Name, Type, Bits, Default) set##Name(Default); -#define BENIGN_DEBUGOPT(Name, Bits, Default) -#define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default) -#define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default) +#define DEBUGOPT(Name, Bits, Default, Compatibility) \ + if constexpr (CK::Compatibility == CK::Affecting) \ + Name = Default; +#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility) \ + if constexpr (CK::Compatibility == CK::Affecting) \ + Name = Default; +#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility) \ + if constexpr (CK::Compatibility == CK::Affecting) \ + set##Name(Default); #include "clang/Basic/DebugOptions.def" } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index e233821..b9f7579 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -5308,13 +5308,17 @@ std::string CompilerInvocation::getModuleHash() const { // Extend the signature with the affecting debug options. if (getHeaderSearchOpts().ModuleFormat == "obj") { -#define DEBUGOPT(Name, Bits, Default) HBuilder.add(CodeGenOpts->Name); -#define VALUE_DEBUGOPT(Name, Bits, Default) HBuilder.add(CodeGenOpts->Name); -#define ENUM_DEBUGOPT(Name, Type, Bits, Default) \ - HBuilder.add(static_cast<unsigned>(CodeGenOpts->get##Name())); -#define BENIGN_DEBUGOPT(Name, Bits, Default) -#define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default) -#define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default) + // FIXME: Replace with C++20 `using enum CodeGenOptions::CompatibilityKind`. + using CK = CodeGenOptions::CompatibilityKind; +#define DEBUGOPT(Name, Bits, Default, Compatibility) \ + if constexpr (CK::Compatibility == CK::Affecting) \ + HBuilder.add(CodeGenOpts->Name); +#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility) \ + if constexpr (CK::Compatibility == CK::Affecting) \ + HBuilder.add(CodeGenOpts->Name); +#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility) \ + if constexpr (CK::Compatibility == CK::Affecting) \ + HBuilder.add(static_cast<unsigned>(CodeGenOpts->get##Name())); #include "clang/Basic/DebugOptions.def" } |