From 9f1b9560e7ee542471c89b193c6aea4c674ffe23 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Mon, 7 Jul 2025 09:02:56 -0700 Subject: [clang] Refactor `CodeGenOptions` to specify compatibility as X macro arg (#146910) This is the `CodeGenOptions` counterpart to https://github.com/llvm/llvm-project/pull/146766. --- clang/lib/Frontend/CompilerInvocation.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') 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(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(CodeGenOpts->get##Name())); #include "clang/Basic/DebugOptions.def" } -- cgit v1.1