[cfe-dev] [PATCH] Move some code into GRSimpleVals

Ted Kremenek kremenek at apple.com
Mon Aug 18 22:07:06 PDT 2008


On Aug 18, 2008, at 9:27 PM, Zhongxing Xu wrote:

> 1. Local variables are not handled, since they are handled in  
> GRExprEngine::VisitDeclStmt().

Hi Zhongxing,

This patch looks really awesome.  The only problem I see is that  
VisitDeclStmt doesn't handle the fact that a local variable is  
uninitialized before VisitDeclStmt is called (this poses a problem  
because the Expr* for the initializer is visited before the  
DeclStmt).  That's why local variables are initialized to  
UndefinedVal.  Observe that the test case Analysis/uninit-ps- 
rdar6145427.m fails because of this change (run 'make test').

I think the solution is to leave in:

       RVal X = (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) ||
                 isa<ImplicitParamDecl>(VD))
              ? RVal::GetSymbolValue(SymMgr, VD)
              : UndefinedVal();

instead of:

         // Only handle globals and parameters here. Local variables  
are handled
         // in VisitDeclStmt().
         if (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) ||
             isa<ImplicitParamDecl>(VD)) {
           RVal X = RVal::GetSymbolValue(StateMgr.getSymbolManager(),  
VD);
           St = SetRVal(St, lval::DeclVal(VD), X);
         }

You're right that the following is dead code and should be removed:

     } else if (ImplicitParamDecl *IPD =  
dyn_cast<ImplicitParamDecl>(SD)) {
         RVal X = RVal::GetSymbolValue(SymMgr, IPD);
       StateMgr.SetRVal(StateImpl, lval::DeclVal(IPD), X);
     }

Ted



More information about the cfe-dev mailing list