@@ -847,7 +847,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
847
847
848
848
llvm::DIModule *getOrCreateModule (const void *Key, llvm::DIScope *Parent,
849
849
StringRef Name, StringRef IncludePath,
850
- StringRef CompDir,
851
850
uint64_t Signature = ~1ULL ,
852
851
StringRef ASTFile = StringRef()) {
853
852
// Look in the cache first.
@@ -857,7 +856,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
857
856
858
857
std::string RemappedIncludePath = DebugPrefixMap.remapPath (IncludePath);
859
858
std::string RemappedASTFile = DebugPrefixMap.remapPath (ASTFile);
860
- std::string RemappedCompDir = DebugPrefixMap.remapPath (CompDir);
861
859
862
860
// For Clang modules / PCH, create a Skeleton CU pointing to the PCM/PCH.
863
861
if (!Opts.DisableClangModuleSkeletonCUs ) {
@@ -867,7 +865,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
867
865
llvm::DIBuilder DIB (M);
868
866
DIB.createCompileUnit (IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC
869
867
: llvm::dwarf::DW_LANG_C99,
870
- DIB.createFile (Name, RemappedCompDir ),
868
+ DIB.createFile (Name, RemappedIncludePath ),
871
869
TheCU->getProducer (), true , StringRef (), 0 ,
872
870
RemappedASTFile, llvm::DICompileUnit::FullDebug,
873
871
Signature);
@@ -894,8 +892,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
894
892
uint64_t Signature =
895
893
Desc.getSignature () ? Desc.getSignature ().truncatedValue () : ~1ULL ;
896
894
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 ();
899
901
900
902
// Handle Clang modules.
901
903
if (ClangModule) {
@@ -917,13 +919,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
917
919
ClangModule->Parent );
918
920
}
919
921
return getOrCreateModule (ClangModule, Parent, Desc.getModuleName (),
920
- IncludePath, CompDir, Signature,
921
- Desc.getASTFile ());
922
+ IncludePath, Signature, Desc.getASTFile ());
922
923
}
923
924
// Handle PCH.
924
925
return getOrCreateModule (Desc.getASTFile ().bytes_begin (), nullptr ,
925
- Desc.getModuleName (), IncludePath, CompDir ,
926
- Signature, Desc.getASTFile ());
926
+ Desc.getModuleName (), IncludePath, Signature ,
927
+ Desc.getASTFile ());
927
928
};
928
929
929
930
static std::optional<ASTSourceDescriptor>
@@ -946,7 +947,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
946
947
// the module on disk is Bar (.swiftmodule or .swiftinterface), and is used
947
948
// for loading and mangling.
948
949
StringRef Name = M->getRealName ().str ();
949
- return getOrCreateModule (M, TheCU, Name, Path, Opts. DebugCompilationDir );
950
+ return getOrCreateModule (M, TheCU, Name, Path);
950
951
}
951
952
952
953
TypeAliasDecl *getMetadataType (StringRef ArchetypeName) {
@@ -2545,8 +2546,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2545
2546
auto Identifier = IGM.getSILModule ().getASTContext ().getIdentifier (
2546
2547
Attribute->getManglingModuleName ());
2547
2548
void *Key = (void *)Identifier.get ();
2548
- Scope = getOrCreateModule (Key, TheCU,
2549
- Attribute->getManglingModuleName (), {} , {});
2549
+ Scope =
2550
+ getOrCreateModule (Key, TheCU, Attribute->getManglingModuleName (), {});
2550
2551
} else {
2551
2552
Context = ND->getParent ();
2552
2553
}
@@ -2793,8 +2794,7 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
2793
2794
// Create a module for the current compile unit.
2794
2795
auto *MDecl = IGM.getSwiftModule ();
2795
2796
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);
2798
2798
DBuilder.createImportedModule (MainFile, MainModule, MainFile, 0 );
2799
2799
2800
2800
// Macro definitions that were defined by the user with "-Xcc -D" on the
0 commit comments