diff options
author | Sean Silva <chisophugis@gmail.com> | 2015-07-30 00:52:32 +0000 |
---|---|---|
committer | Sean Silva <chisophugis@gmail.com> | 2015-07-30 00:52:32 +0000 |
commit | 3e36e507ec21c6777d4a26880f49022ff0dd7836 (patch) | |
tree | 8fbe40ae989c19039c2d30a10999fd1b9c7183e3 /clang/lib/Basic/FileManager.cpp | |
parent | ba46a47e07bb1982736136665f6f527466fdbf4d (diff) | |
download | bcm5719-llvm-3e36e507ec21c6777d4a26880f49022ff0dd7836.tar.gz bcm5719-llvm-3e36e507ec21c6777d4a26880f49022ff0dd7836.zip |
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.
llvm-svn: 243600
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 3d160569bc8..209abad6567 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/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<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(SmallVectorImpl<char> &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<char>(CanonicalNameBuf.size()); memcpy(Mem, CanonicalNameBuf.data(), CanonicalNameBuf.size()); CanonicalName = StringRef(Mem, CanonicalNameBuf.size()); |