diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-11-22 20:26:21 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-11-22 20:26:21 +0000 |
commit | 12b64959ceebbc2e8e356ad45fdd16cb07aa9993 (patch) | |
tree | 39f808b493ddba8ea819d48dc9a7a24e098f7f2a /clang/lib/Analysis | |
parent | bf6d35893fc3521d8dc5f9acdd8d2dee40ff50ca (diff) | |
download | bcm5719-llvm-12b64959ceebbc2e8e356ad45fdd16cb07aa9993.tar.gz bcm5719-llvm-12b64959ceebbc2e8e356ad45fdd16cb07aa9993.zip |
Change CheckDeadStores to use Expr::isNullPointerConstant, which will correctly determine whether an expression is a null pointer constant.
Patch by Kovarththanan Rajaratnam!
llvm-svn: 89621
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/CheckDeadStores.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Analysis/CheckDeadStores.cpp b/clang/lib/Analysis/CheckDeadStores.cpp index d5cb7ca7fdd..dd70ed7f2c1 100644 --- a/clang/lib/Analysis/CheckDeadStores.cpp +++ b/clang/lib/Analysis/CheckDeadStores.cpp @@ -134,16 +134,15 @@ public: if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(B->getLHS())) if (VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) { - Expr* RHS = B->getRHS()->IgnoreParenCasts(); - // Special case: check for assigning null to a pointer. // This is a common form of defensive programming. if (VD->getType()->isPointerType()) { - if (IntegerLiteral* L = dyn_cast<IntegerLiteral>(RHS)) - // FIXME: Probably should have an Expr::isNullPointerConstant. - if (L->getValue() == 0) - return; + if (B->getRHS()->isNullPointerConstant(Ctx, + Expr::NPC_ValueDependentIsNull)) + return; } + + Expr* RHS = B->getRHS()->IgnoreParenCasts(); // Special case: self-assignments. These are often used to shut up // "unused variable" compiler warnings. if (DeclRefExpr* RhsDR = dyn_cast<DeclRefExpr>(RHS)) |