clangllvmclang-tidyclang-static-analyzerscan-build

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)


Solution

  • 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>