From e96a30a5314ae9c206957a35217395bd0649963c Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 30 Oct 2009 05:48:30 +0000 Subject: Handle loading of field values from LazyCompoundVals in GRExprEngine::VisitMemberExpr(). This fixes the crash reported in PR 5316. llvm-svn: 85578 --- clang/lib/Analysis/GRExprEngine.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'clang/lib/Analysis/GRExprEngine.cpp') diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index c0aed2306e3..99e214400ec 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/lib/Analysis/GRExprEngine.cpp @@ -1092,13 +1092,26 @@ void GRExprEngine::VisitMemberExpr(MemberExpr* M, ExplodedNode* Pred, // FIXME: Should we insert some assumption logic in here to determine // if "Base" is a valid piece of memory? Before we put this assumption // later when using FieldOffset lvals (which we no longer have). - SVal L = state->getLValue(Field, state->getSVal(Base)); + SVal BaseV = state->getSVal(Base); + + if (nonloc::LazyCompoundVal *LVC=dyn_cast(&BaseV)){ + const LazyCompoundValData *D = LVC->getCVData(); + const FieldRegion * FR = + getStateManager().getRegionManager().getFieldRegion(Field, + D->getRegion()); + + SVal V = D->getState()->getSVal(loc::MemRegionVal(FR)); + MakeNode(Dst, M, *I, state->BindExpr(M, V)); + } + else { + SVal L = state->getLValue(Field, BaseV); - if (asLValue) - MakeNode(Dst, M, *I, state->BindExpr(M, L), - ProgramPoint::PostLValueKind); - else - EvalLoad(Dst, M, *I, state, L); + if (asLValue) + MakeNode(Dst, M, *I, state->BindExpr(M, L), + ProgramPoint::PostLValueKind); + else + EvalLoad(Dst, M, *I, state, L); + } } } -- cgit v1.2.3