From: Sean Silva Date: Thu, 30 Jul 2015 00:52:32 +0000 (+0000) Subject: Attempt to make clang-x64-ninja-win7 happy. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e40e2c50f6dbb504be1603d9b42bac960f745a0;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243600 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index ac0d7a15e5..a08d3c894f 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -267,7 +267,7 @@ public: time_t ModificationTime); /// \brief Remove any './' components from a path. - static bool removeDotPaths(SmallVectorImpl &Path); + static bool removeDotPaths(SmallVectorImpl &Path, bool RemoveDotDot = false); /// \brief Retrieve the canonical name for a given directory. /// diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 3d160569bc..209abad656 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -517,7 +517,7 @@ void FileManager::modifyFileEntry(FileEntry *File, /// 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 &Path) { +bool FileManager::removeDotPaths(SmallVectorImpl &Path, bool RemoveDotDot) { using namespace llvm::sys; SmallVector ComponentStack; @@ -528,10 +528,12 @@ bool FileManager::removeDotPaths(SmallVectorImpl &Path) { 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(const DirectoryEntry *Dir) { SmallString<256> CanonicalNameBuf(CanonicalName); llvm::sys::fs::make_absolute(CanonicalNameBuf); llvm::sys::path::native(CanonicalNameBuf); - removeDotPaths(CanonicalNameBuf); + removeDotPaths(CanonicalNameBuf, true); char *Mem = CanonicalNameStorage.Allocate(CanonicalNameBuf.size()); memcpy(Mem, CanonicalNameBuf.data(), CanonicalNameBuf.size()); CanonicalName = StringRef(Mem, CanonicalNameBuf.size());