cpp-linter / clang-tools-pip

Install clang-format, clang-tidy, clang-query and clang-apply-replacements binaries with clang-tools CLI.
https://pypi.org/project/clang-tools
MIT License
7 stars 1 forks source link

The test results are different when installing clang-query-10 using apt and pip for the project. #102

Open tomchon opened 1 month ago

tomchon commented 1 month ago

i want using clang-query to do Static Code Analysis. but i find some different and funny things. The test results are different when installing clang-query-10 using apt and pip method in the project. The only difference is the path used for clang-query.

  1. using pip install
    It will install the clang-tools into /usr/local/bin/
    pip3 install clang-tools 
    clang-tools --install 10 --tool  clang-query   --directory  /usr/local/bin/

    test result in match :

 root@dc9a644c9793: /usr/local/bin/clang-query-10 TDengine/debug/compile_commands.json TDengine/community/source/dnode/vnode/src/tsdb/tsdbRead2.c -f TDengine/community/tests/ci/filter_for_return_values 

0 matches.
  1. apt install It will install the clang-tools into /usr/bin/
    apt install clang-tools-10
root@dc9a644c9793:/home/chr/clang_scan_result/20240812154233#  /usr/bin/clang-query-10 -p TDengine/debug/compile_commands.json TDengine/community/source/dnode/vnode/src/tsdb/tsdbRead2.c -f TDengine/community/tests/ci/filter_for_return_values
In file included from TDengine/community/source/dnode/vnode/src/tsdb/tsdbRead2.c:17:
In file included from TDengine/community/source/dnode/vnode/src/inc/tsdb.h:22:
In file included from TDengine/community/include/util/tsimplehash.h:19:
In file included from TDengine/community/include/util/tarray.h:19:

Match #1:
TDengine/community/source/dnode/vnode/src/tsdb/tsdbRead2.c:5831:7: note: "root" binds here
      tsdbUnrefMemTable(pTsdb->mem, pSnap->pNode, true);  // unref the previous refed mem
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Match #2:

TDengine/community/source/dnode/vnode/src/tsdb/tsdbRead2.c:5848:7: note: "root" binds here
      tsdbUnrefMemTable(pTsdb->mem, pSnap->pNode, true);  // unref the previous refed mem
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Match #3:
TDengine/source/dnode/vnode/src/tsdb/tsdbRead2.c:5852:7: note: "root" binds here
      tsdbUnrefMemTable(pTsdb->imem, pSnap->pINode, true);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 matches.
shenxianpeng commented 1 month ago

Thanks for reporting this issue. I am not sure if it is because of clang-query-10 versions are different.

The clang-query-10 version supported by clang-tools is 10.0.1, but the version installed with apt install clang-tools-10 should be 10.0.0.

If you run the apt install clang-tools-10 first and then run clang-tools --install 10 --tool clang-query, clang-tools will link to /usr/lib/llvm-10/bin/clang-query automatically.