aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CheckObjCDealloc.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-07-07 06:36:08 +0000
committerTed Kremenek <kremenek@apple.com>2008-07-07 06:36:08 +0000
commit00fed8d4722517835c82c15ffd940100ac491e42 (patch)
tree5f7b15241b4382a8459e791f1c1ece1f415a924a /lib/Analysis/CheckObjCDealloc.cpp
parentcdfc641a6a6dd1e31894c3510a4894fc64ffdc37 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CheckObjCDealloc.cpp')
-rw-r--r--lib/Analysis/CheckObjCDealloc.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp
index 1f627216ef..7a2a0b65f0 100644
--- a/lib/Analysis/CheckObjCDealloc.cpp
+++ b/lib/Analysis/CheckObjCDealloc.cpp
@@ -48,11 +48,27 @@ void clang::CheckObjCDealloc(ObjCImplementationDecl* D,
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");