r243600 - Attempt to make clang-x64-ninja-win7 happy.

Sean Silva chisophugis at gmail.com
Wed Jul 29 17:52:32 PDT 2015


Author: silvas
Date: Wed Jul 29 19:52:32 2015
New Revision: 243600

URL: http://llvm.org/viewvc/llvm-project?rev=243600&view=rev
Log:
Attempt to make clang-x64-ninja-win7 happy.

It looks like we were somehow relying somewhere on removing 'foo/./bar'
but *not* 'foo/../foo/bar'. Currently investigating.

Modified:
    cfe/trunk/include/clang/Basic/FileManager.h
    cfe/trunk/lib/Basic/FileManager.cpp

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=243600&r1=243599&r2=243600&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Wed Jul 29 19:52:32 2015
@@ -267,7 +267,7 @@ public:
                               time_t ModificationTime);
 
   /// \brief Remove any './' components from a path.
-  static bool removeDotPaths(SmallVectorImpl<char> &Path);
+  static bool removeDotPaths(SmallVectorImpl<char> &Path, bool RemoveDotDot = false);
 
   /// \brief Retrieve the canonical name for a given directory.
   ///

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=243600&r1=243599&r2=243600&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Wed Jul 29 19:52:32 2015
@@ -517,7 +517,7 @@ void FileManager::modifyFileEntry(FileEn
 /// Remove '.' and '..' path components from the given absolute path.
 /// \return \c true if any changes were made.
 // FIXME: Move this to llvm::sys::path.
-bool FileManager::removeDotPaths(SmallVectorImpl<char> &Path) {
+bool FileManager::removeDotPaths(SmallVectorImpl<char> &Path, bool RemoveDotDot) {
   using namespace llvm::sys;
 
   SmallVector<StringRef, 16> ComponentStack;
@@ -528,10 +528,12 @@ bool FileManager::removeDotPaths(SmallVe
   for (StringRef C : llvm::make_range(path::begin(Rel), path::end(Rel))) {
     if (C == ".")
       continue;
-    if (C == "..") {
-      if (!ComponentStack.empty())
-        ComponentStack.pop_back();
-      continue;
+    if (RemoveDotDot) {
+      if (C == "..") {
+        if (!ComponentStack.empty())
+          ComponentStack.pop_back();
+        continue;
+      }
     }
     ComponentStack.push_back(C);
   }
@@ -566,7 +568,7 @@ StringRef FileManager::getCanonicalName(
   SmallString<256> CanonicalNameBuf(CanonicalName);
   llvm::sys::fs::make_absolute(CanonicalNameBuf);
   llvm::sys::path::native(CanonicalNameBuf);
-  removeDotPaths(CanonicalNameBuf);
+  removeDotPaths(CanonicalNameBuf, true);
   char *Mem = CanonicalNameStorage.Allocate<char>(CanonicalNameBuf.size());
   memcpy(Mem, CanonicalNameBuf.data(), CanonicalNameBuf.size());
   CanonicalName = StringRef(Mem, CanonicalNameBuf.size());





More information about the cfe-commits mailing list