summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/PathV2.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-01 03:18:33 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-01 03:18:33 +0000
commit956955ed8b5954b31c39cff09c342abad8a28596 (patch)
treecdb7f7af4a915d9dbb7340a286870c04bfc1ffea /llvm/lib/Support/PathV2.cpp
parent142692006bb824796ea3ddf1907db81af7956fd8 (diff)
downloadbcm5719-llvm-956955ed8b5954b31c39cff09c342abad8a28596.tar.gz
bcm5719-llvm-956955ed8b5954b31c39cff09c342abad8a28596.zip
Support/PathV2: Add stem implementation.
llvm-svn: 120547
Diffstat (limited to 'llvm/lib/Support/PathV2.cpp')
-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 9c343ea0060..e360e9cd1fe 100644
--- a/llvm/lib/Support/PathV2.cpp
+++ b/llvm/lib/Support/PathV2.cpp
@@ -558,6 +558,22 @@ error_code filename(const StringRef &path, StringRef &result) {
return make_error_code(errc::success);
}
+error_code stem(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 = fname;
+ else
+ if ((fname.size() == 1 && fname == ".") ||
+ (fname.size() == 2 && fname == ".."))
+ result = fname;
+ else
+ result = StringRef(fname.begin(), pos);
+
+ return make_error_code(errc::success);
+}
+
}
}
}
OpenPOWER on IntegriCloud