Disabling clang compiler warnings, but not static analyzer ones

Hi,

To test the checkers we’ve developed, we would like to disable all clang warnings, except from the ones coming from our checker. We’ve tried the -w flag, but it also suppresses our own checker’s warnings. We’re running the clang with the -Xclang -analyzer-checker=“testchecker” flags.

We have some work-around ideas (putting a unique marker string in our warnings, and filter out any warnings that do not contain them), but I feel that this is something most checker developers would run into sooner-or-later, so surely, there must be a better solution.

So how could we disable all clang warnings, except for the ones emitted by our specific checker?

Thanks!

Gabor

Hi,

To test the checkers we’ve developed, we would like to disable all clang warnings, except from the ones coming from our checker. We’ve tried the -w flag, but it also suppresses our own checker’s warnings.

Is there something special in your setup?
The -w flag should not/does not suppress warnings coming from the analyzer:

Ex:
$clang -w --analyze ~/tmp/ex.m
/Users/zaks/tmp/ex.m:4:11: warning: Division by zero

return 5/zero + 5/0;
*~^~~~~*
1 warning generated.

Thanks Anna, you’re right, it works when passed directly to clang, but not when using -Xclang.