Skip to content

Revert PR#4963 #4986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2016
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
24 changes: 13 additions & 11 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
ClangImporter &CI,
IRGenModule &IGM,
llvm::Module &M,
StringRef MainSourceFileName)
SourceFile *SF)
: Opts(Opts),
CI(CI),
SM(IGM.Context.SourceMgr),
Expand All @@ -107,8 +107,18 @@ IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
LastDebugLoc({}),
LastScope(nullptr)
{
assert(Opts.DebugInfoKind > IRGenDebugInfoKind::None &&
"no debug info should be generated");
assert(Opts.DebugInfoKind > IRGenDebugInfoKind::None
&& "no debug info should be generated");
StringRef SourceFileName = SF ? SF->getFilename() :
StringRef(Opts.MainInputFilename);
StringRef Dir;
llvm::SmallString<256> AbsMainFile;
if (SourceFileName.empty())
AbsMainFile = "<unknown>";
else {
AbsMainFile = SourceFileName;
llvm::sys::fs::make_absolute(AbsMainFile);
}

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

// No split DWARF on Darwin.
StringRef SplitName = StringRef();

// The Darwin linker ld64 depends on DW_AT_comp_dir to determine
// whether an object file has debug info.
assert(!MainSourceFileName.empty() && "main source file name is empty");
llvm::SmallString<256> AbsMainFile;
AbsMainFile = MainSourceFileName;
llvm::sys::fs::make_absolute(AbsMainFile);

// Note that File + Dir need not result in a valid path.
// Clang is doing the same thing here.
TheCU = DBuilder.createCompileUnit(
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/IRGenDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class IRGenDebugInfo {

public:
IRGenDebugInfo(const IRGenOptions &Opts, ClangImporter &CI, IRGenModule &IGM,
llvm::Module &M, StringRef MainSourceFileName);
llvm::Module &M, SourceFile *SF);

/// Finalize the llvm::DIBuilder owned by this object.
void finalize();
Expand Down
7 changes: 2 additions & 5 deletions lib/IRGen/IRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,8 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
else
RegisterPreservingCC = DefaultCC;

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

initClangTypeConverter();
}
Expand Down