diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-18 23:46:43 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-18 23:46:43 +0000 |
commit | ac91b4c7063615da6797031f5ac46a906e6b8166 (patch) | |
tree | b88da2fc12a6b9b07d50ad5799aa1d7926adfc1f /lib/CodeGen/CGDebugInfo.cpp | |
parent | 3c26684d0339a36915fd3b30e6df82fe618bb7a7 (diff) |
For debug information, get the main file name from the source manager
rather than from the -main-file-name flag, since the source manager
has proper path information. Fixes <rdar://problem/7769538>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98898 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 60aa4e784e..323c458842 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -104,9 +104,14 @@ llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) { void CGDebugInfo::CreateCompileUnit() { // Get absolute path name. - std::string MainFileName = CGM.getCodeGenOpts().MainFileName; - if (MainFileName.empty()) + SourceManager &SM = CGM.getContext().getSourceManager(); + std::string MainFileName; + if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) + MainFileName = MainFile->getName(); + else if (CGM.getCodeGenOpts().MainFileName.empty()) MainFileName = "<unknown>"; + else + MainFileName = CGM.getCodeGenOpts().MainFileName; llvm::sys::Path AbsFileName(MainFileName); AbsFileName.makeAbsolute(); |