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

Devang Patel dpatel at apple.com
Fri Jul 23 16:04:28 PDT 2010


Author: dpatel
Date: Fri Jul 23 18:04:28 2010
New Revision: 109284

URL: http://llvm.org/viewvc/llvm-project?rev=109284&view=rev
Log:
Revert r109263.

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=109284&r1=109283&r2=109284&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jul 23 18:04:28 2010
@@ -188,25 +188,18 @@
   if (MainFileName.empty())
     MainFileName = "<unknown>";
 
+  llvm::sys::Path AbsFileName(MainFileName);
+  AbsFileName.makeAbsolute();
+
   // The main file name provided via the "-main-file-name" option contains just
   // the file name itself with no path information. This file name may have had
   // a relative path, so we look into the actual file entry for the main
   // file to determine the real absolute path for the file.
-  char *FileNamePtr = NULL;
-  if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-    std::string MainFileDir;
+  std::string MainFileDir;
+  if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID()))
     MainFileDir = MainFile->getDir()->getName();
-    llvm::sys::Path AbsFileDirName(MainFileDir);
-    AbsFileDirName.makeAbsolute();
-    AbsFileDirName.appendComponent(MainFileName);
-    FileNamePtr = DebugInfoNames.Allocate<char>(AbsFileDirName.size());
-    memcpy(FileNamePtr, AbsFileDirName.c_str(), AbsFileDirName.size());
-  } else {
-    llvm::sys::Path AbsFileDirName(MainFileName);
-    AbsFileDirName.makeAbsolute();
-    FileNamePtr = DebugInfoNames.Allocate<char>(AbsFileDirName.size());
-    memcpy(FileNamePtr, AbsFileDirName.c_str(), AbsFileDirName.size());
-  }
+  else
+    MainFileDir = AbsFileName.getDirname();
 
   unsigned LangTag;
   const LangOptions &LO = CGM.getLangOptions();
@@ -236,7 +229,7 @@
 
   // Create new compile unit.
   TheCU = DebugFactory.CreateCompileUnit(
-    LangTag, FileNamePtr, llvm::StringRef(), Producer, true,
+    LangTag, AbsFileName.getLast(), MainFileDir, Producer, true,
     LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers);
 }
 





More information about the cfe-commits mailing list