summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Path.inc
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2017-08-21 20:49:44 +0000
committerPirama Arumuga Nainar <pirama@google.com>2017-08-21 20:49:44 +0000
commit3d48bb5fc2eb6316fa16a3f48cdf2c8df3ed217d (patch)
treec61d91123cf28c19eacab253f1cc7dcd3ca08622 /llvm/lib/Support/Windows/Path.inc
parent08a38fe71e607505dd07c66e4fec6c3c4aff99f4 (diff)
downloadbcm5719-llvm-3d48bb5fc2eb6316fa16a3f48cdf2c8df3ed217d.tar.gz
bcm5719-llvm-3d48bb5fc2eb6316fa16a3f48cdf2c8df3ed217d.zip
[Support, Windows] Handle long paths with unix separators
Summary: The function widenPath() for Windows also normalizes long path names by iterating over the path's components and calling append(). The assumption during the iteration that separators are not returned by the iterator doesn't hold because the iterators do return a separator when the path has a drive name. Handle this case by ignoring separators during iteration. Reviewers: rnk Subscribers: danalbert, srhines Differential Revision: https://reviews.llvm.org/D36752 llvm-svn: 311382
Diffstat (limited to 'llvm/lib/Support/Windows/Path.inc')
-rw-r--r--llvm/lib/Support/Windows/Path.inc11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 8dac0e4482b..f82a6bc07bd 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -94,13 +94,16 @@ std::error_code widenPath(const Twine &Path8,
return EC;
FullPath.append(CurPath);
}
- // Traverse the requested path, canonicalizing . and .. as we go (because
- // the \\?\ prefix is documented to treat them as real components).
- // The iterators don't report separators and append() always attaches
- // preferred_separator so we don't need to call native() on the result.
+ // Traverse the requested path, canonicalizing . and .. (because the \\?\
+ // prefix is documented to treat them as real components). Ignore
+ // separators, which can be returned from the iterator if the path has a
+ // drive name. We don't need to call native() on the result since append()
+ // always attaches preferred_separator.
for (llvm::sys::path::const_iterator I = llvm::sys::path::begin(Path8Str),
E = llvm::sys::path::end(Path8Str);
I != E; ++I) {
+ if (I->size() == 1 && is_separator((*I)[0]))
+ continue;
if (I->size() == 1 && *I == ".")
continue;
if (I->size() == 2 && *I == "..")
OpenPOWER on IntegriCloud