aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/TransformerTest.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2023-09-08 13:13:20 -0700
committerJan Svoboda <jan_svoboda@apple.com>2023-09-08 16:38:08 -0700
commit5523fefb01c282c4cbcaf6314a9aaf658c6c145f (patch)
tree21391a147cf519283e749127f10397d934d03bb7 /clang/unittests/Tooling/TransformerTest.cpp
parent9818bf2619b1213ebf045250dc13562e723e581a (diff)
downloadllvm-5523fefb01c282c4cbcaf6314a9aaf658c6c145f.zip
llvm-5523fefb01c282c4cbcaf6314a9aaf658c6c145f.tar.gz
llvm-5523fefb01c282c4cbcaf6314a9aaf658c6c145f.tar.bz2
[clang][lex] Use preferred path separator in includer-relative lookup
There is a long-standing FIXME in `HeaderSearch.cpp` to use the path separator preferred by the platform instead of forward slash. There was an attempt to fix that (1cf6c28a) which got reverted (cf385dc8). I couldn't find an explanation, but my guess is that some tests assuming forward slash started failing. This commit fixes tests with that assumption. This is intended to be NFC, but there are two exceptions to that: * Some diagnostic messages might now contain backslash instead of forward slash. * Arguments to the "-remap-file" option that use forward slash might stop kicking in. Separators between potential includer path and header name need to be replaced by backslash in that case.
Diffstat (limited to 'clang/unittests/Tooling/TransformerTest.cpp')
-rw-r--r--clang/unittests/Tooling/TransformerTest.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/unittests/Tooling/TransformerTest.cpp b/clang/unittests/Tooling/TransformerTest.cpp
index 09fcf04..cbd84ab 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -1623,7 +1623,8 @@ TEST_F(TransformerTest, MultipleFiles) {
return L.getFilePath() < R.getFilePath();
});
- ASSERT_EQ(Changes[0].getFilePath(), "./input.h");
+ ASSERT_EQ(llvm::sys::path::convert_to_slash(Changes[0].getFilePath()),
+ "./input.h");
EXPECT_THAT(Changes[0].getInsertedHeaders(), IsEmpty());
EXPECT_THAT(Changes[0].getRemovedHeaders(), IsEmpty());
llvm::Expected<std::string> UpdatedCode =
@@ -1660,7 +1661,8 @@ TEST_F(TransformerTest, AddIncludeMultipleFiles) {
{{"input.h", Header}}));
ASSERT_EQ(Changes.size(), 1U);
- ASSERT_EQ(Changes[0].getFilePath(), "./input.h");
+ ASSERT_EQ(llvm::sys::path::convert_to_slash(Changes[0].getFilePath()),
+ "./input.h");
EXPECT_THAT(Changes[0].getInsertedHeaders(), ElementsAre("header.h"));
EXPECT_THAT(Changes[0].getRemovedHeaders(), IsEmpty());
llvm::Expected<std::string> UpdatedCode =
@@ -1702,14 +1704,14 @@ TEST_F(TransformerTest, MultiFileEdit) {
"clang-tool", std::make_shared<PCHContainerOperations>(),
{{"input.h", Header}}));
+ auto GetPathWithSlashes = [](const AtomicChange &C) {
+ return llvm::sys::path::convert_to_slash(C.getFilePath());
+ };
+
EXPECT_EQ(ErrorCount, 0);
- EXPECT_THAT(
- ChangeSets,
- UnorderedElementsAre(UnorderedElementsAre(
- ResultOf([](const AtomicChange &C) { return C.getFilePath(); },
- "input.cc"),
- ResultOf([](const AtomicChange &C) { return C.getFilePath(); },
- "./input.h"))));
+ EXPECT_THAT(ChangeSets, UnorderedElementsAre(UnorderedElementsAre(
+ ResultOf(GetPathWithSlashes, "input.cc"),
+ ResultOf(GetPathWithSlashes, "./input.h"))));
}
TEST_F(TransformerTest, GeneratesMetadata) {