summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-18 23:46:43 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-18 23:46:43 +0000
commitc6b5a3df1e73552d86808f7dccc043386e30b235 (patch)
tree3bf6730f1eb2ba724042433712aeeafe05c50a4c /clang/lib/CodeGen/CGDebugInfo.cpp
parentfdc20711e865cdc5fa918eff6134d1c4d9f4ce73 (diff)
downloadbcm5719-llvm-c6b5a3df1e73552d86808f7dccc043386e30b235.tar.gz
bcm5719-llvm-c6b5a3df1e73552d86808f7dccc043386e30b235.zip
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>. llvm-svn: 98898
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 60aa4e784e6..323c4588428 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud