aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/CompilationDatabaseTest.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2022-01-06 05:00:11 +0100
committerSam McCall <sam.mccall@gmail.com>2022-01-11 01:41:42 +0100
commit4258d68dc73789bc7fc491734c9c392809b1b29a (patch)
tree291ee61c8d2ca872bf24651ebdf0fac87f715925 /clang/unittests/Tooling/CompilationDatabaseTest.cpp
parentd789ea713372d44e50ff52a85a198ac6bbedaef9 (diff)
downloadllvm-4258d68dc73789bc7fc491734c9c392809b1b29a.zip
llvm-4258d68dc73789bc7fc491734c9c392809b1b29a.tar.gz
llvm-4258d68dc73789bc7fc491734c9c392809b1b29a.tar.bz2
[Tooling] When transferring compile commands between files, always use '--'
"driver <flags> -- <input>" is a particularly convenient form of the compile command to manipulate, with fewer special cases to handle. Guaranteeing that the output command is of that form is cheap and makes it easier to consume the result in some cases. Differential Revision: https://reviews.llvm.org/D116721
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
-rw-r--r--clang/unittests/Tooling/CompilationDatabaseTest.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 218a352..adb9de0 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -739,6 +739,9 @@ protected:
EXPECT_EQ(Results[0].CommandLine.back(), MakeNative ? path(F) : F)
<< "Last arg should be the file";
Results[0].CommandLine.pop_back();
+ EXPECT_EQ(Results[0].CommandLine.back(), "--")
+ << "Second-last arg should be --";
+ Results[0].CommandLine.pop_back();
return llvm::join(Results[0].CommandLine, " ");
}
@@ -826,18 +829,6 @@ TEST_F(InterpolateTest, StripDoubleDash) {
EXPECT_EQ(getCommand("dir/bar.cpp"), "clang -D dir/foo.cpp -Wall -std=c++14");
}
-TEST_F(InterpolateTest, InsertDoubleDash) {
- add("dir/foo.cpp", "-o foo.o -std=c++14 -Wall");
- EXPECT_EQ(getCommand("-dir/bar.cpp", false),
- "clang -D dir/foo.cpp -Wall -std=c++14 --");
-}
-
-TEST_F(InterpolateTest, InsertDoubleDashForClangCL) {
- add("dir/foo.cpp", "clang-cl", "/std:c++14 /W4");
- EXPECT_EQ(getCommand("/dir/bar.cpp", false),
- "clang-cl -D dir/foo.cpp /W4 /std:c++14 --");
-}
-
TEST_F(InterpolateTest, Case) {
add("FOO/BAR/BAZ/SHOUT.cc");
add("foo/bar/baz/quiet.cc");
@@ -879,7 +870,7 @@ TEST(TransferCompileCommandTest, Smoke) {
CompileCommand Transferred = transferCompileCommand(std::move(Cmd), "foo.h");
EXPECT_EQ(Transferred.Filename, "foo.h");
EXPECT_THAT(Transferred.CommandLine,
- ElementsAre("clang", "-Wall", "-x", "c++-header", "foo.h"));
+ ElementsAre("clang", "-Wall", "-x", "c++-header", "--", "foo.h"));
EXPECT_EQ(Transferred.Directory, "dir");
}