[llvm-commits] [llvm-gcc-4.2] r109329 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h

Bob Wilson bob.wilson at apple.com
Fri Jul 23 22:41:06 PDT 2010


Author: bwilson
Date: Sat Jul 24 00:41:06 2010
New Revision: 109329

URL: http://llvm.org/viewvc/llvm-project?rev=109329&view=rev
Log:
Revert Devang's patch for file and directory names in debug info
due to buildbot failures.

--- Reverse-merging r109316 into '.':
U    gcc/llvm-debug.cpp
U    gcc/llvm-debug.h

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=109329&r1=109328&r2=109329&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Sat Jul 24 00:41:06 2010
@@ -57,16 +57,28 @@
 #endif
 
 
-/// DirectoryAndFile - If Filename is absolute then directory name is empty.
-/// Otherwise directory name is current working directory.
+/// DirectoryAndFile - Extract the directory and file name from a path.  If no
+/// directory is specified, then use the source working directory.
 static void DirectoryAndFile(const std::string &FullPath,
                              std::string &Directory, std::string &FileName) {
-  FileName = FullPath;
-
-  if (FullPath[0] != '/')
-    Directory = std::string(get_src_pwd());
-  else
+  // Look for the directory slash.
+  size_t Slash = FullPath.rfind('/');
+  
+  // If no slash
+  if (Slash == std::string::npos) {
+    // The entire path is the file name.
     Directory = "";
+    FileName = FullPath;
+  } else {
+    // Separate the directory from the file name.
+    Directory = FullPath.substr(0, Slash);
+    FileName = FullPath.substr(Slash + 1);
+  }
+  
+  // If no directory present then use source working directory.
+  if (Directory.empty() || Directory[0] != '/') {
+    Directory = std::string(get_src_pwd()) + "/" + Directory;
+  }
 }
 
 /// NodeSizeInBits - Returns the size in bits stored in a tree node regardless
@@ -1382,13 +1394,10 @@
   }
 
   // Get source file information.
-  llvm::StringRef Dir;
-  if (FullPath[0] != '/') {
-    if (CWD.empty())
-      CWD = std::string(get_src_pwd());
-    Dir = llvm::StringRef(CWD);
-  }
-
+  std::string Directory;
+  std::string FileName;
+  DirectoryAndFile(FullPath, Directory, FileName);
+  
   // Set up Language number.
   unsigned LangTag;
   const std::string LanguageName(lang_hooks.name);
@@ -1423,8 +1432,8 @@
   unsigned ObjcRunTimeVer = 0;
   if (flag_objc_abi != 0 && flag_objc_abi != -1)
     ObjcRunTimeVer = flag_objc_abi;
-  return DebugFactory.CreateCompileUnit(LangTag, FullPath,
-                                        Dir,
+  return DebugFactory.CreateCompileUnit(LangTag, FileName.c_str(),
+                                        Directory.c_str(),
                                         version_string, isMain,
                                         optimize, Flags,
                                         ObjcRunTimeVer);
@@ -1440,13 +1449,10 @@
   }
 
   // Get source file information.
-  llvm::StringRef Dir;
-  if (FullPath[0] != '/') {
-    if (CWD.empty())
-      CWD = std::string(get_src_pwd());
-    Dir = llvm::StringRef(CWD);
-  }
-  return DebugFactory.CreateFile(FullPath, Dir, TheCU);
+  std::string Directory;
+  std::string FileName;
+  DirectoryAndFile(FullPath, Directory, FileName);
+  return DebugFactory.CreateFile(FileName, Directory, TheCU);
 }
 
 /* LLVM LOCAL end (ENTIRE FILE!)  */

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=109329&r1=109328&r2=109329&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Sat Jul 24 00:41:06 2010
@@ -63,7 +63,6 @@
   int PrevLineNo;                       // Previous location line# encountered.
   BasicBlock *PrevBB;                   // Last basic block encountered.
   DICompileUnit TheCU;                  // The compile unit.
-  std::string CWD;                      // Current working directory.
 
   // Current GCC lexical block (or enclosing FUNCTION_DECL).
   tree_node *CurrentGCCLexicalBlock;	





More information about the llvm-commits mailing list