diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-11-07 10:38:33 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-11-07 10:38:33 +0000 |
commit | f22679e3e5d5f5754931952e58112b4c863a4137 (patch) | |
tree | 703bcba80843be4e5e5a31a6cebb394aead9ec38 /lib/Analysis/GRExprEngine.cpp | |
parent | 13d1ee2ea780c749f8c2298d253b67d50535e493 (diff) |
Finish the implementation of VisitCompoundLiteralExpr. As VisitInitListExpr is
available, things get much simplified.
One addition is that CompoundLiteralExpr can appear both in rvalue and lvalue
context.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58837 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 6162592437..e2c23b4942 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -329,6 +329,10 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) { case Stmt::CompoundAssignOperatorClass: VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Dst); break; + + case Stmt::CompoundLiteralExprClass: + VisitCompoundLiteralExpr(cast<CompoundLiteralExpr>(S), Pred, Dst, false); + break; case Stmt::ConditionalOperatorClass: { // '?' operator ConditionalOperator* C = cast<ConditionalOperator>(S); @@ -435,7 +439,7 @@ void GRExprEngine::VisitLValue(Expr* Ex, NodeTy* Pred, NodeSet& Dst) { return; case Stmt::CompoundLiteralExprClass: - VisitCompoundLiteralExpr(cast<CompoundLiteralExpr>(Ex), Pred, Dst); + VisitCompoundLiteralExpr(cast<CompoundLiteralExpr>(Ex), Pred, Dst, true); return; case Stmt::ObjCPropertyRefExprClass: @@ -1575,31 +1579,21 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){ } void GRExprEngine::VisitCompoundLiteralExpr(CompoundLiteralExpr* CL, - NodeTy* Pred, NodeSet& Dst) { - - // FIXME: Can getInitializer() be NULL? + NodeTy* Pred, NodeSet& Dst, + bool asLValue) { InitListExpr* ILE = cast<InitListExpr>(CL->getInitializer()->IgnoreParens()); NodeSet Tmp; Visit(ILE, Pred, Tmp); for (NodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I!=EI; ++I) { - // Retrieve the initializer values from the environment and store them - // into a vector that will then be handed off to the Store. - const GRState* St = GetState(*I); - llvm::SmallVector<SVal, 10> IVals; - IVals.reserve(ILE->getNumInits()); - - for (Stmt::child_iterator J=ILE->child_begin(), EJ=ILE->child_end(); - J!=EJ; ++J) - IVals.push_back(GetSVal(St, cast<Expr>(*J))); - - const CompoundLiteralRegion* R = - StateMgr.getRegionManager().getCompoundLiteralRegion(CL); - - assert (!IVals.empty() && "Initializer cannot be empty."); + const GRState* St = GetState(*I); + SVal ILV = GetSVal(St, ILE); + St = StateMgr.BindCompoundLiteral(St, CL, ILV); - St = StateMgr.BindCompoundLiteral(St, R, &IVals[0], &IVals[0]+IVals.size()); - MakeNode(Dst, CL, *I, BindExpr(St, CL, loc::MemRegionVal(R))); + if (asLValue) + MakeNode(Dst, CL, *I, BindExpr(St, CL, StateMgr.GetLValue(St, CL))); + else + MakeNode(Dst, CL, *I, BindExpr(St, CL, ILV)); } } |