[PATCH] D55680: [analyzer] ObjCDealloc: Fix a crash when a class attempts to deallocate another class.
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 14 18:12:25 PST 2018
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349228: [analyzer] ObjCDealloc: Fix a crash when a class attempts to deallocate a class. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D55680?vs=178146&id=178330#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55680/new/
https://reviews.llvm.org/D55680
Files:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/MissingDealloc.m
Index: cfe/trunk/test/Analysis/MissingDealloc.m
===================================================================
--- cfe/trunk/test/Analysis/MissingDealloc.m
+++ cfe/trunk/test/Analysis/MissingDealloc.m
@@ -183,4 +183,17 @@
@implementation NonNSObjectMissingDealloc
@end
-// CHECK: 4 warnings generated.
+
+//===------------------------------------------------------------------------===
+// Don't crash on calls to dealloc as a class method.
+
+ at interface DeallocingClass : NSObject {}
+ at end
+ at implementation DeallocingClass
+- (void)dealloc {
+ [DeallocingClass dealloc]; // FIXME: Should we warn on this specifically?
+}
+#if NON_ARC
+// expected-warning at -2{{method possibly missing a [super dealloc] call}}
+#endif
+ at end
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
@@ -715,6 +715,10 @@
bool ObjCDeallocChecker::diagnoseMistakenDealloc(SymbolRef DeallocedValue,
const ObjCMethodCall &M,
CheckerContext &C) const {
+ // TODO: Apart from unknown/undefined receivers, this may happen when
+ // dealloc is called as a class method. Should we warn?
+ if (!DeallocedValue)
+ return false;
// Find the property backing the instance variable that M
// is dealloc'ing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55680.178330.patch
Type: text/x-patch
Size: 1502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181215/4eb8b2d1/attachment.bin>
More information about the llvm-commits
mailing list