[cfe-commits] r91577 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp
Daniel Dunbar
daniel at zuster.org
Thu Dec 17 07:58:06 PST 2009
Hi Ted,
On Wed, Dec 16, 2009 at 5:20 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Wed Dec 16 19:20:43 2009
> New Revision: 91577
>
> URL: http://llvm.org/viewvc/llvm-project?rev=91577&view=rev
> Log:
> Fix check in GRExprEngine for the 'main' function to handle NULL IdentifierInfo*'s.
Can this use early exits to reduce nesting?
- Daniel
> Modified:
> cfe/trunk/lib/Analysis/GRExprEngine.cpp
>
> Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=91577&r1=91576&r2=91577&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
> +++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Dec 16 19:20:43 2009
> @@ -339,23 +339,24 @@
> 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)) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list