-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Open
Labels
clang:static analyzerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
In the following file
struct A {
void doSomething();
};
struct B {
A* _Nullable a();
};
int main() {
const auto a = B{}.a();
// un-comment this line to get the clang-analyzer-core.CallAndMessage lint.
// I'm wondering why this line is needed, since we mark it as nullable already!
// [[maybe_unused]] int x = a ? 1 : 0;
a->doSomething();
return 0;
}
If you run clang-tidy --checks="clang-analyzer-core*" file.cpp
, you won't get a clang-analyzer-core.CallAndMessage
diagnostic until you comment out the line that checks a
against null. I think it would be useful and in the spirit of the nullability annotations to instead issue a diagnostic here, because the return value of a()
is explicitly marked nullable. godbolt short link for repro
Metadata
Metadata
Assignees
Labels
clang:static analyzerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!