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); 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; +}