[PATCH] D46887: Fix llvm::sys::path::remove_dots() to return "." instead of an empty path.
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 16 11:29:52 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332508: Fix llvm::sys::path::remove_dots() to return "." instead of an empty path. (authored by gclayton, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D46887?vs=147134&id=147143#toc
Repository:
rL LLVM
https://reviews.llvm.org/D46887
Files:
llvm/trunk/lib/Support/Path.cpp
llvm/trunk/unittests/Support/Path.cpp
Index: llvm/trunk/lib/Support/Path.cpp
===================================================================
--- llvm/trunk/lib/Support/Path.cpp
+++ llvm/trunk/lib/Support/Path.cpp
@@ -726,6 +726,10 @@
SmallString<256> buffer = path::root_path(path, style);
for (StringRef C : components)
path::append(buffer, style, C);
+ // If the buffer is empty, then return ".". Many other path utilities
+ // do this so it seems to be an expected result.
+ if (buffer.empty())
+ buffer.append(1, '.');
return buffer;
}
Index: llvm/trunk/unittests/Support/Path.cpp
===================================================================
--- llvm/trunk/unittests/Support/Path.cpp
+++ llvm/trunk/unittests/Support/Path.cpp
@@ -1146,7 +1146,7 @@
TEST(Support, RemoveDots) {
EXPECT_EQ("foolz\\wat",
remove_dots(".\\.\\\\foolz\\wat", false, path::Style::windows));
- EXPECT_EQ("", remove_dots(".\\\\\\\\\\", false, path::Style::windows));
+ EXPECT_EQ(".", remove_dots(".\\\\\\\\\\", false, path::Style::windows));
EXPECT_EQ("a\\..\\b\\c",
remove_dots(".\\a\\..\\b\\c", false, path::Style::windows));
@@ -1163,7 +1163,8 @@
EXPECT_EQ("foolz/wat",
remove_dots("././/foolz/wat", false, path::Style::posix));
- EXPECT_EQ("", remove_dots("./////", false, path::Style::posix));
+ EXPECT_EQ(".", remove_dots("./////", false, path::Style::posix));
+ EXPECT_EQ(".", remove_dots("", false, path::Style::posix));
EXPECT_EQ("a/../b/c", remove_dots("./a/../b/c", false, path::Style::posix));
EXPECT_EQ("b/c", remove_dots("./a/../b/c", true, path::Style::posix));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46887.147143.patch
Type: text/x-patch
Size: 1615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180516/0f9f7ce8/attachment.bin>
More information about the llvm-commits
mailing list