summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-02-23 21:19:33 +0000
committerTed Kremenek <kremenek@apple.com>2010-02-23 21:19:33 +0000
commitb4331a990859f0ca3995f1736eb3d05a85b7a60e (patch)
treeb16af246947a3a067396b3bfa8a5763db1f0bbcf /clang/lib
parent00fb2ce233dd3f182aa4365c77c2addf2a657262 (diff)
downloadbcm5719-llvm-b4331a990859f0ca3995f1736eb3d05a85b7a60e.tar.gz
bcm5719-llvm-b4331a990859f0ca3995f1736eb3d05a85b7a60e.zip
Dead emit dead store warnings when assigning nil to an ObjC object
pointer (for defensive programming). This matches the behavior with assigning NULL to a regular pointer. Fixes <rdar://problem/7631278>. llvm-svn: 96985
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Checker/CheckDeadStores.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Checker/CheckDeadStores.cpp b/clang/lib/Checker/CheckDeadStores.cpp
index 4a7ca705488..31f9390e622 100644
--- a/clang/lib/Checker/CheckDeadStores.cpp
+++ b/clang/lib/Checker/CheckDeadStores.cpp
@@ -142,7 +142,8 @@ public:
if (VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
// Special case: check for assigning null to a pointer.
// This is a common form of defensive programming.
- if (VD->getType()->isPointerType()) {
+ QualType T = VD->getType();
+ if (T->isPointerType() || T->isObjCObjectPointerType()) {
if (B->getRHS()->isNullPointerConstant(Ctx,
Expr::NPC_ValueDependentIsNull))
return;
OpenPOWER on IntegriCloud