[PATCH] D157888: [NFC][Clang] Fix static analyzer concern about null value dereference
Elizabeth Andrews via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 14 12:44:59 PDT 2023
eandrews added a comment.
In D157888#4586126 <https://reviews.llvm.org/D157888#4586126>, @steakhal wrote:
> Hmm. I guess the assertion is to silence some tool. And I think actually that function might very well also return null in some cases.
> Why do you think it cannot or at least should not return null in your context? I couldn't infer this from the context, neither from the description of this patch.
>
> Without that, I would prefer an if to guard the code, instead of asserting this.
`createBegin()` has a call to `getValidSourceLocation()` which dereferences this Statement. So in this context Statement cannot be null.
> If getStmtForDiagnostics() in general, never returns null, then shouldn't we mark the API with an appropriate attribute?
`getStmtForDiagnostics()` explicitly returns `nullptr` when none of the cases for `ProgramPoint` listed in the function are met. So I am not sure if we can just assume this function should never return null.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157888/new/
https://reviews.llvm.org/D157888
More information about the cfe-commits
mailing list