@@ -95,7 +95,7 @@ IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
95
95
ClangImporter &CI,
96
96
IRGenModule &IGM,
97
97
llvm::Module &M,
98
- SourceFile *SF )
98
+ StringRef MainSourceFileName )
99
99
: Opts(Opts),
100
100
CI(CI),
101
101
SM(IGM.Context.SourceMgr),
@@ -107,18 +107,8 @@ IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
107
107
LastDebugLoc({}),
108
108
LastScope(nullptr )
109
109
{
110
- assert (Opts.DebugInfoKind > IRGenDebugInfoKind::None
111
- && " no debug info should be generated" );
112
- StringRef SourceFileName = SF ? SF->getFilename () :
113
- StringRef (Opts.MainInputFilename );
114
- StringRef Dir;
115
- llvm::SmallString<256 > AbsMainFile;
116
- if (SourceFileName.empty ())
117
- AbsMainFile = " <unknown>" ;
118
- else {
119
- AbsMainFile = SourceFileName;
120
- llvm::sys::fs::make_absolute (AbsMainFile);
121
- }
110
+ assert (Opts.DebugInfoKind > IRGenDebugInfoKind::None &&
111
+ " no debug info should be generated" );
122
112
123
113
unsigned Lang = llvm::dwarf::DW_LANG_Swift;
124
114
std::string Producer = version::getSwiftFullVersion (
@@ -131,6 +121,14 @@ IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
131
121
132
122
// No split DWARF on Darwin.
133
123
StringRef SplitName = StringRef ();
124
+
125
+ // The Darwin linker ld64 depends on DW_AT_comp_dir to determine
126
+ // whether an object file has debug info.
127
+ assert (!MainSourceFileName.empty () && " main source file name is empty" );
128
+ llvm::SmallString<256 > AbsMainFile;
129
+ AbsMainFile = MainSourceFileName;
130
+ llvm::sys::fs::make_absolute (AbsMainFile);
131
+
134
132
// Note that File + Dir need not result in a valid path.
135
133
// Clang is doing the same thing here.
136
134
TheCU = DBuilder.createCompileUnit (
0 commit comments