First, let me move this over to cfe-dev -- that's where the clang-tidy developers hang out.
On Fri, Jul 5, 2019 at 4:00 PM martin lampacher <[hidden email]> wrote:
thanks a bunch for the reply! Yeah I was looking deeper into it - and it makes sense. Apart from naming lot of the checks do require the actual build/AST. I'm working on that now - compiledb might just do what I need otherwise building the file should not be a major problem.
Am I correct in assuming that the compile database should contain _all_ the files that are required for a build, whereas I can still run clang-tidy on a per-file basis? We have loads of third-party code that needs to be configured and compiled into our projects but must not be modified (safety project).
I'm not sure exactly how cmake decides what to include in the compilation database, but I'd assume it includes anything that clang compiles, which is all you're concerned with. As for 3rd party code, you can pick up the headers automatically (please see --header-filter=), but if you want the c/cpp files, you need to do each project individually. Just try a few, and you'll figure it out pretty quickly.
I hope it is o.k. if I'm continuing to post here. It's hard to find references on the web for this kinda edge-case, otherwise just let me know :)
Clang-tidy works on the AST, so you have to be able to compile the program and produce a valid AST for it to do anything useful.
Here are a few things you can try:
1) Don't pass -DCMAKE_EXPORT_COMPILE_COMMANDS=On to clang-tidy:
This only works when passed to cmake when generating build files, e.g., Makefiles. So if you aren't using cmake, you'll need to generate the compilation database yourself. Google for it, and you'll find a bunch of links, but here's a couple that might be useful (note I haven't used them):
Then use the -p flag to help clang-tidy find and use it -- it's just a json file.
2) You can also pass additional flags after the --, e.g., -I, etc. if needed.
On Wed, Jul 3, 2019 at 6:11 PM martin lampacher via llvm-dev <[hidden email]> wrote:
sorry for posting this here but I'm kind of stuck. I'm trying to introduce LLVM tooling step by step at the company I'm working for. So far I'm using clang-format for automated formatting.
Since I'm also working on the coding guideline I wanted to use clang-tidy for enforcing the naming convention. The problem is that we're using a plain old MAKE project, so I can't really benefit from the CMAKE integration.
The idea was to simply run clang-format and clang-tidy alongside the normal MAKE process, it's quite easy to integrate into the ruleset.
With clang-tidy I have the problem that it is trying to do "to much". So even if I'm disabling all rules but 'readability-identifier-naming ' the tool will still execute clang-diagnostic-error checks.