Really struggling to find documentation / examples so thought I'd reach out.
My goal: I want clang-tidy to produce a report that I can eventually submit to sonarqube for analysis.
Setting the scene: I have an Android project that's a hybrid of Java and C++ (using JNI). It's legacy C++ that I'm porting (pre-11) and is compiled using CMake throughout the multiple files that make up the project. When editing my code, I can see that clang-tidy is doing a great job of identifying "static" issues as I code, e.g.
Problem: I can't find any specific documentation or examples of how to run clang-tidy, as part of my build. Android Studio is obviously running it via it's "plugin" to highlight "on-the-fly", so it must already be doing what I need - but I just cannot see how to begin to get a report out.
What I've tried:
- Analyze->Run Inspection By Name->Clang-tidy... This runs on the whole project, but produces a tiny amount of issues compared to the number I see from "on-the-fly" analysis.
- Adding CMAKE_CXX_CLANG_TIDY to my top level CMakelists.txt, and to my build.gradle (externalNativeBuild) - with various different options, including "-checks=-,clang-analyzer-*,-clang-analyzer-cplusplus**"
- This almost appears to work, but I just get a lookup related error: Android\Sdk\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\c++\v1\cstddef:44:15: error: 'stddef.h' file not found [clang-diagnostic-error]
- Research.. Done my usual trawl of the internet - and I'm either doing something crazy, or the only people attempting to do this are keeping their methods to themselves!
Desperate for any help here, feel like it's trivial but no-one in my organisation has tried anything like this before.