[cfe-commits] r98959 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Douglas Gregor
dgregor at apple.com
Fri Mar 19 07:49:10 PDT 2010
Author: dgregor
Date: Fri Mar 19 09:49:09 2010
New Revision: 98959
URL: http://llvm.org/viewvc/llvm-project?rev=98959&view=rev
Log:
Try to improve computation of the main file name for debug
information, to address recent gdb failures.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=98959&r1=98958&r2=98959&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Mar 19 09:49:09 2010
@@ -105,16 +105,19 @@
// Get absolute path name.
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())
+ std::string MainFileName = CGM.getCodeGenOpts().MainFileName;
+ if (MainFileName.empty())
MainFileName = "<unknown>";
- else
- MainFileName = CGM.getCodeGenOpts().MainFileName;
+
llvm::sys::Path AbsFileName(MainFileName);
AbsFileName.makeAbsolute();
+ std::string MainFileDir;
+ if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID()))
+ MainFileDir = MainFile->getDir()->getName();
+ else
+ MainFileDir = AbsFileName.getDirname();
+
unsigned LangTag;
const LangOptions &LO = CGM.getLangOptions();
if (LO.CPlusPlus) {
@@ -143,7 +146,7 @@
// Create new compile unit.
TheCU = DebugFactory.CreateCompileUnit(
- LangTag, AbsFileName.getLast(), AbsFileName.getDirname(), Producer, true,
+ LangTag, AbsFileName.getLast(), MainFileDir, Producer, true,
LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers);
}
More information about the cfe-commits
mailing list