[cfe-dev] scan-build constraints

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 6 21:38:14 PDT 2019


You can use assert() to communicate your knowledge about the code to the 
static analyzer. E.g., assert that the pointer is non-null before 
dereferencing. It also saves you from undefined behavior when the static 
analyzer turns out to be right.

That said, also please feel free to send us a bug report about these 
false positives through llvm bugzilla (with either a full html report 
or, even better, a small reproducer) - i'll see what i can do.

On 06.06.2019 12:37, Paulo Matos via cfe-dev wrote:
> Hi,
>
> scan-build is generating null pointer dereference complaints because it
> does not understand that there's a relation between the arguments to a
> function.
>
> The function looks like:
> void *array_func(void **arr, int arrl) ...
>
> where arrl is equal to the number of elements in array l so any access
> to arr[0] - arr[arrl-1] is fine. Is there a way to specify to scan-build
> these relationships?
>
> Thanks,
>




More information about the cfe-dev mailing list