[cfe-dev] scan-build constraints

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Fri Jun 7 22:02:57 PDT 2019


Yes!

http://clang-analyzer.llvm.org/faq.html#exclude_code

On 07.06.2019 01:20, Paulo Matos wrote:
>
> On 07/06/2019 06:38, Artem Dergachev wrote:
>> 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.
>>
> In that case, is there any way to determine through cpp macros if we are
> running under scan_build?
>
>
>> 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