[PATCH] D50523: [analyzer] Fix the bug in UninitializedObjectChecker caused by not handling block pointers
George Karpenkov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 9 12:03:45 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339369: [analyzer] Fix the bug in UninitializedObjectChecker caused by not handling… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.
Changed prior to commit:
https://reviews.llvm.org/D50523?vs=159968&id=159971#toc
Repository:
rC Clang
https://reviews.llvm.org/D50523
Files:
lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
test/Analysis/objcpp-uninitialized-object.mm
Index: test/Analysis/objcpp-uninitialized-object.mm
===================================================================
--- test/Analysis/objcpp-uninitialized-object.mm
+++ test/Analysis/objcpp-uninitialized-object.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s
+
+typedef void (^myBlock) ();
+
+struct StructWithBlock {
+ int a;
+ myBlock z; // expected-note{{uninitialized field 'this->z'}}
+
+ StructWithBlock() : a(0), z(^{}) {}
+
+ // Miss initialization of field `z`.
+ StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}}
+
+};
+
+void warnOnUninitializedBlock() {
+ StructWithBlock a(10);
+}
+
+void noWarningWhenInitialized() {
+ StructWithBlock a;
+}
Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
@@ -417,7 +417,7 @@
continue;
}
- if (T->isPointerType() || T->isReferenceType()) {
+ if (T->isPointerType() || T->isReferenceType() || T->isBlockPointerType()) {
if (isPointerOrReferenceUninit(FR, LocalChain))
ContainsUninitField = true;
continue;
@@ -478,7 +478,8 @@
const FieldRegion *FR, FieldChainInfo LocalChain) {
assert((FR->getDecl()->getType()->isPointerType() ||
- FR->getDecl()->getType()->isReferenceType()) &&
+ FR->getDecl()->getType()->isReferenceType() ||
+ FR->getDecl()->getType()->isBlockPointerType()) &&
"This method only checks pointer/reference objects!");
SVal V = State->getSVal(FR);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50523.159971.patch
Type: text/x-patch
Size: 1786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180809/fc5eb6d5/attachment.bin>
More information about the cfe-commits
mailing list