diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-12-17 01:20:43 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-12-17 01:20:43 +0000 |
commit | 2e2b2581583b4f59df907cb1e0455fb67946e487 (patch) | |
tree | df3831410f4e0be1bfa96551f4c9abcda75add4f /clang/lib/Analysis | |
parent | 057a17e4c518e218aee42323f901fb25f17543c2 (diff) | |
download | bcm5719-llvm-2e2b2581583b4f59df907cb1e0455fb67946e487.tar.gz bcm5719-llvm-2e2b2581583b4f59df907cb1e0455fb67946e487.zip |
Fix check in GRExprEngine for the 'main' function to handle NULL IdentifierInfo*'s.
llvm-svn: 91577
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/GRExprEngine.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index f93ed7871b5..ec2d913b68f 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/lib/Analysis/GRExprEngine.cpp @@ -339,23 +339,24 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { // Precondition: the first argument of 'main' is an integer guaranteed // to be > 0. - if (FD->getIdentifier()->getName() == "main" && - FD->getNumParams() > 0) { - const ParmVarDecl *PD = FD->getParamDecl(0); - QualType T = PD->getType(); - if (T->isIntegerType()) - if (const MemRegion *R = state->getRegion(PD, InitLoc)) { - SVal V = state->getSVal(loc::MemRegionVal(R)); - SVal Constraint_untested = EvalBinOp(state, BinaryOperator::GT, V, - ValMgr.makeZeroVal(T), - getContext().IntTy); - - if (DefinedOrUnknownSVal *Constraint = - dyn_cast<DefinedOrUnknownSVal>(&Constraint_untested)) { - if (const GRState *newState = state->Assume(*Constraint, true)) - state = newState; + if (const IdentifierInfo *II = FD->getIdentifier()) { + if (II->getName() == "main" && FD->getNumParams() > 0) { + const ParmVarDecl *PD = FD->getParamDecl(0); + QualType T = PD->getType(); + if (T->isIntegerType()) + if (const MemRegion *R = state->getRegion(PD, InitLoc)) { + SVal V = state->getSVal(loc::MemRegionVal(R)); + SVal Constraint_untested = EvalBinOp(state, BinaryOperator::GT, V, + ValMgr.makeZeroVal(T), + getContext().IntTy); + + if (DefinedOrUnknownSVal *Constraint = + dyn_cast<DefinedOrUnknownSVal>(&Constraint_untested)) { + if (const GRState *newState = state->Assume(*Constraint, true)) + state = newState; + } } - } + } } } else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { |