[cfe-commits] r53168 - /cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
Ted Kremenek
kremenek at apple.com
Sun Jul 6 23:36:08 PDT 2008
Author: kremenek
Date: Mon Jul 7 01:36:08 2008
New Revision: 53168
URL: http://llvm.org/viewvc/llvm-project?rev=53168&view=rev
Log:
Do not emit a "missing -dealloc" warning if a class contains no ivars that are pointers.
This patch aims to address some of the concerns of PR 2517: http://llvm.org/bugs/show_bug.cgi?id=2517
Modified:
cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
Modified: cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp?rev=53168&r1=53167&r2=53168&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp Mon Jul 7 01:36:08 2008
@@ -48,11 +48,27 @@
ASTContext& Ctx = BR.getContext();
ObjCInterfaceDecl* ID = D->getClassInterface();
+
+ // Does the class contain any ivars that are pointers (or id<...>)?
+ // If not, skip the check entirely.
+ // NOTE: This is motivated by PR 2517:
+ // http://llvm.org/bugs/show_bug.cgi?id=2517
- // Does the class contain any ivars? If not, skip the check entirely.
+ bool containsPointerIvar = false;
- if (ID->ivar_empty())
- return;
+ for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(), E=ID->ivar_end();
+ I!=E; ++I) {
+
+ QualType T = (*I)->getType();
+
+ if (T->isPointerType() || T->isObjCQualifiedIdType()) {
+ containsPointerIvar = true;
+ break;
+ }
+ }
+
+ if (!containsPointerIvar)
+ return;
// Determine if the class subclasses NSObject.
IdentifierInfo* NSObjectII = &Ctx.Idents.get("NSObject");
More information about the cfe-commits
mailing list