mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-07 16:54:48 +00:00
Support/PathV2: Add has_{root_path,root_name,root_directory,parent_path,filename,stem,extension} implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1d3896232a
commit
ae18008584
@ -370,24 +370,6 @@ error_code root_directory(const StringRef &path, StringRef &result) {
|
|||||||
return make_error_code(errc::success);
|
return make_error_code(errc::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code has_root_name(const Twine &path, bool &result) {
|
|
||||||
SmallString<128> storage;
|
|
||||||
StringRef p = path.toStringRef(storage);
|
|
||||||
|
|
||||||
if (error_code ec = root_name(p, p)) return ec;
|
|
||||||
result = !p.empty();
|
|
||||||
return make_error_code(errc::success);
|
|
||||||
}
|
|
||||||
|
|
||||||
error_code has_root_directory(const Twine &path, bool &result) {
|
|
||||||
SmallString<128> storage;
|
|
||||||
StringRef p = path.toStringRef(storage);
|
|
||||||
|
|
||||||
if (error_code ec = root_directory(p, p)) return ec;
|
|
||||||
result = !p.empty();
|
|
||||||
return make_error_code(errc::success);
|
|
||||||
}
|
|
||||||
|
|
||||||
error_code relative_path(const StringRef &path, StringRef &result) {
|
error_code relative_path(const StringRef &path, StringRef &result) {
|
||||||
StringRef root;
|
StringRef root;
|
||||||
if (error_code ec = root_path(path, root)) return ec;
|
if (error_code ec = root_path(path, root)) return ec;
|
||||||
@ -590,6 +572,76 @@ error_code extension(const StringRef &path, StringRef &result) {
|
|||||||
return make_error_code(errc::success);
|
return make_error_code(errc::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_code has_root_name(const Twine &path, bool &result) {
|
||||||
|
SmallString<128> path_storage;
|
||||||
|
StringRef p = path.toStringRef(path_storage);
|
||||||
|
|
||||||
|
if (error_code ec = root_name(p, p)) return ec;
|
||||||
|
|
||||||
|
result = !p.empty();
|
||||||
|
return make_error_code(errc::success);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_code has_root_directory(const Twine &path, bool &result) {
|
||||||
|
SmallString<128> path_storage;
|
||||||
|
StringRef p = path.toStringRef(path_storage);
|
||||||
|
|
||||||
|
if (error_code ec = root_directory(p, p)) return ec;
|
||||||
|
|
||||||
|
result = !p.empty();
|
||||||
|
return make_error_code(errc::success);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_code has_root_path(const Twine &path, bool &result) {
|
||||||
|
SmallString<128> path_storage;
|
||||||
|
StringRef p = path.toStringRef(path_storage);
|
||||||
|
|
||||||
|
if (error_code ec = root_path(p, p)) return ec;
|
||||||
|
|
||||||
|
result = !p.empty();
|
||||||
|
return make_error_code(errc::success);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_code has_filename(const Twine &path, bool &result) {
|
||||||
|
SmallString<128> path_storage;
|
||||||
|
StringRef p = path.toStringRef(path_storage);
|
||||||
|
|
||||||
|
if (error_code ec = filename(p, p)) return ec;
|
||||||
|
|
||||||
|
result = !p.empty();
|
||||||
|
return make_error_code(errc::success);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_code has_parent_path(const Twine &path, bool &result) {
|
||||||
|
SmallString<128> path_storage;
|
||||||
|
StringRef p = path.toStringRef(path_storage);
|
||||||
|
|
||||||
|
if (error_code ec = parent_path(p, p)) return ec;
|
||||||
|
|
||||||
|
result = !p.empty();
|
||||||
|
return make_error_code(errc::success);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_code has_stem(const Twine &path, bool &result) {
|
||||||
|
SmallString<128> path_storage;
|
||||||
|
StringRef p = path.toStringRef(path_storage);
|
||||||
|
|
||||||
|
if (error_code ec = stem(p, p)) return ec;
|
||||||
|
|
||||||
|
result = !p.empty();
|
||||||
|
return make_error_code(errc::success);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_code has_extension(const Twine &path, bool &result) {
|
||||||
|
SmallString<128> path_storage;
|
||||||
|
StringRef p = path.toStringRef(path_storage);
|
||||||
|
|
||||||
|
if (error_code ec = extension(p, p)) return ec;
|
||||||
|
|
||||||
|
result = !p.empty();
|
||||||
|
return make_error_code(errc::success);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,13 +96,21 @@ TEST(Support, Path) {
|
|||||||
}
|
}
|
||||||
outs() << "]\n";
|
outs() << "]\n";
|
||||||
|
|
||||||
|
bool bres;
|
||||||
StringRef sfres;
|
StringRef sfres;
|
||||||
|
TEST_PATH(has_root_path, *i, bres);
|
||||||
TEST_PATH(root_path, *i, sfres);
|
TEST_PATH(root_path, *i, sfres);
|
||||||
|
TEST_PATH(has_root_name, *i, bres);
|
||||||
TEST_PATH(root_name, *i, sfres);
|
TEST_PATH(root_name, *i, sfres);
|
||||||
|
TEST_PATH(has_root_directory, *i, bres);
|
||||||
TEST_PATH(root_directory, *i, sfres);
|
TEST_PATH(root_directory, *i, sfres);
|
||||||
|
TEST_PATH(has_parent_path, *i, bres);
|
||||||
TEST_PATH(parent_path, *i, sfres);
|
TEST_PATH(parent_path, *i, sfres);
|
||||||
|
TEST_PATH(has_filename, *i, bres);
|
||||||
TEST_PATH(filename, *i, sfres);
|
TEST_PATH(filename, *i, sfres);
|
||||||
|
TEST_PATH(has_stem, *i, bres);
|
||||||
TEST_PATH(stem, *i, sfres);
|
TEST_PATH(stem, *i, sfres);
|
||||||
|
TEST_PATH(has_extension, *i, bres);
|
||||||
TEST_PATH(extension, *i, sfres);
|
TEST_PATH(extension, *i, sfres);
|
||||||
|
|
||||||
SmallString<16> temp_store;
|
SmallString<16> temp_store;
|
||||||
|
Loading…
Reference in New Issue
Block a user