diff options
author | Dan McGregor <dan.mcgregor@usask.ca> | 2019-11-26 14:23:07 -0800 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-11-26 15:17:49 -0800 |
commit | 6c92cdff72251a7d13ab3958b04fba72dfcaebb1 (patch) | |
tree | 109f389b97c23284a0af76927c7f1650f1fb9787 /llvm/unittests/Support | |
parent | e177c5a00da34ba61b762e2b32bd96e33b0c10b4 (diff) | |
download | bcm5719-llvm-6c92cdff72251a7d13ab3958b04fba72dfcaebb1.tar.gz bcm5719-llvm-6c92cdff72251a7d13ab3958b04fba72dfcaebb1.zip |
Initial implementation of -fmacro-prefix-map and -ffile-prefix-map
GCC 8 implements -fmacro-prefix-map. Like -fdebug-prefix-map, it replaces a string prefix for the __FILE__ macro.
-ffile-prefix-map is the union of -fdebug-prefix-map and -fmacro-prefix-map
Reviewed By: rnk, Lekensteyn, maskray
Differential Revision: https://reviews.llvm.org/D49466
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r-- | llvm/unittests/Support/Path.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 9de46a689cd..1f7a10d94f2 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -1230,7 +1230,9 @@ TEST(Support, RemoveDots) { TEST(Support, ReplacePathPrefix) { SmallString<64> Path1("/foo"); SmallString<64> Path2("/old/foo"); + SmallString<64> Path3("/oldnew/foo"); SmallString<64> OldPrefix("/old"); + SmallString<64> OldPrefixSep("/old/"); SmallString<64> NewPrefix("/new"); SmallString<64> NewPrefix2("/longernew"); SmallString<64> EmptyPrefix(""); @@ -1250,6 +1252,33 @@ TEST(Support, ReplacePathPrefix) { Path = Path2; path::replace_path_prefix(Path, OldPrefix, EmptyPrefix); EXPECT_EQ(Path, "/foo"); + Path = Path2; + path::replace_path_prefix(Path, OldPrefix, EmptyPrefix, true); + EXPECT_EQ(Path, "foo"); + Path = Path3; + path::replace_path_prefix(Path, OldPrefix, NewPrefix, false); + EXPECT_EQ(Path, "/newnew/foo"); + Path = Path3; + path::replace_path_prefix(Path, OldPrefix, NewPrefix, true); + EXPECT_EQ(Path, "/oldnew/foo"); + Path = Path3; + path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true); + EXPECT_EQ(Path, "/oldnew/foo"); + Path = Path1; + path::replace_path_prefix(Path, EmptyPrefix, NewPrefix); + EXPECT_EQ(Path, "/new/foo"); + Path = OldPrefix; + path::replace_path_prefix(Path, OldPrefix, NewPrefix); + EXPECT_EQ(Path, "/new"); + Path = OldPrefixSep; + path::replace_path_prefix(Path, OldPrefix, NewPrefix); + EXPECT_EQ(Path, "/new/"); + Path = OldPrefix; + path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, false); + EXPECT_EQ(Path, "/old"); + Path = OldPrefix; + path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true); + EXPECT_EQ(Path, "/new"); } TEST_F(FileSystemTest, OpenFileForRead) { |