3

I'm trying to run the clang analyzer through its clang-tidy interface, but I need to pass the clang analyzer an additional flag. Specifically, I want to run an alpha checker for nondeterminism with

clang-tidy -allow-enabling-analyzer-alpha-checkers -checks=clang-analyzer-alpha.nondeterminism.*

but it gives me the error:

error: checker cannot be enabled with analyzer option 'aggressive-binary-operation-simplification' == false [clang-diagnostic-error]

since it depends on having the flag aggressive-binary-operation-simplification=true (false by default) set for the clang analyzer.

If I'm limited to using clang-tidy, is this possible?

I've taken a look at the options available, and none seem to fit the bill. (e.g. using --extra-arg(-before)

2 Answers 2

2

clang-tidy --extra-arg=-Xclang --extra-arg=-analyzer-config --extra-arg=-Xclang --extra-arg=aggressive-binary-operation-simplification=true -p the_build_dir_contain_the_file_compile_commands.json your_source_file_pathname

Sign up to request clarification or add additional context in comments.

Comments

0

The flag --extra-arg=aggressive-binary-operation-simplification wasn't actually necessary in the end. I believe the error was in my build process.

Boris' answer is close, but it's missing the alpha checker call and it isn't necessary to use the --extra-arg flags specifying.

For reference, the final fixed call is:

clang-tidy <source_file> -allow-enabling-analyzer-alpha-checkers -checks=clang-analyzer-alpha.nondeterminism.* -- -ffile-prefix-map=</my/include/path/>= -I</my/include/path/ same for the -ffile-prefix-map>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.