diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 5211d97bc8d64..de91b0779b782 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -637,6 +637,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { if (Val != DIModuleCache.end()) return cast(Val->second); + std::string RemappedIncludePath = DebugPrefixMap.remapPath(IncludePath); + // For Clang modules / PCH, create a Skeleton CU pointing to the PCM/PCH. bool CreateSkeletonCU = !ASTFile.empty(); bool IsRootModule = !Parent; @@ -644,7 +646,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { llvm::DIBuilder DIB(M); DIB.createCompileUnit(IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC : llvm::dwarf::DW_LANG_C99, - DIB.createFile(Name, IncludePath), + DIB.createFile(Name, RemappedIncludePath), TheCU->getProducer(), true, StringRef(), 0, ASTFile, llvm::DICompileUnit::FullDebug, Signature); DIB.finalize(); @@ -652,7 +654,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { StringRef Sysroot = IGM.Context.SearchPathOpts.SDKPath; llvm::DIModule *M = - DBuilder.createModule(Parent, Name, ConfigMacros, IncludePath, Sysroot); + DBuilder.createModule(Parent, Name, ConfigMacros, RemappedIncludePath, + Sysroot); DIModuleCache.insert({Key, llvm::TrackingMDNodeRef(M)}); return M; } diff --git a/test/DebugInfo/debug_prefix_map.swift b/test/DebugInfo/debug_prefix_map.swift index 8a3ce3fffb3f8..67668ed673b47 100644 --- a/test/DebugInfo/debug_prefix_map.swift +++ b/test/DebugInfo/debug_prefix_map.swift @@ -1,7 +1,12 @@ -// RUN: %swiftc_driver -g -debug-prefix-map %/S=/var/empty %/s -emit-ir -o - | %FileCheck %s +// RUN: %empty-directory(%t) +// RUN: %target-swift-frontend -emit-module-path %t/Globals.swiftmodule %S/Globals.swift +// 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 + +import Globals func square(_ n: Int) -> Int { return n * n } // CHECK: !DIFile(filename: "/var/empty/debug_prefix_map.swift" +// CHECK: !DIModule(scope: null, name: "Globals", includePath: "/var/empty/Globals.swiftmodule"