aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/CompilationDatabaseTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
-rw-r--r--clang/unittests/Tooling/CompilationDatabaseTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index da7ae09..6794029 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -370,6 +370,30 @@ TEST(findCompileArgsInJsonDatabase, FindsEntry) {
EXPECT_EQ("command4", FoundCommand.CommandLine[0]) << ErrorMessage;
}
+TEST(findCompileArgsInJsonDatabase, ParsesCompilerWrappers) {
+ std::vector<std::pair<std::string, std::string>> Cases = {
+ {"distcc gcc foo.c", "gcc foo.c"},
+ {"gomacc clang++ foo.c", "clang++ foo.c"},
+ {"ccache gcc foo.c", "gcc foo.c"},
+ {"ccache.exe gcc foo.c", "gcc foo.c"},
+ {"ccache g++.exe foo.c", "g++.exe foo.c"},
+ {"ccache distcc gcc foo.c", "gcc foo.c"},
+
+ {"distcc foo.c", "distcc foo.c"},
+ {"distcc -I/foo/bar foo.c", "distcc -I/foo/bar foo.c"},
+ };
+ std::string ErrorMessage;
+
+ for (const auto &Case : Cases) {
+ std::string DB = R"([{"directory":".", "file":"/foo.c", "command":")" +
+ Case.first + "\"}]";
+ CompileCommand FoundCommand =
+ findCompileArgsInJsonDatabase("/foo.c", DB, ErrorMessage);
+ EXPECT_EQ(Case.second, llvm::join(FoundCommand.CommandLine, " "))
+ << Case.first;
+ }
+}
+
static std::vector<std::string> unescapeJsonCommandLine(StringRef Command) {
std::string JsonDatabase =
("[{\"directory\":\"//net/root\", \"file\":\"test\", \"command\": \"" +