Clang-tidy Ignoring Format Style


I am running clang-tidy from CMake. clang-tidy is running all of the other checks (configured in .clang-tidy), but it is ignoring my format style options. I am just trying to lint the format, not automatically fix the format.

I have tried:
In CMakeLists.txt:

        CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-format-style='llvm'")

I have also tried in .clang-tidy:

FormatStyle: llvm

I have also tried setting the format style to file and adding BasedOnStyle: LLVM to .clang-format in the same folder as .clang-tidy. Running clang-format separately works as expected.

What am I missing?

clang-tidy only uses the format style to reformat any fixes it makes, it wont just reformat all your code.
If you are using the -fix flag and its outputting fixes that look unformatted then there is an issue that needs resolving.

1 Like

I see, that makes a lot of sense! Thank you!