Skip to content

Commit a533081

Browse files
authored
Merge pull request #23628 from DavidGoldman/master
2 parents 3c74c0f + 3b2c5a9 commit a533081

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,22 +637,25 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
637637
if (Val != DIModuleCache.end())
638638
return cast<llvm::DIModule>(Val->second);
639639

640+
std::string RemappedIncludePath = DebugPrefixMap.remapPath(IncludePath);
641+
640642
// For Clang modules / PCH, create a Skeleton CU pointing to the PCM/PCH.
641643
bool CreateSkeletonCU = !ASTFile.empty();
642644
bool IsRootModule = !Parent;
643645
if (CreateSkeletonCU && IsRootModule) {
644646
llvm::DIBuilder DIB(M);
645647
DIB.createCompileUnit(IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC
646648
: llvm::dwarf::DW_LANG_C99,
647-
DIB.createFile(Name, IncludePath),
649+
DIB.createFile(Name, RemappedIncludePath),
648650
TheCU->getProducer(), true, StringRef(), 0, ASTFile,
649651
llvm::DICompileUnit::FullDebug, Signature);
650652
DIB.finalize();
651653
}
652654

653655
StringRef Sysroot = IGM.Context.SearchPathOpts.SDKPath;
654656
llvm::DIModule *M =
655-
DBuilder.createModule(Parent, Name, ConfigMacros, IncludePath, Sysroot);
657+
DBuilder.createModule(Parent, Name, ConfigMacros, RemappedIncludePath,
658+
Sysroot);
656659
DIModuleCache.insert({Key, llvm::TrackingMDNodeRef(M)});
657660
return M;
658661
}

test/DebugInfo/debug_prefix_map.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
// RUN: %swiftc_driver -g -debug-prefix-map %/S=/var/empty %/s -emit-ir -o - | %FileCheck %s
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module-path %t/Globals.swiftmodule %S/Globals.swift
3+
// RUN: %target-swiftc_driver -g -debug-prefix-map %/S=/var/empty -debug-prefix-map %t=/var/empty %/s -I %t -emit-ir -o - | %FileCheck %s
4+
5+
import Globals
26

37
func square(_ n: Int) -> Int {
48
return n * n
59
}
610

711
// CHECK: !DIFile(filename: "/var/empty/debug_prefix_map.swift"
12+
// CHECK: !DIModule(scope: null, name: "Globals", includePath: "/var/empty/Globals.swiftmodule"

0 commit comments

Comments
 (0)