Fix false positive related to handling of [[noreturn]] function pointers
authorArseniy Zaostrovnykh <arseniy.zaostrovnykh@sonarsource.com>
Wed, 12 Oct 2022 12:46:32 +0000 (14:46 +0200)
committerBalazs Benics <benicsbalazs@gmail.com>
Wed, 12 Oct 2022 12:46:32 +0000 (14:46 +0200)
commitec6da3fb9d8c7859da22d9eb7e814faf2e5a524a
tree16ad04140763394864f3b6636ecef7e2489f2a66
parent78c66cf300eab3e7b49803e21c6bea5fb69a975d
Fix false positive related to handling of [[noreturn]] function pointers

Before this change, the `NoReturnFunctionChecker` was missing function pointers
with a `[[noreturn]]` attribute, while `CFG` was constructed taking that into
account, which leads CSA to take impossible paths. The reason was that the
`NoReturnFunctionChecker` was looking for the attribute in the type of the
entire call expression rather than the type of the function being called.

This change makes the `[[noreturn]]` attribute of a function pointer visible
to `NoReturnFunctionChecker`. This leads to a more coherent behavior of the
CSA on the AST involving.

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D135682
clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
clang/test/Analysis/no-return.c [new file with mode: 0644]