[clang] 2756e2e - [libTooling] Recognize sccache as a compiler wrapper in compilation database commands

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 26 22:47:10 PDT 2020


Author: Nathan Ridge
Date: 2020-10-27T01:46:32-04:00
New Revision: 2756e2ee0bceaf532d4990cbb4f2a84fe62b6b84

URL: https://github.com/llvm/llvm-project/commit/2756e2ee0bceaf532d4990cbb4f2a84fe62b6b84
DIFF: https://github.com/llvm/llvm-project/commit/2756e2ee0bceaf532d4990cbb4f2a84fe62b6b84.diff

LOG: [libTooling] Recognize sccache as a compiler wrapper in compilation database commands

sccache is a compiler caching tool similar to ccache.

Differential Revision: https://reviews.llvm.org/D88790

Added: 
    

Modified: 
    clang/lib/Tooling/JSONCompilationDatabase.cpp
    clang/unittests/Tooling/CompilationDatabaseTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 67a42d3c55a7..4aa16853ce45 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -272,7 +272,8 @@ static bool unwrapCommand(std::vector<std::string> &Args) {
     return false;
   StringRef Wrapper =
       stripExecutableExtension(llvm::sys::path::filename(Args.front()));
-  if (Wrapper == "distcc" || Wrapper == "gomacc" || Wrapper == "ccache") {
+  if (Wrapper == "distcc" || Wrapper == "gomacc" || Wrapper == "ccache" ||
+      Wrapper == "sccache") {
     // Most of these wrappers support being invoked 3 ways:
     // `distcc g++ file.c` This is the mode we're trying to match.
     //                     We need to drop `distcc`.

diff  --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 3bfb0ec1f7d5..9e2342894f71 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -383,6 +383,7 @@ 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"},
+      {"sccache 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"},


        


More information about the cfe-commits mailing list