]> granicus.if.org Git - clang/commit
[analyzer] Do not infer nullability inside function-like macros, even when macro...
authorGeorge Karpenkov <ekarpenkov@apple.com>
Sat, 3 Feb 2018 00:55:21 +0000 (00:55 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Sat, 3 Feb 2018 00:55:21 +0000 (00:55 +0000)
commitd4a7bc588f9f950e90e3fcc7186e3bc2e706b116
tree74912e093e0baac3484f4b823f7e58cd60be8203
parent64e12bfe9c3e83e35bee59146577a4e951bee09f
[analyzer] Do not infer nullability inside function-like macros, even when macro is explicitly returning NULL

We already suppress such reports for inlined functions, we should then
get the same behavior for macros.
The underlying reason is that the same macro, can be called from many
different contexts, and nullability can only be expected in _some_ of
them.
Assuming that the macro can return null in _all_ of them sometimes leads
to a large number of false positives.

E.g. consider the test case for the dynamic cast implementation in
macro: in such cases, the bug report is unwanted.

Tracked in rdar://36304776

Differential Revision: https://reviews.llvm.org/D42404

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324161 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
test/Analysis/diagnostics/macro-null-return-suppression.cpp [new file with mode: 0644]