-1

I'm trying to implement my little custom check, for example trying to walk through this tutorial (which is out of date a bit).

I have several problems:

  • After I cloned the repos, implemented the check and runned cmake, the builds targets are different from the tutorial
  • After the build and the make of the project I don't even know what should I run, to execute my checker on a file or on a project.

Thank you forward for your help!

  • 2
    Please, describe your **exact steps** in the question post. Linking to the tutorial shows the *reason* of these steps ("**Why** have you performed these steps?" - "I have followed the tutorial"). Currently, your question can be answered only by a person who knows well the tutorial and practicing a lot in it. E.g. you say "builds targets are different from the tutorial." - Which **exact** targets are different? Should we try to follow the tutorial (build our code) for detect that? – Tsyvarev Jul 20 '18 at 09:09
  • Yes, you should try to follow it. I believe that the same problems will come out for you too. – Huszák Richárd Jul 20 '18 at 11:54
  • 1
    You don't quite understand me. Would you say like: "I have cloned repos and run `cmake `. But there is no target `Foo`, which is needed for <...>. The tutorial talks about that target.", then a person, who familiar with clang-tidy, but **not familiar with a tutorial**, may answer like: "The target for make these thing is named `Bar`". But currently your question doesn't allow such person to answer - the absent target can only be revealed by following the tutorial. Do not expect everyone *wants* to follow the same tutorial as you for help you. – Tsyvarev Jul 20 '18 at 12:16
  • - I Cloned the mirror of the repos as written in the tutorial from here, because the ones in the tutorial were not working https://github.com/llvm-mirror/clang-tools-extra https://github.com/llvm-mirror/clang https://github.com/llvm-mirror/llvm cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. Then I Tried: make check-clang-tools but I can only run: make check-clang-tooling After following the tutorial I cannot find the point which shows me how to run my check which I implemented as It is written in it. – Huszák Richárd Jul 20 '18 at 12:40
  • 2
    Do not post additional information about your problem in the *comments*. Instead, [edit] the **question post** and add this information into it. – Tsyvarev Jul 20 '18 at 12:51

2 Answers2

3

Well instead of using a tutorial which you admit is out of date how about using a tutorial that is part of the official documentation?

https://clang.llvm.org/extra/clang-tidy/Contributing.html#writing-a-clang-tidy-check

what should I run, to execute my checker on a file or on a project.

Run the clang-tidy executable with proper parameters (see the aforementioned documentation for more details)

$ clang-tidy test.cpp -checks=-*,your-custom-check-name

-* disables all default checks so this will only run your custom check.

user2023370
  • 10,488
  • 6
  • 50
  • 83
pablo285
  • 2,460
  • 4
  • 14
  • 38
0

I've solved the build target problem, which was that the check-clang-tools target were missing. In the cmake file structure, on the llvm/tools/clang/tools level, in the CMakeLists.txt there was a missing line, which i have to add: add_clang_subdirectory(clang-tools-extra)


The solution to the execution problem:

  1. Make sure that the somedir/llvm/build/bin is added to your PATH
  2. Then you need to execute

llvm/tools/clang/tools/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py fileyouwanttocheck.cpp -checks='-*,your-check'

or

llvm/tools/clang/tools/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py project_folder_you_want_to_check -checks='-*,your-check'