From: Ted Kremenek Date: Thu, 17 Dec 2009 01:20:43 +0000 (+0000) Subject: Fix check in GRExprEngine for the 'main' function to handle NULL IdentifierInfo*'s. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f75f92a9c2e6e3ad8fbb08532b6e5852d785b60;p=clang Fix check in GRExprEngine for the 'main' function to handle NULL IdentifierInfo*'s. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91577 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index f93ed7871b..ec2d913b68 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -339,23 +339,24 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) { if (const FunctionDecl *FD = dyn_cast(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(&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(&Constraint_untested)) { + if (const GRState *newState = state->Assume(*Constraint, true)) + state = newState; + } } - } + } } } else if (const ObjCMethodDecl *MD = dyn_cast(D)) {