https://bugs.llvm.org/show_bug.cgi?id=42398
Bug ID: 42398
Summary: [static analyzer/ObjC] Static analyzer does not catch
invoking a null block parameter
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Created attachment 22141
--> https://bugs.llvm.org/attachment.cgi?id=22141&action=edit
Repro for static analyzer bug
The Clang static analyzer correctly catches invoking a null block when it's a
local variable, but fails to catch the same issue when it's a nullable block
parameter:
% cat test.m
static void DoStuff(void (^_Nullable block_param)()) {
// This raises `core.CallAndMessage` as expected:
// warning: Called function pointer is null (null dereference)
[clang-analyzer-core.CallAndMessage]
void (^block)() = 0;
block();
// This should raise `nullability.NullableDereferenced` but does not
block_param();
// This raises neither `core.CallAndMessage` nor
`nullability.NullableDereferenced`
block_param = 0;
block_param();
}
% clang-tidy -checks=\* test.m -- -fblocks
1 warning generated.
test.m:5:3: warning: Called function pointer is null (null dereference)
[clang-analyzer-core.CallAndMessage]
block();
^
test.m:4:3: note: 'block' initialized to a null pointer value
void (^block)() = 0;
^
test.m:5:3: note: Called function pointer is null (null dereference)
block();
^
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs