__clang_analyzer__
not defined in headers?
#3676
Labels
clang sa 🐉
The Clang Static Analyzer is a source code analysis tool that finds bugs in C-family programs.
help wanted
I'm working on adding CodeChecker support for our codebase and the docs mention that you should use
assert()
to guide clangsa around false positives. Our codebase doesn't currently useassert()
so I went to add it as a macro guarded by__clang_analyzer__
so that it doesn't affect our normal builds:I have some code in
api.c
that looks likeWhich produces this error:
We know that
cycle_length_sec()
can technically, but never practically, return 0, so I added our assert right above the line:But the warning keeps appearing, and clangsa doesn't seem to acknowledge the macro in its list of
Macro expansions
like it does forROUNDDOWN
. However, if I move theifdef
block intoapi.c
then the warning is suppressed as I'd expect:So for some reason it seems like
__clang_analyzer__
is defined inapi.c
but not indef.h
, even though the latter is directly#include
d from the former??I tried running the analyzer with debug logging turned on and I do see
-D__clang_analyzer__
in the CTU portion of the analysis:But I do not see it in the analysis run itself:
Is this something I need to go bug LLVM about or is there something going on with how CodeChecker invokes it?
CodeChecker version
v6.19.1
The text was updated successfully, but these errors were encountered: