mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 07:56:07 +00:00

Before this patch, FieldChainInfo used a spaghetti: it took care of way too many cases, even though it was always meant as a lightweight wrapper around ImmutableList<const FieldRegion *>. This problem is solved by introducing a lightweight polymorphic wrapper around const FieldRegion *, FieldNode. It is an interface that abstracts away special cases like pointers/references, objects that need to be casted to another type for a proper note messages. Changes to FieldChainInfo: * Now wraps ImmutableList<const FieldNode &>. * Any pointer/reference related fields and methods were removed * Got a new add method. This replaces it's former constructors as a way to create a new FieldChainInfo objects with a new element. Changes to FindUninitializedField: * In order not to deal with dynamic memory management, when an uninitialized field is found, the note message for it is constructed and is stored instead of a FieldChainInfo object. (see doc around addFieldToUninits). Some of the test files are changed too, from now on uninitialized pointees of references always print "uninitialized pointee" instead of "uninitialized field" (which should've really been like this from the beginning). I also updated every comment according to these changes. Differential Revision: https://reviews.llvm.org/D50506 llvm-svn: 339599
23 lines
566 B
Plaintext
23 lines
566 B
Plaintext
// 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 pointer '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;
|
|
}
|