diff options
author | Eric Liu <ioeric@google.com> | 2016-10-13 15:07:14 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2016-10-13 15:07:14 +0000 |
commit | af5a28fe879e01b694c5faea6878461289938ab4 (patch) | |
tree | 6d30fa76e95ba88411a1034a33018cfbfb2c6f82 /llvm/lib/Support/Path.cpp | |
parent | 6d3ea6831d6fe30683d6b5078ad826fdedc2e946 (diff) | |
download | bcm5719-llvm-af5a28fe879e01b694c5faea6878461289938ab4.tar.gz bcm5719-llvm-af5a28fe879e01b694c5faea6878461289938ab4.zip |
Do not delete leading ../ in remove_dots.
Reviewers: bkramer
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D25561
llvm-svn: 284129
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index f6355d1df80..4374cba4988 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -707,12 +707,11 @@ static SmallString<256> remove_dots(StringRef path, bool remove_dot_dot) { for (StringRef C : llvm::make_range(path::begin(rel), path::end(rel))) { if (C == ".") continue; - if (remove_dot_dot) { - if (C == "..") { - if (!components.empty()) - components.pop_back(); - continue; - } + // Leading ".." will remain in the path. + if (remove_dot_dot && C == ".." && !components.empty() && + components.back() != "..") { + components.pop_back(); + continue; } components.push_back(C); } |