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 | c6b5a3df1e73552d86808f7dccc043386e30b235 (patch) | |
tree | 3bf6730f1eb2ba724042433712aeeafe05c50a4c /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | fdc20711e865cdc5fa918eff6134d1c4d9f4ce73 (diff) | |
download | bcm5719-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.cpp | 9 |
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(); |