summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-01 03:37:41 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-01 03:37:41 +0000
commit87106c59edbd97b08207cc145f78be7b99d1cabc (patch)
treeaf791ed933740a26a8d7726b66048821817e69df /llvm/lib
parenta695abde49af9657dc927df48178f732a2d692fe (diff)
downloadbcm5719-llvm-87106c59edbd97b08207cc145f78be7b99d1cabc.tar.gz
bcm5719-llvm-87106c59edbd97b08207cc145f78be7b99d1cabc.zip
Support/PathV2: Add extension implementation.
llvm-svn: 120550
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/PathV2.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp
index e360e9cd1fe..47e59dd1cf1 100644
--- a/llvm/lib/Support/PathV2.cpp
+++ b/llvm/lib/Support/PathV2.cpp
@@ -574,6 +574,22 @@ error_code stem(const StringRef &path, StringRef &result) {
return make_error_code(errc::success);
}
+error_code extension(const StringRef &path, StringRef &result) {
+ StringRef fname;
+ if (error_code ec = filename(path, fname)) return ec;
+ size_t pos = fname.find_last_of('.');
+ if (pos == StringRef::npos)
+ result = StringRef();
+ else
+ if ((fname.size() == 1 && fname == ".") ||
+ (fname.size() == 2 && fname == ".."))
+ result = StringRef();
+ else
+ result = StringRef(fname.begin() + pos, fname.size() - pos);
+
+ return make_error_code(errc::success);
+}
+
}
}
}
OpenPOWER on IntegriCloud