aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@ributzka.de>2023-12-05 08:31:21 -0800
committerGitHub <noreply@github.com>2023-12-05 08:31:21 -0800
commit5ad3a32c79319b0721cb26398946b9a59b50d264 (patch)
tree729565f82cc46362de5a67f32ea0d8fa73b2f9d8 /clang/lib/Frontend/CompilerInvocation.cpp
parent4e0275a2c8f7f94cc1aacf4803fc827fad8f56d4 (diff)
downloadllvm-5ad3a32c79319b0721cb26398946b9a59b50d264.zip
llvm-5ad3a32c79319b0721cb26398946b9a59b50d264.tar.gz
llvm-5ad3a32c79319b0721cb26398946b9a59b50d264.tar.bz2
[clang][modules] Reset codegen options (take 2). (#74388)
CodeGen options do not affect the AST, so they usually can be ignored. The only exception to the rule is when a PCM is created with `-gmodules`. In that case the Clang module format is switched to object file container and contains also serialized debug information that can be affected by debug options. There the following approach was choosen: 1.) Split out all the debug options into a separate `DebugOptions.def` file. The file is included by `CodeGenOptions.def`, so the change is transparent to all existing users of `CodeGenOptions.def`. 2.) Reset all CodeGen options, but excluding affecting debug options. 3.) Conditionally reset debug options that can affect the PCM. This fixes rdar://113135909.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index be0d496..56de0f7 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4787,6 +4787,18 @@ std::string CompilerInvocation::getModuleHash() const {
if (getCodeGenOpts().DebugTypeExtRefs)
HBuilder.addRange(getCodeGenOpts().DebugPrefixMap);
+ // 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)
+#include "clang/Basic/DebugOptions.def"
+ }
+
// Extend the signature with the enabled sanitizers, if at least one is
// enabled. Sanitizers which cannot affect AST generation aren't hashed.
SanitizerSet SanHash = getLangOpts().Sanitize;
@@ -4833,6 +4845,7 @@ std::vector<std::string> CompilerInvocationBase::getCC1CommandLine() const {
void CompilerInvocation::resetNonModularOptions() {
getLangOpts().resetNonModularOptions();
getPreprocessorOpts().resetNonModularOptions();
+ getCodeGenOpts().resetNonModularOptions(getHeaderSearchOpts().ModuleFormat);
}
void CompilerInvocation::clearImplicitModuleBuildOptions() {