continue;
}
- if (T->isPointerType() || T->isReferenceType()) {
+ if (T->isPointerType() || T->isReferenceType() || T->isBlockPointerType()) {
if (isPointerOrReferenceUninit(FR, LocalChain))
ContainsUninitField = true;
continue;
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);
--- /dev/null
+// 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;
+}