ginginsha
ginginsha

Reputation: 152

How to enable clang static analyzer flags from clang-tidy for alpha (experimental) checkers?

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)

Upvotes: 2

Views: 839

Answers (2)

ginginsha
ginginsha

Reputation: 152

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>

Upvotes: 0

Boris Wang
Boris Wang

Reputation: 41

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

Upvotes: 1

Related Questions