To repro:
int foo(int* p) {
if (p != nullptr) {
return 0;
} else {
return *p;
}
}
clang --analyze -Xclang -analyzer-output=sarif-html
Actual result:
foo.cpp:5:16: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
5 | return *p;
| ^~
foo.cpp:5:16: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
5 | return *p;
| ^~
foo.cpp:5:16: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
5 | return *p;
| ^~
3 warnings generated.
Expected result:
foo.cpp:5:16: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
5 | return *p;
| ^~
1 warning generated.