[cfe-commits] r124776 - /cfe/trunk/lib/Basic/FileManager.cpp

Rafael Espindola rafael.espindola at gmail.com
Wed Feb 2 20:35:45 PST 2011


Author: rafael
Date: Wed Feb  2 22:35:45 2011
New Revision: 124776

URL: http://llvm.org/viewvc/llvm-project?rev=124776&view=rev
Log:
Revert 124754 and 124760 as they made clang unusable in the presence of symbolic
links.

Modified:
    cfe/trunk/lib/Basic/FileManager.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=124776&r1=124775&r2=124776&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Wed Feb  2 22:35:45 2011
@@ -271,91 +271,10 @@
   return &UDE;
 }
 
-/// \brief Canonicalize a file or path name by eliminating redundant
-/// "foo/.." and "./" path components.
-///
-/// Uses the given scratch space to store the resulting string, if needed.
-static llvm::StringRef CanonicalizeFileName(llvm::StringRef Filename, 
-                                            llvm::SmallVectorImpl<char> &Scratch) {
-  size_t Start = 0;
-  bool Changed = false;
-  size_t FirstSlash = Filename.find('/', Start);
-  do {
-    if (FirstSlash == llvm::StringRef::npos) {
-      // No more components. Just copy the rest of the file name, if
-      // we need to.
-      if (Changed)
-        Scratch.append(Filename.begin() + Start, Filename.end());
-      break;
-    }
-
-    if (Start + 1 == FirstSlash && Filename[Start] == '.') {
-      // We have './'; remove it.
-      
-      // If we haven't changed anything previously, copy the
-      // starting bits here.
-      if (!Changed) {
-        Scratch.clear();
-        Scratch.append(Filename.begin(), Filename.begin() + Start);
-        Changed = true;
-      }
-      
-      // Skip over the './'.
-      Start = FirstSlash + 1;
-      FirstSlash = Filename.find('/', Start);
-      continue;
-    }
-    
-    size_t SecondSlash = Filename.find('/', FirstSlash + 1);
-    if (SecondSlash != llvm::StringRef::npos &&
-        SecondSlash - FirstSlash == 3 &&
-        Filename[FirstSlash + 1] == '.' &&
-        Filename[FirstSlash + 2] == '.') {
-      // We have 'foo/../'; remove it.
-      
-      // If we haven't changed anything previously, copy the
-      // starting bits here.
-      if (!Changed) {
-        Scratch.clear();
-        Scratch.append(Filename.begin(), Filename.begin() + Start);
-        Changed = true;
-      }
-      
-      // Skip over the 'foo/..'.
-      Start = SecondSlash + 1;
-      FirstSlash = Filename.find('/', Start);
-      continue;
-    }
-
-    if (Changed)
-      Scratch.append(Filename.begin() + Start, 
-                     Filename.begin() + FirstSlash + 1);
-    Start = FirstSlash + 1;
-
-    if (SecondSlash == llvm::StringRef::npos)
-      FirstSlash = Filename.find('/', Start);
-    else
-      FirstSlash = SecondSlash;
-  } while (true);
-
-  if (Changed) {
-#if 0
-    llvm::errs() << "Canonicalized \"" << Filename << "\" to \""
-                 << llvm::StringRef(Scratch.data(), Scratch.size()) << "\"\n";
-#endif
-    return llvm::StringRef(Scratch.data(), Scratch.size());
-  }
-
-  return Filename;
-}
-
 /// getFile - Lookup, cache, and verify the specified file.  This returns null
 /// if the file doesn't exist.
 ///
 const FileEntry *FileManager::getFile(llvm::StringRef Filename) {
-  llvm::SmallString<128> FilenameScratch;
-  Filename = CanonicalizeFileName(Filename, FilenameScratch);
-
   ++NumFileLookups;
 
   // See if there is already an entry in the map.
@@ -424,9 +343,6 @@
 const FileEntry *
 FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size,
                             time_t ModificationTime) {
-  llvm::SmallString<128> FilenameScratch;
-  Filename = CanonicalizeFileName(Filename, FilenameScratch);
-
   ++NumFileLookups;
 
   // See if there is already an entry in the map.





More information about the cfe-commits mailing list