[PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

Zachary Turner via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 12 14:37:31 PDT 2016


zturner added a comment.

This is starting to get fairly difficult, and I'm afraid it may require someone more knowledgable about clang-format's internals than me.  I wrote a test to have it use a fixed compilation database, and I was able to make that test pass, but it breaks many other tests.  I will go ahead and upload that patch anyway just so you can see what I did.

What's weird is that it doesn't seem to break clang-tidy itself, just the tests.  For example, here's what I get when I run the following command:

  D:\src\llvmbuild\ninja>"bin\clang-tidy" "--checks=-*,google-readability-casting" "-header-filter=.*" "D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c" "--" "-ID:\src\llvm\tools\clang\tools\extra\test\clang-tidy" "-DTEST_INCLUDE" "-x" "c++"
  1 warning generated.
  D:\src\llvm\tools\clang\tools\extra\test\clang-tidy/google-readability-casting.c:16:22: warning: redundant cast to the same type [google-readability-casting]
    const char *cpc2 = (const char*)cpc;
                       ^

It appears to work fine.

But when I run the test, it complains about trying to copy some file which seems unrelated to my change and more about the test infrastructure.

  D:\src\llvmbuild\ninja>python bin\llvm-lit.py -sv d:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c
  -- Testing: 1 tests, 1 threads --
  Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
  FAIL: Clang Tools :: clang-tidy/google-readability-casting.c (1 of 1)
  ******************** TEST 'Clang Tools :: clang-tidy/google-readability-casting.c' FAILED ********************
  Script:
  --
  C:/Python27/python.exe D:/src/llvm/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c google-readability-casting D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp -- -- -x c
  clang-tidy --checks=-*,google-readability-casting D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c -- -x c++ | FileCheck D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
  cp D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.main_file.cpp
  clang-tidy --checks=-*,google-readability-casting -header-filter='.*' D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.main_file.cpp -- -ID:\src\llvm\tools\clang\tools\extra\test\clang-tidy -DTEST_INCLUDE -x c++ | FileCheck D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  $ "C:/Python27/python.exe" "D:/src/llvm/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py" "D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c" "google-readability-casting" "D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp" "--" "--" "-x" "c"
  # command output:
  Running ['clang-tidy', 'D:\\src\\llvmbuild\\ninja\\tools\\clang\\tools\\extra\\test\\clang-tidy\\Output\\google-readability-casting.c.tmp.c', '-fix', '--checks=-*,google-readability-casting', '--', '-x', 'c']...
  ------------------------ clang-tidy output -----------------------
  1 warning generated.
  D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.c:16:22: warning: redundant cast to the same type [google-readability-casting]
    const char *cpc2 = (const char*)cpc;
                       ^
  D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.c:16:22: note: FIX-IT applied suggested code changes
    const char *cpc2 = (const char*)cpc;
                       ^
  clang-tidy applied 1 of 1 suggested fixes.
  
  ------------------------------------------------------------------
  ------------------------------ Fixes -----------------------------
  --- D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.c.orig       2016-08-12 14:29:14.035738300 -0700
  +++ D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.c    2016-08-12 14:29:14.133810600 -0700
  @@ -13,7 +13,7 @@
   #else
  
   void f(const char *cpc) {
  -  const char *cpc2 = (const char*)cpc;
  +  const char *cpc2 = cpc;
     //
     //
     char *pc = (char*)cpc;
  
  ------------------------------------------------------------------
  
  $ "clang-tidy" "--checks=-*,google-readability-casting" "D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c" "--" "-x" "c++"
  # command stderr:
  1 warning generated.
  
  $ "FileCheck" "D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c" "-check-prefix=CHECK-MESSAGES" "-implicit-check-not={{warning|error}}:"
  $ "cp" "D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c" "D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.main_file.cpp"
  $ "clang-tidy" "--checks=-*,google-readability-casting" "-header-filter=.*" "D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.main_file.cpp" "--" "-ID:\src\llvm\tools\clang\tools\extra\test\clang-tidy" "-DTEST_INCLUDE" "-x" "c++"
  # command stderr:
  1 error generated.
  Error while processing D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.main_file.cpp.
  
  $ "FileCheck" "D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c" "-check-prefix=CHECK-MESSAGES" "-implicit-check-not={{warning|error}}:"
  # command stderr:
  D:\src\llvm\tools\clang\tools\extra\test\clang-tidy\google-readability-casting.c:17:21: error: expected string not found in input
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [google-readability-casting]
                      ^
  <stdin>:1:1: note: scanning from here
  D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.main_file.cpp:11:10: error: 'google-readability-casting.c' file not found [clang-diagnostic-error]
  ^
  <stdin>:1:1: note: with expression "@LINE-1" equal to "16"
  D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.main_file.cpp:11:10: error: 'google-readability-casting.c' file not found [clang-diagnostic-error]
  ^
  <stdin>:1:84: note: possible intended match here
  D:\src\llvmbuild\ninja\tools\clang\tools\extra\test\clang-tidy\Output\google-readability-casting.c.tmp.main_file.cpp:11:10: error: 'google-readability-casting.c' file not found [clang-diagnostic-error]
                                                                                     ^
  
  error: command failed with exit status: 1
  
  --
  
  ********************
  Testing Time: 0.66s
  ********************
  Failing Tests (1):
      Clang Tools :: clang-tidy/google-readability-casting.c
  
    Unexpected Failures: 1

I'm not really sure what to make of this.

Any assistance would be appreciated.  I will update the diff with what I came up with.

As a temporary solution, since the patch here could not possibly regress anything since it leaves the code unchanged on all the paths where it is already supported, perhaps this can go in without a test until I have time to understand the codebase better and figure out something better.


https://reviews.llvm.org/D23455





More information about the cfe-commits mailing list