[cfe-commits] r98898 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Douglas Gregor dgregor at apple.com
Thu Mar 18 16:46:43 PDT 2010


Author: dgregor
Date: Thu Mar 18 18:46:43 2010
New Revision: 98898

URL: http://llvm.org/viewvc/llvm-project?rev=98898&view=rev
Log:
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>.

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=98898&r1=98897&r2=98898&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Mar 18 18:46:43 2010
@@ -104,9 +104,14 @@
 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();
 





More information about the cfe-commits mailing list