Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,22 +637,25 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
if (Val != DIModuleCache.end())
return cast<llvm::DIModule>(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;
if (CreateSkeletonCU && IsRootModule) {
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();
}

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;
}
Expand Down
7 changes: 6 additions & 1 deletion test/DebugInfo/debug_prefix_map.swift
Original file line number Diff line number Diff line change
@@ -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"