summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Path.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r--llvm/lib/Support/Path.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 4374cba4988..b2d645779b0 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -707,11 +707,14 @@ 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;
- // Leading ".." will remain in the path.
- if (remove_dot_dot && C == ".." && !components.empty() &&
- components.back() != "..") {
- components.pop_back();
- continue;
+ // Leading ".." will remain in the path unless it's at the root.
+ if (remove_dot_dot && C == "..") {
+ if (!components.empty() && components.back() != "..") {
+ components.pop_back();
+ continue;
+ }
+ if (path::is_absolute(path))
+ continue;
}
components.push_back(C);
}
OpenPOWER on IntegriCloud