summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Path.cpp
diff options
context:
space:
mode:
authorDouglas Katzman <dougk@google.com>2015-09-02 21:02:10 +0000
committerDouglas Katzman <dougk@google.com>2015-09-02 21:02:10 +0000
commita26be4a946ded0d328473e3842f2df45e896488f (patch)
tree3c49861cd5090e0c521d244c843b15d92b66384e /llvm/lib/Support/Path.cpp
parent9550590711ed82b357837b5af976ab3b7611764c (diff)
downloadbcm5719-llvm-a26be4a946ded0d328473e3842f2df45e896488f.tar.gz
bcm5719-llvm-a26be4a946ded0d328473e3842f2df45e896488f.zip
Move twice-repeated clang path operation into a new function.
And make it more robust in the edge case of exactly "./" as input. llvm-svn: 246711
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r--llvm/lib/Support/Path.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 54daf24daba..aa96074554e 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -661,8 +661,16 @@ bool is_absolute(const Twine &path) {
return rootDir && rootName;
}
-bool is_relative(const Twine &path) {
- return !is_absolute(path);
+bool is_relative(const Twine &path) { return !is_absolute(path); }
+
+StringRef remove_leading_dotslash(StringRef Path) {
+ // Remove leading "./" (or ".//" or "././" etc.)
+ while (Path.size() > 2 && Path[0] == '.' && is_separator(Path[1])) {
+ Path = Path.substr(2);
+ while (Path.size() > 0 && is_separator(Path[0]))
+ Path = Path.substr(1);
+ }
+ return Path;
}
} // end namespace path
OpenPOWER on IntegriCloud