From: Adrian Prantl Date: Thu, 29 Nov 2018 22:33:09 +0000 (+0000) Subject: [-gmodules] Honor -fdebug-prefix-map in the debug info inside PCMs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6554d78420bbe4c6b100a796a9426489d75f9319;p=clang [-gmodules] Honor -fdebug-prefix-map in the debug info inside PCMs. This patch passes -fdebug-prefix-map (a feature for renaming source paths in the debug info) through to the per-module codegen options and adds the debug prefix map to the module hash. Differential Revision: https://reviews.llvm.org/D55037 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347926 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index c164cec5d9..5d97807316 100644 --- a/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -156,6 +156,8 @@ public: LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule; CodeGenOpts.setDebugInfo(codegenoptions::FullDebugInfo); CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning()); + CodeGenOpts.DebugPrefixMap = + CI.getInvocation().getCodeGenOpts().DebugPrefixMap; } ~PCHContainerGenerator() override = default; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 8840e2ed00..f511fdcd87 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -3264,6 +3264,12 @@ std::string CompilerInvocation::getModuleHash() const { code = ext->hashExtension(code); } + // When compiling with -gmodules, also hash -fdebug-prefix-map as it + // affects the debug info in the PCM. + if (getCodeGenOpts().DebugTypeExtRefs) + for (const auto &KeyValue : getCodeGenOpts().DebugPrefixMap) + code = hash_combine(code, KeyValue.first, KeyValue.second); + // Extend the signature with the enabled sanitizers, if at least one is // enabled. Sanitizers which cannot affect AST generation aren't hashed. SanitizerSet SanHash = LangOpts->Sanitize; diff --git a/test/Modules/module-debuginfo-prefix.m b/test/Modules/module-debuginfo-prefix.m new file mode 100644 index 0000000000..c4a7d2b614 --- /dev/null +++ b/test/Modules/module-debuginfo-prefix.m @@ -0,0 +1,23 @@ +// REQUIRES: asserts + +// Modules: +// RUN: rm -rf %t +// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \ +// RUN: -fdebug-prefix-map=%S/Inputs=/OVERRIDE \ +// RUN: -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \ +// RUN: -I %S/Inputs -I %t -emit-llvm -o %t.ll \ +// RUN: -mllvm -debug-only=pchcontainer &>%t-mod.ll +// RUN: cat %t-mod.ll | FileCheck %s + +// PCH: +// RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \ +// RUN: -fdebug-prefix-map=%S/Inputs=/OVERRIDE \ +// RUN: -o %t.pch %S/Inputs/DebugObjC.h \ +// RUN: -mllvm -debug-only=pchcontainer &>%t-pch.ll +// RUN: cat %t-pch.ll | FileCheck %s + +#ifdef MODULES +@import DebugObjC; +#endif + +// CHECK: !DIFile({{.*}}"/OVERRIDE/DebugObjC.h"