diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index eeb1927177c50..6d0960687a95e 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2492,12 +2492,16 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod, ? (uint64_t)Mod.getSignature()[1] << 32 | Mod.getSignature()[0] : ~1ULL; llvm::DIBuilder DIB(CGM.getModule()); + SmallString<0> PCM; + if (!llvm::sys::path::is_absolute(PCM)) + PCM = Mod.getPath(); + llvm::sys::path::append(PCM, Mod.getASTFile()); + StringRef CompDir = getCurrentDirname(); DIB.createCompileUnit(TheCU->getSourceLanguage(), // TODO: Support "Source" from external AST providers? - DIB.createFile(Mod.getModuleName(), Mod.getPath()), - TheCU->getProducer(), true, StringRef(), 0, - Mod.getASTFile(), llvm::DICompileUnit::FullDebug, - Signature); + DIB.createFile(Mod.getModuleName(), CompDir), + TheCU->getProducer(), true, StringRef(), 0, PCM, + llvm::DICompileUnit::FullDebug, Signature); DIB.finalize(); } diff --git a/clang/test/Modules/debug-info-moduleimport.m b/clang/test/Modules/debug-info-moduleimport.m index f07c6fce784d5..837459b0786c3 100644 --- a/clang/test/Modules/debug-info-moduleimport.m +++ b/clang/test/Modules/debug-info-moduleimport.m @@ -28,5 +28,7 @@ // RUN: -fmodule-format=obj -dwarf-ext-refs \ // RUN: %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \ // RUN: | FileCheck %s --check-prefix=SKEL-CHECK -// SKEL-CHECK: distinct !DICompileUnit -// SKEL-CHECK: distinct !DICompileUnit{{.*}}dwoId +// SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[CUFILE:[0-9]+]] +// SKEL-CHECK: ![[CUFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR:.*]]" +// SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[DWOFILE:[0-9]+]]{{.*}}dwoId +// SKEL-CHECK: ![[DWOFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR]]" diff --git a/clang/test/PCH/debug-info-pch-path.c b/clang/test/PCH/debug-info-pch-path.c index dcf7ed41f50ef..32d1cbd44bdf4 100644 --- a/clang/test/PCH/debug-info-pch-path.c +++ b/clang/test/PCH/debug-info-pch-path.c @@ -23,7 +23,7 @@ // CHECK-REL-NODIR: ![[C]] = !DIFile({{.*}}directory: "[[DIR:.*]]" // CHECK-REL-NODIR: !DICompileUnit( // CHECK-REL-NODIR-SAME: file: ![[PCH:[0-9]+]] -// CHECK-REL-NODIR-SAME: splitDebugFilename: "prefix.pch" +// CHECK-REL-NODIR-SAME: splitDebugFilename: "{{.*}}PCH{{.*}}prefix.pch" // CHECK-REL-NODIR: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]] // --------------------------------------------------------------------- @@ -47,8 +47,8 @@ // CHECK-REL: ![[C]] = !DIFile({{.*}}directory: "[[DIR:.*]]" // CHECK-REL: !DICompileUnit( // CHECK-REL-SAME: file: ![[PCH:[0-9]+]] -// CHECK-REL-SAME: splitDebugFilename: "prefix.pch" -// CHECK-REL: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]{{.*}}pchdir" +// CHECK-REL-SAME: splitDebugFilename: "[[DIR]]{{.*}}pchdir{{.*}}prefix.pch" +// CHECK-REL: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]" // --------------------------------------------------------------------- // Absolute PCH. @@ -70,5 +70,5 @@ // CHECK-ABS: ![[C]] = !DIFile({{.*}}directory: "[[DIR:.*]]" // CHECK-ABS: !DICompileUnit( // CHECK-ABS-SAME: file: ![[PCH:[0-9]+]] -// CHECK-ABS-SAME: splitDebugFilename: "prefix.pch" +// CHECK-ABS-SAME: splitDebugFilename: "[[DIR]]{{.*}}prefix.pch" // CHECK-ABS: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]