diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-08-09 00:05:14 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-08-09 00:05:14 +0000 |
| commit | 0216b83d944538cefb7935fa817d6f87878b910e (patch) | |
| tree | c8a572ce6a0a93d0f2f591137254a2d0ac7550c3 /clang/lib/Analysis | |
| parent | 1a02630b632a776010f9218764f39afb74829eb0 (diff) | |
| download | bcm5719-llvm-0216b83d944538cefb7935fa817d6f87878b910e.tar.gz bcm5719-llvm-0216b83d944538cefb7935fa817d6f87878b910e.zip | |
Don't use Expr::isIntegerConstantExpr just to check if a pointer value is initialize to NULL.
llvm-svn: 54563
Diffstat (limited to 'clang/lib/Analysis')
| -rw-r--r-- | clang/lib/Analysis/CheckDeadStores.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/clang/lib/Analysis/CheckDeadStores.cpp b/clang/lib/Analysis/CheckDeadStores.cpp index 63de9adb8fc..9d9e68d2ef8 100644 --- a/clang/lib/Analysis/CheckDeadStores.cpp +++ b/clang/lib/Analysis/CheckDeadStores.cpp @@ -128,25 +128,21 @@ public: if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(B->getLHS())) 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. - // FIXME: Make this optional? - - Expr* Val = B->getRHS(); - llvm::APSInt Result(Ctx.getTypeSize(Val->getType())); - - if (VD->getType()->isPointerType() && - Val->IgnoreParenCasts()->isIntegerConstantExpr(Result, Ctx, 0)) - if (Result == 0) - return; + // 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>(B->getRHS()->IgnoreParenCasts())) + if (L->getValue() == 0) + return; + } DeadStoreKind dsk = Parents.isSubExpr(B) ? Enclosing : (isIncrement(VD,B) ? DeadIncrement : Standard); - CheckVarDecl(VD, DR, Val, dsk, AD, Live); + CheckVarDecl(VD, DR, B->getRHS(), dsk, AD, Live); } } else if (UnaryOperator* U = dyn_cast<UnaryOperator>(S)) { |

