Do not delete leading ../ in remove_dots.
Reviewers: bkramer
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D25561
llvm-svn: 284129
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index f6355d1..4374cba 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -707,12 +707,11 @@
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);
}