Skip to content

Commit dcfc536

Browse files
Merge pull request #83304 from rastogishubham/RevertCompDir
Revert "Set the Compilation directory when generating the Skeleton CU"
2 parents ee0da2d + 5b4fdd6 commit dcfc536

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
847847

848848
llvm::DIModule *getOrCreateModule(const void *Key, llvm::DIScope *Parent,
849849
StringRef Name, StringRef IncludePath,
850-
StringRef CompDir,
851850
uint64_t Signature = ~1ULL,
852851
StringRef ASTFile = StringRef()) {
853852
// Look in the cache first.
@@ -857,7 +856,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
857856

858857
std::string RemappedIncludePath = DebugPrefixMap.remapPath(IncludePath);
859858
std::string RemappedASTFile = DebugPrefixMap.remapPath(ASTFile);
860-
std::string RemappedCompDir = DebugPrefixMap.remapPath(CompDir);
861859

862860
// For Clang modules / PCH, create a Skeleton CU pointing to the PCM/PCH.
863861
if (!Opts.DisableClangModuleSkeletonCUs) {
@@ -867,7 +865,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
867865
llvm::DIBuilder DIB(M);
868866
DIB.createCompileUnit(IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC
869867
: llvm::dwarf::DW_LANG_C99,
870-
DIB.createFile(Name, RemappedCompDir),
868+
DIB.createFile(Name, RemappedIncludePath),
871869
TheCU->getProducer(), true, StringRef(), 0,
872870
RemappedASTFile, llvm::DICompileUnit::FullDebug,
873871
Signature);
@@ -894,8 +892,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
894892
uint64_t Signature =
895893
Desc.getSignature() ? Desc.getSignature().truncatedValue() : ~1ULL;
896894

897-
StringRef CompDir = Opts.DebugCompilationDir;
898-
StringRef IncludePath = Desc.getPath();
895+
// Clang modules using fmodule-file-home-is-cwd should have their
896+
// include path set to the working directory.
897+
auto &HSI =
898+
CI.getClangPreprocessor().getHeaderSearchInfo().getHeaderSearchOpts();
899+
StringRef IncludePath =
900+
HSI.ModuleFileHomeIsCwd ? Opts.DebugCompilationDir : Desc.getPath();
899901

900902
// Handle Clang modules.
901903
if (ClangModule) {
@@ -917,13 +919,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
917919
ClangModule->Parent);
918920
}
919921
return getOrCreateModule(ClangModule, Parent, Desc.getModuleName(),
920-
IncludePath, CompDir, Signature,
921-
Desc.getASTFile());
922+
IncludePath, Signature, Desc.getASTFile());
922923
}
923924
// Handle PCH.
924925
return getOrCreateModule(Desc.getASTFile().bytes_begin(), nullptr,
925-
Desc.getModuleName(), IncludePath, CompDir,
926-
Signature, Desc.getASTFile());
926+
Desc.getModuleName(), IncludePath, Signature,
927+
Desc.getASTFile());
927928
};
928929

929930
static std::optional<ASTSourceDescriptor>
@@ -946,7 +947,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
946947
// the module on disk is Bar (.swiftmodule or .swiftinterface), and is used
947948
// for loading and mangling.
948949
StringRef Name = M->getRealName().str();
949-
return getOrCreateModule(M, TheCU, Name, Path, Opts.DebugCompilationDir);
950+
return getOrCreateModule(M, TheCU, Name, Path);
950951
}
951952

952953
TypeAliasDecl *getMetadataType(StringRef ArchetypeName) {
@@ -2545,8 +2546,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
25452546
auto Identifier = IGM.getSILModule().getASTContext().getIdentifier(
25462547
Attribute->getManglingModuleName());
25472548
void *Key = (void *)Identifier.get();
2548-
Scope = getOrCreateModule(Key, TheCU,
2549-
Attribute->getManglingModuleName(), {}, {});
2549+
Scope =
2550+
getOrCreateModule(Key, TheCU, Attribute->getManglingModuleName(), {});
25502551
} else {
25512552
Context = ND->getParent();
25522553
}
@@ -2793,8 +2794,7 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
27932794
// Create a module for the current compile unit.
27942795
auto *MDecl = IGM.getSwiftModule();
27952796
llvm::sys::path::remove_filename(SourcePath);
2796-
MainModule = getOrCreateModule(MDecl, TheCU, Opts.ModuleName, SourcePath,
2797-
Opts.DebugCompilationDir);
2797+
MainModule = getOrCreateModule(MDecl, TheCU, Opts.ModuleName, SourcePath);
27982798
DBuilder.createImportedModule(MainFile, MainModule, MainFile, 0);
27992799

28002800
// Macro definitions that were defined by the user with "-Xcc -D" on the

test/DebugInfo/comp-dir.swift

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)