[PATCH] D50673: [analyzer] Fix UninitializedObjectChecker to not crash on uninitialized "id" fields
George Karpenkov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 13 16:32:55 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339631: [analyzer] Fix UninitializedObjectChecker to not crash on uninitialized "id"… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.
Changed prior to commit:
https://reviews.llvm.org/D50673?vs=160473&id=160482#toc
Repository:
rC Clang
https://reviews.llvm.org/D50673
Files:
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
test/Analysis/objcpp-uninitialized-object.mm
Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
@@ -78,7 +78,7 @@
bool FindUninitializedFields::isPointerOrReferenceUninit(
const FieldRegion *FR, FieldChainInfo LocalChain) {
- assert((FR->getDecl()->getType()->isPointerType() ||
+ assert((FR->getDecl()->getType()->isAnyPointerType() ||
FR->getDecl()->getType()->isReferenceType() ||
FR->getDecl()->getType()->isBlockPointerType()) &&
"This method only checks pointer/reference objects!");
Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -265,7 +265,7 @@
continue;
}
- if (T->isPointerType() || T->isReferenceType() || T->isBlockPointerType()) {
+ if (T->isAnyPointerType() || T->isReferenceType() || T->isBlockPointerType()) {
if (isPointerOrReferenceUninit(FR, LocalChain))
ContainsUninitField = true;
continue;
Index: test/Analysis/objcpp-uninitialized-object.mm
===================================================================
--- test/Analysis/objcpp-uninitialized-object.mm
+++ test/Analysis/objcpp-uninitialized-object.mm
@@ -20,3 +20,13 @@
void noWarningWhenInitialized() {
StructWithBlock a;
}
+
+struct StructWithId {
+ int a;
+ id z; // expected-note{{uninitialized pointer 'this->z'}}
+ StructWithId() : a(0) {} // expected-warning{{1 uninitialized field at the end of the constructor call}}
+};
+
+void warnOnUninitializedId() {
+ StructWithId s;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50673.160482.patch
Type: text/x-patch
Size: 1941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180813/0a59d3f1/attachment.bin>
More information about the cfe-commits
mailing list