Skip to content

Commit f42dcb9

Browse files
committed
Revert "Debug Info: Assert that the main source file name is non-empty."
This reverts commit 3fd5afc. while investigating buildbot breakage. rdar://problem/28457719
1 parent b6d73ce commit f42dcb9

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
9595
ClangImporter &CI,
9696
IRGenModule &IGM,
9797
llvm::Module &M,
98-
StringRef MainSourceFileName)
98+
SourceFile *SF)
9999
: Opts(Opts),
100100
CI(CI),
101101
SM(IGM.Context.SourceMgr),
@@ -107,8 +107,18 @@ IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
107107
LastDebugLoc({}),
108108
LastScope(nullptr)
109109
{
110-
assert(Opts.DebugInfoKind > IRGenDebugInfoKind::None &&
111-
"no debug info should be generated");
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+
}
112122

113123
unsigned Lang = llvm::dwarf::DW_LANG_Swift;
114124
std::string Producer = version::getSwiftFullVersion(
@@ -121,14 +131,6 @@ IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
121131

122132
// No split DWARF on Darwin.
123133
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-
132134
// Note that File + Dir need not result in a valid path.
133135
// Clang is doing the same thing here.
134136
TheCU = DBuilder.createCompileUnit(

lib/IRGen/IRGenDebugInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class IRGenDebugInfo {
9797

9898
public:
9999
IRGenDebugInfo(const IRGenOptions &Opts, ClangImporter &CI, IRGenModule &IGM,
100-
llvm::Module &M, StringRef MainSourceFileName);
100+
llvm::Module &M, SourceFile *SF);
101101

102102
/// Finalize the llvm::DIBuilder owned by this object.
103103
void finalize();

lib/IRGen/IRGenModule.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,8 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
384384
else
385385
RegisterPreservingCC = DefaultCC;
386386

387-
if (IRGen.Opts.DebugInfoKind > IRGenDebugInfoKind::None) {
388-
StringRef MainFile(SF ? SF->getFilename()
389-
: StringRef(IRGen.Opts.MainInputFilename));
390-
DebugInfo = new IRGenDebugInfo(IRGen.Opts, *CI, *this, Module, MainFile);
391-
}
387+
if (IRGen.Opts.DebugInfoKind > IRGenDebugInfoKind::None)
388+
DebugInfo = new IRGenDebugInfo(IRGen.Opts, *CI, *this, Module, SF);
392389

393390
initClangTypeConverter();
394391
}

0 commit comments

Comments
 (0)