1 //=-- ExprEngineC.cpp - ExprEngine support for C expressions ----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //  This file defines ExprEngine's support for C expressions.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/ExprCXX.h"
14 #include "clang/AST/DeclCXX.h"
15 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
16 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
17 
18 using namespace clang;
19 using namespace ento;
20 using llvm::APSInt;
21 
22 /// Optionally conjure and return a symbol for offset when processing
23 /// an expression \p Expression.
24 /// If \p Other is a location, conjure a symbol for \p Symbol
25 /// (offset) if it is unknown so that memory arithmetic always
26 /// results in an ElementRegion.
27 /// \p Count The number of times the current basic block was visited.
28 static SVal conjureOffsetSymbolOnLocation(
29     SVal Symbol, SVal Other, Expr* Expression, SValBuilder &svalBuilder,
30     unsigned Count, const LocationContext *LCtx) {
31   QualType Ty = Expression->getType();
32   if (Other.getAs<Loc>() &&
33       Ty->isIntegralOrEnumerationType() &&
34       Symbol.isUnknown()) {
35     return svalBuilder.conjureSymbolVal(Expression, LCtx, Ty, Count);
36   }
37   return Symbol;
38 }
39 
40 void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
41                                      ExplodedNode *Pred,
42                                      ExplodedNodeSet &Dst) {
43 
44   Expr *LHS = B->getLHS()->IgnoreParens();
45   Expr *RHS = B->getRHS()->IgnoreParens();
46 
47   // FIXME: Prechecks eventually go in ::Visit().
48   ExplodedNodeSet CheckedSet;
49   ExplodedNodeSet Tmp2;
50   getCheckerManager().runCheckersForPreStmt(CheckedSet, Pred, B, *this);
51 
52   // With both the LHS and RHS evaluated, process the operation itself.
53   for (ExplodedNodeSet::iterator it=CheckedSet.begin(), ei=CheckedSet.end();
54          it != ei; ++it) {
55 
56     ProgramStateRef state = (*it)->getState();
57     const LocationContext *LCtx = (*it)->getLocationContext();
58     SVal LeftV = state->getSVal(LHS, LCtx);
59     SVal RightV = state->getSVal(RHS, LCtx);
60 
61     BinaryOperator::Opcode Op = B->getOpcode();
62 
63     if (Op == BO_Assign) {
64       // EXPERIMENTAL: "Conjured" symbols.
65       // FIXME: Handle structs.
66       if (RightV.isUnknown()) {
67         unsigned Count = currBldrCtx->blockCount();
68         RightV = svalBuilder.conjureSymbolVal(nullptr, B->getRHS(), LCtx,
69                                               Count);
70       }
71       // Simulate the effects of a "store":  bind the value of the RHS
72       // to the L-Value represented by the LHS.
73       SVal ExprVal = B->isGLValue() ? LeftV : RightV;
74       evalStore(Tmp2, B, LHS, *it, state->BindExpr(B, LCtx, ExprVal),
75                 LeftV, RightV);
76       continue;
77     }
78 
79     if (!B->isAssignmentOp()) {
80       StmtNodeBuilder Bldr(*it, Tmp2, *currBldrCtx);
81 
82       if (B->isAdditiveOp()) {
83         // TODO: This can be removed after we enable history tracking with
84         // SymSymExpr.
85         unsigned Count = currBldrCtx->blockCount();
86         RightV = conjureOffsetSymbolOnLocation(
87             RightV, LeftV, RHS, svalBuilder, Count, LCtx);
88         LeftV = conjureOffsetSymbolOnLocation(
89             LeftV, RightV, LHS, svalBuilder, Count, LCtx);
90       }
91 
92       // Although we don't yet model pointers-to-members, we do need to make
93       // sure that the members of temporaries have a valid 'this' pointer for
94       // other checks.
95       if (B->getOpcode() == BO_PtrMemD)
96         state = createTemporaryRegionIfNeeded(state, LCtx, LHS);
97 
98       // Process non-assignments except commas or short-circuited
99       // logical expressions (LAnd and LOr).
100       SVal Result = evalBinOp(state, Op, LeftV, RightV, B->getType());
101       if (!Result.isUnknown()) {
102         state = state->BindExpr(B, LCtx, Result);
103       }
104 
105       Bldr.generateNode(B, *it, state);
106       continue;
107     }
108 
109     assert (B->isCompoundAssignmentOp());
110 
111     switch (Op) {
112       default:
113         llvm_unreachable("Invalid opcode for compound assignment.");
114       case BO_MulAssign: Op = BO_Mul; break;
115       case BO_DivAssign: Op = BO_Div; break;
116       case BO_RemAssign: Op = BO_Rem; break;
117       case BO_AddAssign: Op = BO_Add; break;
118       case BO_SubAssign: Op = BO_Sub; break;
119       case BO_ShlAssign: Op = BO_Shl; break;
120       case BO_ShrAssign: Op = BO_Shr; break;
121       case BO_AndAssign: Op = BO_And; break;
122       case BO_XorAssign: Op = BO_Xor; break;
123       case BO_OrAssign:  Op = BO_Or;  break;
124     }
125 
126     // Perform a load (the LHS).  This performs the checks for
127     // null dereferences, and so on.
128     ExplodedNodeSet Tmp;
129     SVal location = LeftV;
130     evalLoad(Tmp, B, LHS, *it, state, location);
131 
132     for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E;
133          ++I) {
134 
135       state = (*I)->getState();
136       const LocationContext *LCtx = (*I)->getLocationContext();
137       SVal V = state->getSVal(LHS, LCtx);
138 
139       // Get the computation type.
140       QualType CTy =
141         cast<CompoundAssignOperator>(B)->getComputationResultType();
142       CTy = getContext().getCanonicalType(CTy);
143 
144       QualType CLHSTy =
145         cast<CompoundAssignOperator>(B)->getComputationLHSType();
146       CLHSTy = getContext().getCanonicalType(CLHSTy);
147 
148       QualType LTy = getContext().getCanonicalType(LHS->getType());
149 
150       // Promote LHS.
151       V = svalBuilder.evalCast(V, CLHSTy, LTy);
152 
153       // Compute the result of the operation.
154       SVal Result = svalBuilder.evalCast(evalBinOp(state, Op, V, RightV, CTy),
155                                          B->getType(), CTy);
156 
157       // EXPERIMENTAL: "Conjured" symbols.
158       // FIXME: Handle structs.
159 
160       SVal LHSVal;
161 
162       if (Result.isUnknown()) {
163         // The symbolic value is actually for the type of the left-hand side
164         // expression, not the computation type, as this is the value the
165         // LValue on the LHS will bind to.
166         LHSVal = svalBuilder.conjureSymbolVal(nullptr, B->getRHS(), LCtx, LTy,
167                                               currBldrCtx->blockCount());
168         // However, we need to convert the symbol to the computation type.
169         Result = svalBuilder.evalCast(LHSVal, CTy, LTy);
170       }
171       else {
172         // The left-hand side may bind to a different value then the
173         // computation type.
174         LHSVal = svalBuilder.evalCast(Result, LTy, CTy);
175       }
176 
177       // In C++, assignment and compound assignment operators return an
178       // lvalue.
179       if (B->isGLValue())
180         state = state->BindExpr(B, LCtx, location);
181       else
182         state = state->BindExpr(B, LCtx, Result);
183 
184       evalStore(Tmp2, B, LHS, *I, state, location, LHSVal);
185     }
186   }
187 
188   // FIXME: postvisits eventually go in ::Visit()
189   getCheckerManager().runCheckersForPostStmt(Dst, Tmp2, B, *this);
190 }
191 
192 void ExprEngine::VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred,
193                                 ExplodedNodeSet &Dst) {
194 
195   CanQualType T = getContext().getCanonicalType(BE->getType());
196 
197   const BlockDecl *BD = BE->getBlockDecl();
198   // Get the value of the block itself.
199   SVal V = svalBuilder.getBlockPointer(BD, T,
200                                        Pred->getLocationContext(),
201                                        currBldrCtx->blockCount());
202 
203   ProgramStateRef State = Pred->getState();
204 
205   // If we created a new MemRegion for the block, we should explicitly bind
206   // the captured variables.
207   if (const BlockDataRegion *BDR =
208       dyn_cast_or_null<BlockDataRegion>(V.getAsRegion())) {
209 
210     BlockDataRegion::referenced_vars_iterator I = BDR->referenced_vars_begin(),
211                                               E = BDR->referenced_vars_end();
212 
213     auto CI = BD->capture_begin();
214     auto CE = BD->capture_end();
215     for (; I != E; ++I) {
216       const VarRegion *capturedR = I.getCapturedRegion();
217       const VarRegion *originalR = I.getOriginalRegion();
218 
219       // If the capture had a copy expression, use the result of evaluating
220       // that expression, otherwise use the original value.
221       // We rely on the invariant that the block declaration's capture variables
222       // are a prefix of the BlockDataRegion's referenced vars (which may include
223       // referenced globals, etc.) to enable fast lookup of the capture for a
224       // given referenced var.
225       const Expr *copyExpr = nullptr;
226       if (CI != CE) {
227         assert(CI->getVariable() == capturedR->getDecl());
228         copyExpr = CI->getCopyExpr();
229         CI++;
230       }
231 
232       if (capturedR != originalR) {
233         SVal originalV;
234         const LocationContext *LCtx = Pred->getLocationContext();
235         if (copyExpr) {
236           originalV = State->getSVal(copyExpr, LCtx);
237         } else {
238           originalV = State->getSVal(loc::MemRegionVal(originalR));
239         }
240         State = State->bindLoc(loc::MemRegionVal(capturedR), originalV, LCtx);
241       }
242     }
243   }
244 
245   ExplodedNodeSet Tmp;
246   StmtNodeBuilder Bldr(Pred, Tmp, *currBldrCtx);
247   Bldr.generateNode(BE, Pred,
248                     State->BindExpr(BE, Pred->getLocationContext(), V),
249                     nullptr, ProgramPoint::PostLValueKind);
250 
251   // FIXME: Move all post/pre visits to ::Visit().
252   getCheckerManager().runCheckersForPostStmt(Dst, Tmp, BE, *this);
253 }
254 
255 ProgramStateRef ExprEngine::handleLValueBitCast(
256     ProgramStateRef state, const Expr* Ex, const LocationContext* LCtx,
257     QualType T, QualType ExTy, const CastExpr* CastE, StmtNodeBuilder& Bldr,
258     ExplodedNode* Pred) {
259   if (T->isLValueReferenceType()) {
260     assert(!CastE->getType()->isLValueReferenceType());
261     ExTy = getContext().getLValueReferenceType(ExTy);
262   } else if (T->isRValueReferenceType()) {
263     assert(!CastE->getType()->isRValueReferenceType());
264     ExTy = getContext().getRValueReferenceType(ExTy);
265   }
266   // Delegate to SValBuilder to process.
267   SVal OrigV = state->getSVal(Ex, LCtx);
268   SVal V = svalBuilder.evalCast(OrigV, T, ExTy);
269   // Negate the result if we're treating the boolean as a signed i1
270   if (CastE->getCastKind() == CK_BooleanToSignedIntegral)
271     V = evalMinus(V);
272   state = state->BindExpr(CastE, LCtx, V);
273   if (V.isUnknown() && !OrigV.isUnknown()) {
274     state = escapeValue(state, OrigV, PSK_EscapeOther);
275   }
276   Bldr.generateNode(CastE, Pred, state);
277 
278   return state;
279 }
280 
281 ProgramStateRef ExprEngine::handleLVectorSplat(
282     ProgramStateRef state, const LocationContext* LCtx, const CastExpr* CastE,
283     StmtNodeBuilder &Bldr, ExplodedNode* Pred) {
284   // Recover some path sensitivity by conjuring a new value.
285   QualType resultType = CastE->getType();
286   if (CastE->isGLValue())
287     resultType = getContext().getPointerType(resultType);
288   SVal result = svalBuilder.conjureSymbolVal(nullptr, CastE, LCtx,
289                                              resultType,
290                                              currBldrCtx->blockCount());
291   state = state->BindExpr(CastE, LCtx, result);
292   Bldr.generateNode(CastE, Pred, state);
293 
294   return state;
295 }
296 
297 void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
298                            ExplodedNode *Pred, ExplodedNodeSet &Dst) {
299 
300   ExplodedNodeSet dstPreStmt;
301   getCheckerManager().runCheckersForPreStmt(dstPreStmt, Pred, CastE, *this);
302 
303   if (CastE->getCastKind() == CK_LValueToRValue) {
304     for (ExplodedNodeSet::iterator I = dstPreStmt.begin(), E = dstPreStmt.end();
305          I!=E; ++I) {
306       ExplodedNode *subExprNode = *I;
307       ProgramStateRef state = subExprNode->getState();
308       const LocationContext *LCtx = subExprNode->getLocationContext();
309       evalLoad(Dst, CastE, CastE, subExprNode, state, state->getSVal(Ex, LCtx));
310     }
311     return;
312   }
313 
314   // All other casts.
315   QualType T = CastE->getType();
316   QualType ExTy = Ex->getType();
317 
318   if (const ExplicitCastExpr *ExCast=dyn_cast_or_null<ExplicitCastExpr>(CastE))
319     T = ExCast->getTypeAsWritten();
320 
321   StmtNodeBuilder Bldr(dstPreStmt, Dst, *currBldrCtx);
322   for (ExplodedNodeSet::iterator I = dstPreStmt.begin(), E = dstPreStmt.end();
323        I != E; ++I) {
324 
325     Pred = *I;
326     ProgramStateRef state = Pred->getState();
327     const LocationContext *LCtx = Pred->getLocationContext();
328 
329     switch (CastE->getCastKind()) {
330       case CK_LValueToRValue:
331         llvm_unreachable("LValueToRValue casts handled earlier.");
332       case CK_ToVoid:
333         continue;
334         // The analyzer doesn't do anything special with these casts,
335         // since it understands retain/release semantics already.
336       case CK_ARCProduceObject:
337       case CK_ARCConsumeObject:
338       case CK_ARCReclaimReturnedObject:
339       case CK_ARCExtendBlockObject: // Fall-through.
340       case CK_CopyAndAutoreleaseBlockObject:
341         // The analyser can ignore atomic casts for now, although some future
342         // checkers may want to make certain that you're not modifying the same
343         // value through atomic and nonatomic pointers.
344       case CK_AtomicToNonAtomic:
345       case CK_NonAtomicToAtomic:
346         // True no-ops.
347       case CK_NoOp:
348       case CK_ConstructorConversion:
349       case CK_UserDefinedConversion:
350       case CK_FunctionToPointerDecay:
351       case CK_BuiltinFnToFnPtr: {
352         // Copy the SVal of Ex to CastE.
353         ProgramStateRef state = Pred->getState();
354         const LocationContext *LCtx = Pred->getLocationContext();
355         SVal V = state->getSVal(Ex, LCtx);
356         state = state->BindExpr(CastE, LCtx, V);
357         Bldr.generateNode(CastE, Pred, state);
358         continue;
359       }
360       case CK_MemberPointerToBoolean:
361       case CK_PointerToBoolean: {
362         SVal V = state->getSVal(Ex, LCtx);
363         auto PTMSV = V.getAs<nonloc::PointerToMember>();
364         if (PTMSV)
365           V = svalBuilder.makeTruthVal(!PTMSV->isNullMemberPointer(), ExTy);
366         if (V.isUndef() || PTMSV) {
367           state = state->BindExpr(CastE, LCtx, V);
368           Bldr.generateNode(CastE, Pred, state);
369           continue;
370         }
371         // Explicitly proceed with default handler for this case cascade.
372         state =
373             handleLValueBitCast(state, Ex, LCtx, T, ExTy, CastE, Bldr, Pred);
374         continue;
375       }
376       case CK_Dependent:
377       case CK_ArrayToPointerDecay:
378       case CK_BitCast:
379       case CK_AddressSpaceConversion:
380       case CK_BooleanToSignedIntegral:
381       case CK_IntegralToPointer:
382       case CK_PointerToIntegral: {
383         SVal V = state->getSVal(Ex, LCtx);
384         if (V.getAs<nonloc::PointerToMember>()) {
385           state = state->BindExpr(CastE, LCtx, UnknownVal());
386           Bldr.generateNode(CastE, Pred, state);
387           continue;
388         }
389         // Explicitly proceed with default handler for this case cascade.
390         state =
391             handleLValueBitCast(state, Ex, LCtx, T, ExTy, CastE, Bldr, Pred);
392         continue;
393       }
394       case CK_IntegralToBoolean:
395       case CK_IntegralToFloating:
396       case CK_FloatingToIntegral:
397       case CK_FloatingToBoolean:
398       case CK_FloatingCast:
399       case CK_FloatingRealToComplex:
400       case CK_FloatingComplexToReal:
401       case CK_FloatingComplexToBoolean:
402       case CK_FloatingComplexCast:
403       case CK_FloatingComplexToIntegralComplex:
404       case CK_IntegralRealToComplex:
405       case CK_IntegralComplexToReal:
406       case CK_IntegralComplexToBoolean:
407       case CK_IntegralComplexCast:
408       case CK_IntegralComplexToFloatingComplex:
409       case CK_CPointerToObjCPointerCast:
410       case CK_BlockPointerToObjCPointerCast:
411       case CK_AnyPointerToBlockPointerCast:
412       case CK_ObjCObjectLValueCast:
413       case CK_ZeroToOCLOpaqueType:
414       case CK_IntToOCLSampler:
415       case CK_LValueBitCast:
416       case CK_FixedPointCast:
417       case CK_FixedPointToBoolean:
418       case CK_FixedPointToIntegral:
419       case CK_IntegralToFixedPoint: {
420         state =
421             handleLValueBitCast(state, Ex, LCtx, T, ExTy, CastE, Bldr, Pred);
422         continue;
423       }
424       case CK_IntegralCast: {
425         // Delegate to SValBuilder to process.
426         SVal V = state->getSVal(Ex, LCtx);
427         V = svalBuilder.evalIntegralCast(state, V, T, ExTy);
428         state = state->BindExpr(CastE, LCtx, V);
429         Bldr.generateNode(CastE, Pred, state);
430         continue;
431       }
432       case CK_DerivedToBase:
433       case CK_UncheckedDerivedToBase: {
434         // For DerivedToBase cast, delegate to the store manager.
435         SVal val = state->getSVal(Ex, LCtx);
436         val = getStoreManager().evalDerivedToBase(val, CastE);
437         state = state->BindExpr(CastE, LCtx, val);
438         Bldr.generateNode(CastE, Pred, state);
439         continue;
440       }
441       // Handle C++ dyn_cast.
442       case CK_Dynamic: {
443         SVal val = state->getSVal(Ex, LCtx);
444 
445         // Compute the type of the result.
446         QualType resultType = CastE->getType();
447         if (CastE->isGLValue())
448           resultType = getContext().getPointerType(resultType);
449 
450         bool Failed = false;
451 
452         // Check if the value being cast evaluates to 0.
453         if (val.isZeroConstant())
454           Failed = true;
455         // Else, evaluate the cast.
456         else
457           val = getStoreManager().attemptDownCast(val, T, Failed);
458 
459         if (Failed) {
460           if (T->isReferenceType()) {
461             // A bad_cast exception is thrown if input value is a reference.
462             // Currently, we model this, by generating a sink.
463             Bldr.generateSink(CastE, Pred, state);
464             continue;
465           } else {
466             // If the cast fails on a pointer, bind to 0.
467             state = state->BindExpr(CastE, LCtx, svalBuilder.makeNull());
468           }
469         } else {
470           // If we don't know if the cast succeeded, conjure a new symbol.
471           if (val.isUnknown()) {
472             DefinedOrUnknownSVal NewSym =
473               svalBuilder.conjureSymbolVal(nullptr, CastE, LCtx, resultType,
474                                            currBldrCtx->blockCount());
475             state = state->BindExpr(CastE, LCtx, NewSym);
476           } else
477             // Else, bind to the derived region value.
478             state = state->BindExpr(CastE, LCtx, val);
479         }
480         Bldr.generateNode(CastE, Pred, state);
481         continue;
482       }
483       case CK_BaseToDerived: {
484         SVal val = state->getSVal(Ex, LCtx);
485         QualType resultType = CastE->getType();
486         if (CastE->isGLValue())
487           resultType = getContext().getPointerType(resultType);
488 
489         bool Failed = false;
490 
491         if (!val.isConstant()) {
492           val = getStoreManager().attemptDownCast(val, T, Failed);
493         }
494 
495         // Failed to cast or the result is unknown, fall back to conservative.
496         if (Failed || val.isUnknown()) {
497           val =
498             svalBuilder.conjureSymbolVal(nullptr, CastE, LCtx, resultType,
499                                          currBldrCtx->blockCount());
500         }
501         state = state->BindExpr(CastE, LCtx, val);
502         Bldr.generateNode(CastE, Pred, state);
503         continue;
504       }
505       case CK_NullToPointer: {
506         SVal V = svalBuilder.makeNull();
507         state = state->BindExpr(CastE, LCtx, V);
508         Bldr.generateNode(CastE, Pred, state);
509         continue;
510       }
511       case CK_NullToMemberPointer: {
512         SVal V = svalBuilder.getMemberPointer(nullptr);
513         state = state->BindExpr(CastE, LCtx, V);
514         Bldr.generateNode(CastE, Pred, state);
515         continue;
516       }
517       case CK_DerivedToBaseMemberPointer:
518       case CK_BaseToDerivedMemberPointer:
519       case CK_ReinterpretMemberPointer: {
520         SVal V = state->getSVal(Ex, LCtx);
521         if (auto PTMSV = V.getAs<nonloc::PointerToMember>()) {
522           SVal CastedPTMSV = svalBuilder.makePointerToMember(
523               getBasicVals().accumCXXBase(
524                   llvm::make_range<CastExpr::path_const_iterator>(
525                       CastE->path_begin(), CastE->path_end()), *PTMSV));
526           state = state->BindExpr(CastE, LCtx, CastedPTMSV);
527           Bldr.generateNode(CastE, Pred, state);
528           continue;
529         }
530         // Explicitly proceed with default handler for this case cascade.
531         state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
532         continue;
533       }
534       // Various C++ casts that are not handled yet.
535       case CK_ToUnion:
536       case CK_VectorSplat: {
537         state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
538         continue;
539       }
540     }
541   }
542 }
543 
544 void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL,
545                                           ExplodedNode *Pred,
546                                           ExplodedNodeSet &Dst) {
547   StmtNodeBuilder B(Pred, Dst, *currBldrCtx);
548 
549   ProgramStateRef State = Pred->getState();
550   const LocationContext *LCtx = Pred->getLocationContext();
551 
552   const Expr *Init = CL->getInitializer();
553   SVal V = State->getSVal(CL->getInitializer(), LCtx);
554 
555   if (isa<CXXConstructExpr>(Init) || isa<CXXStdInitializerListExpr>(Init)) {
556     // No work needed. Just pass the value up to this expression.
557   } else {
558     assert(isa<InitListExpr>(Init));
559     Loc CLLoc = State->getLValue(CL, LCtx);
560     State = State->bindLoc(CLLoc, V, LCtx);
561 
562     if (CL->isGLValue())
563       V = CLLoc;
564   }
565 
566   B.generateNode(CL, Pred, State->BindExpr(CL, LCtx, V));
567 }
568 
569 void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
570                                ExplodedNodeSet &Dst) {
571   // Assumption: The CFG has one DeclStmt per Decl.
572   const VarDecl *VD = dyn_cast_or_null<VarDecl>(*DS->decl_begin());
573 
574   if (!VD) {
575     //TODO:AZ: remove explicit insertion after refactoring is done.
576     Dst.insert(Pred);
577     return;
578   }
579 
580   // FIXME: all pre/post visits should eventually be handled by ::Visit().
581   ExplodedNodeSet dstPreVisit;
582   getCheckerManager().runCheckersForPreStmt(dstPreVisit, Pred, DS, *this);
583 
584   ExplodedNodeSet dstEvaluated;
585   StmtNodeBuilder B(dstPreVisit, dstEvaluated, *currBldrCtx);
586   for (ExplodedNodeSet::iterator I = dstPreVisit.begin(), E = dstPreVisit.end();
587        I!=E; ++I) {
588     ExplodedNode *N = *I;
589     ProgramStateRef state = N->getState();
590     const LocationContext *LC = N->getLocationContext();
591 
592     // Decls without InitExpr are not initialized explicitly.
593     if (const Expr *InitEx = VD->getInit()) {
594 
595       // Note in the state that the initialization has occurred.
596       ExplodedNode *UpdatedN = N;
597       SVal InitVal = state->getSVal(InitEx, LC);
598 
599       assert(DS->isSingleDecl());
600       if (getObjectUnderConstruction(state, DS, LC)) {
601         state = finishObjectConstruction(state, DS, LC);
602         // We constructed the object directly in the variable.
603         // No need to bind anything.
604         B.generateNode(DS, UpdatedN, state);
605       } else {
606         // Recover some path-sensitivity if a scalar value evaluated to
607         // UnknownVal.
608         if (InitVal.isUnknown()) {
609           QualType Ty = InitEx->getType();
610           if (InitEx->isGLValue()) {
611             Ty = getContext().getPointerType(Ty);
612           }
613 
614           InitVal = svalBuilder.conjureSymbolVal(nullptr, InitEx, LC, Ty,
615                                                  currBldrCtx->blockCount());
616         }
617 
618 
619         B.takeNodes(UpdatedN);
620         ExplodedNodeSet Dst2;
621         evalBind(Dst2, DS, UpdatedN, state->getLValue(VD, LC), InitVal, true);
622         B.addNodes(Dst2);
623       }
624     }
625     else {
626       B.generateNode(DS, N, state);
627     }
628   }
629 
630   getCheckerManager().runCheckersForPostStmt(Dst, B.getResults(), DS, *this);
631 }
632 
633 void ExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred,
634                                   ExplodedNodeSet &Dst) {
635   // This method acts upon CFG elements for logical operators && and ||
636   // and attaches the value (true or false) to them as expressions.
637   // It doesn't produce any state splits.
638   // If we made it that far, we're past the point when we modeled the short
639   // circuit. It means that we should have precise knowledge about whether
640   // we've short-circuited. If we did, we already know the value we need to
641   // bind. If we didn't, the value of the RHS (casted to the boolean type)
642   // is the answer.
643   // Currently this method tries to figure out whether we've short-circuited
644   // by looking at the ExplodedGraph. This method is imperfect because there
645   // could inevitably have been merges that would have resulted in multiple
646   // potential path traversal histories. We bail out when we fail.
647   // Due to this ambiguity, a more reliable solution would have been to
648   // track the short circuit operation history path-sensitively until
649   // we evaluate the respective logical operator.
650   assert(B->getOpcode() == BO_LAnd ||
651          B->getOpcode() == BO_LOr);
652 
653   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
654   ProgramStateRef state = Pred->getState();
655 
656   if (B->getType()->isVectorType()) {
657     // FIXME: We do not model vector arithmetic yet. When adding support for
658     // that, note that the CFG-based reasoning below does not apply, because
659     // logical operators on vectors are not short-circuit. Currently they are
660     // modeled as short-circuit in Clang CFG but this is incorrect.
661     // Do not set the value for the expression. It'd be UnknownVal by default.
662     Bldr.generateNode(B, Pred, state);
663     return;
664   }
665 
666   ExplodedNode *N = Pred;
667   while (!N->getLocation().getAs<BlockEntrance>()) {
668     ProgramPoint P = N->getLocation();
669     assert(P.getAs<PreStmt>()|| P.getAs<PreStmtPurgeDeadSymbols>());
670     (void) P;
671     if (N->pred_size() != 1) {
672       // We failed to track back where we came from.
673       Bldr.generateNode(B, Pred, state);
674       return;
675     }
676     N = *N->pred_begin();
677   }
678 
679   if (N->pred_size() != 1) {
680     // We failed to track back where we came from.
681     Bldr.generateNode(B, Pred, state);
682     return;
683   }
684 
685   N = *N->pred_begin();
686   BlockEdge BE = N->getLocation().castAs<BlockEdge>();
687   SVal X;
688 
689   // Determine the value of the expression by introspecting how we
690   // got this location in the CFG.  This requires looking at the previous
691   // block we were in and what kind of control-flow transfer was involved.
692   const CFGBlock *SrcBlock = BE.getSrc();
693   // The only terminator (if there is one) that makes sense is a logical op.
694   CFGTerminator T = SrcBlock->getTerminator();
695   if (const BinaryOperator *Term = cast_or_null<BinaryOperator>(T.getStmt())) {
696     (void) Term;
697     assert(Term->isLogicalOp());
698     assert(SrcBlock->succ_size() == 2);
699     // Did we take the true or false branch?
700     unsigned constant = (*SrcBlock->succ_begin() == BE.getDst()) ? 1 : 0;
701     X = svalBuilder.makeIntVal(constant, B->getType());
702   }
703   else {
704     // If there is no terminator, by construction the last statement
705     // in SrcBlock is the value of the enclosing expression.
706     // However, we still need to constrain that value to be 0 or 1.
707     assert(!SrcBlock->empty());
708     CFGStmt Elem = SrcBlock->rbegin()->castAs<CFGStmt>();
709     const Expr *RHS = cast<Expr>(Elem.getStmt());
710     SVal RHSVal = N->getState()->getSVal(RHS, Pred->getLocationContext());
711 
712     if (RHSVal.isUndef()) {
713       X = RHSVal;
714     } else {
715       // We evaluate "RHSVal != 0" expression which result in 0 if the value is
716       // known to be false, 1 if the value is known to be true and a new symbol
717       // when the assumption is unknown.
718       nonloc::ConcreteInt Zero(getBasicVals().getValue(0, B->getType()));
719       X = evalBinOp(N->getState(), BO_NE,
720                     svalBuilder.evalCast(RHSVal, B->getType(), RHS->getType()),
721                     Zero, B->getType());
722     }
723   }
724   Bldr.generateNode(B, Pred, state->BindExpr(B, Pred->getLocationContext(), X));
725 }
726 
727 void ExprEngine::VisitInitListExpr(const InitListExpr *IE,
728                                    ExplodedNode *Pred,
729                                    ExplodedNodeSet &Dst) {
730   StmtNodeBuilder B(Pred, Dst, *currBldrCtx);
731 
732   ProgramStateRef state = Pred->getState();
733   const LocationContext *LCtx = Pred->getLocationContext();
734   QualType T = getContext().getCanonicalType(IE->getType());
735   unsigned NumInitElements = IE->getNumInits();
736 
737   if (!IE->isGLValue() && !IE->isTransparent() &&
738       (T->isArrayType() || T->isRecordType() || T->isVectorType() ||
739        T->isAnyComplexType())) {
740     llvm::ImmutableList<SVal> vals = getBasicVals().getEmptySValList();
741 
742     // Handle base case where the initializer has no elements.
743     // e.g: static int* myArray[] = {};
744     if (NumInitElements == 0) {
745       SVal V = svalBuilder.makeCompoundVal(T, vals);
746       B.generateNode(IE, Pred, state->BindExpr(IE, LCtx, V));
747       return;
748     }
749 
750     for (InitListExpr::const_reverse_iterator it = IE->rbegin(),
751          ei = IE->rend(); it != ei; ++it) {
752       SVal V = state->getSVal(cast<Expr>(*it), LCtx);
753       vals = getBasicVals().prependSVal(V, vals);
754     }
755 
756     B.generateNode(IE, Pred,
757                    state->BindExpr(IE, LCtx,
758                                    svalBuilder.makeCompoundVal(T, vals)));
759     return;
760   }
761 
762   // Handle scalars: int{5} and int{} and GLvalues.
763   // Note, if the InitListExpr is a GLvalue, it means that there is an address
764   // representing it, so it must have a single init element.
765   assert(NumInitElements <= 1);
766 
767   SVal V;
768   if (NumInitElements == 0)
769     V = getSValBuilder().makeZeroVal(T);
770   else
771     V = state->getSVal(IE->getInit(0), LCtx);
772 
773   B.generateNode(IE, Pred, state->BindExpr(IE, LCtx, V));
774 }
775 
776 void ExprEngine::VisitGuardedExpr(const Expr *Ex,
777                                   const Expr *L,
778                                   const Expr *R,
779                                   ExplodedNode *Pred,
780                                   ExplodedNodeSet &Dst) {
781   assert(L && R);
782 
783   StmtNodeBuilder B(Pred, Dst, *currBldrCtx);
784   ProgramStateRef state = Pred->getState();
785   const LocationContext *LCtx = Pred->getLocationContext();
786   const CFGBlock *SrcBlock = nullptr;
787 
788   // Find the predecessor block.
789   ProgramStateRef SrcState = state;
790   for (const ExplodedNode *N = Pred ; N ; N = *N->pred_begin()) {
791     ProgramPoint PP = N->getLocation();
792     if (PP.getAs<PreStmtPurgeDeadSymbols>() || PP.getAs<BlockEntrance>()) {
793       // If the state N has multiple predecessors P, it means that successors
794       // of P are all equivalent.
795       // In turn, that means that all nodes at P are equivalent in terms
796       // of observable behavior at N, and we can follow any of them.
797       // FIXME: a more robust solution which does not walk up the tree.
798       continue;
799     }
800     SrcBlock = PP.castAs<BlockEdge>().getSrc();
801     SrcState = N->getState();
802     break;
803   }
804 
805   assert(SrcBlock && "missing function entry");
806 
807   // Find the last expression in the predecessor block.  That is the
808   // expression that is used for the value of the ternary expression.
809   bool hasValue = false;
810   SVal V;
811 
812   for (CFGElement CE : llvm::reverse(*SrcBlock)) {
813     if (Optional<CFGStmt> CS = CE.getAs<CFGStmt>()) {
814       const Expr *ValEx = cast<Expr>(CS->getStmt());
815       ValEx = ValEx->IgnoreParens();
816 
817       // For GNU extension '?:' operator, the left hand side will be an
818       // OpaqueValueExpr, so get the underlying expression.
819       if (const OpaqueValueExpr *OpaqueEx = dyn_cast<OpaqueValueExpr>(L))
820         L = OpaqueEx->getSourceExpr();
821 
822       // If the last expression in the predecessor block matches true or false
823       // subexpression, get its the value.
824       if (ValEx == L->IgnoreParens() || ValEx == R->IgnoreParens()) {
825         hasValue = true;
826         V = SrcState->getSVal(ValEx, LCtx);
827       }
828       break;
829     }
830   }
831 
832   if (!hasValue)
833     V = svalBuilder.conjureSymbolVal(nullptr, Ex, LCtx,
834                                      currBldrCtx->blockCount());
835 
836   // Generate a new node with the binding from the appropriate path.
837   B.generateNode(Ex, Pred, state->BindExpr(Ex, LCtx, V, true));
838 }
839 
840 void ExprEngine::
841 VisitOffsetOfExpr(const OffsetOfExpr *OOE,
842                   ExplodedNode *Pred, ExplodedNodeSet &Dst) {
843   StmtNodeBuilder B(Pred, Dst, *currBldrCtx);
844   Expr::EvalResult Result;
845   if (OOE->EvaluateAsInt(Result, getContext())) {
846     APSInt IV = Result.Val.getInt();
847     assert(IV.getBitWidth() == getContext().getTypeSize(OOE->getType()));
848     assert(OOE->getType()->isBuiltinType());
849     assert(OOE->getType()->getAs<BuiltinType>()->isInteger());
850     assert(IV.isSigned() == OOE->getType()->isSignedIntegerType());
851     SVal X = svalBuilder.makeIntVal(IV);
852     B.generateNode(OOE, Pred,
853                    Pred->getState()->BindExpr(OOE, Pred->getLocationContext(),
854                                               X));
855   }
856   // FIXME: Handle the case where __builtin_offsetof is not a constant.
857 }
858 
859 
860 void ExprEngine::
861 VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Ex,
862                               ExplodedNode *Pred,
863                               ExplodedNodeSet &Dst) {
864   // FIXME: Prechecks eventually go in ::Visit().
865   ExplodedNodeSet CheckedSet;
866   getCheckerManager().runCheckersForPreStmt(CheckedSet, Pred, Ex, *this);
867 
868   ExplodedNodeSet EvalSet;
869   StmtNodeBuilder Bldr(CheckedSet, EvalSet, *currBldrCtx);
870 
871   QualType T = Ex->getTypeOfArgument();
872 
873   for (ExplodedNodeSet::iterator I = CheckedSet.begin(), E = CheckedSet.end();
874        I != E; ++I) {
875     if (Ex->getKind() == UETT_SizeOf) {
876       if (!T->isIncompleteType() && !T->isConstantSizeType()) {
877         assert(T->isVariableArrayType() && "Unknown non-constant-sized type.");
878 
879         // FIXME: Add support for VLA type arguments and VLA expressions.
880         // When that happens, we should probably refactor VLASizeChecker's code.
881         continue;
882       } else if (T->getAs<ObjCObjectType>()) {
883         // Some code tries to take the sizeof an ObjCObjectType, relying that
884         // the compiler has laid out its representation.  Just report Unknown
885         // for these.
886         continue;
887       }
888     }
889 
890     APSInt Value = Ex->EvaluateKnownConstInt(getContext());
891     CharUnits amt = CharUnits::fromQuantity(Value.getZExtValue());
892 
893     ProgramStateRef state = (*I)->getState();
894     state = state->BindExpr(Ex, (*I)->getLocationContext(),
895                             svalBuilder.makeIntVal(amt.getQuantity(),
896                                                    Ex->getType()));
897     Bldr.generateNode(Ex, *I, state);
898   }
899 
900   getCheckerManager().runCheckersForPostStmt(Dst, EvalSet, Ex, *this);
901 }
902 
903 void ExprEngine::handleUOExtension(ExplodedNodeSet::iterator I,
904                                    const UnaryOperator *U,
905                                    StmtNodeBuilder &Bldr) {
906   // FIXME: We can probably just have some magic in Environment::getSVal()
907   // that propagates values, instead of creating a new node here.
908   //
909   // Unary "+" is a no-op, similar to a parentheses.  We still have places
910   // where it may be a block-level expression, so we need to
911   // generate an extra node that just propagates the value of the
912   // subexpression.
913   const Expr *Ex = U->getSubExpr()->IgnoreParens();
914   ProgramStateRef state = (*I)->getState();
915   const LocationContext *LCtx = (*I)->getLocationContext();
916   Bldr.generateNode(U, *I, state->BindExpr(U, LCtx,
917                                            state->getSVal(Ex, LCtx)));
918 }
919 
920 void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, ExplodedNode *Pred,
921                                     ExplodedNodeSet &Dst) {
922   // FIXME: Prechecks eventually go in ::Visit().
923   ExplodedNodeSet CheckedSet;
924   getCheckerManager().runCheckersForPreStmt(CheckedSet, Pred, U, *this);
925 
926   ExplodedNodeSet EvalSet;
927   StmtNodeBuilder Bldr(CheckedSet, EvalSet, *currBldrCtx);
928 
929   for (ExplodedNodeSet::iterator I = CheckedSet.begin(), E = CheckedSet.end();
930        I != E; ++I) {
931     switch (U->getOpcode()) {
932     default: {
933       Bldr.takeNodes(*I);
934       ExplodedNodeSet Tmp;
935       VisitIncrementDecrementOperator(U, *I, Tmp);
936       Bldr.addNodes(Tmp);
937       break;
938     }
939     case UO_Real: {
940       const Expr *Ex = U->getSubExpr()->IgnoreParens();
941 
942       // FIXME: We don't have complex SValues yet.
943       if (Ex->getType()->isAnyComplexType()) {
944         // Just report "Unknown."
945         break;
946       }
947 
948       // For all other types, UO_Real is an identity operation.
949       assert (U->getType() == Ex->getType());
950       ProgramStateRef state = (*I)->getState();
951       const LocationContext *LCtx = (*I)->getLocationContext();
952       Bldr.generateNode(U, *I, state->BindExpr(U, LCtx,
953                                                state->getSVal(Ex, LCtx)));
954       break;
955     }
956 
957     case UO_Imag: {
958       const Expr *Ex = U->getSubExpr()->IgnoreParens();
959       // FIXME: We don't have complex SValues yet.
960       if (Ex->getType()->isAnyComplexType()) {
961         // Just report "Unknown."
962         break;
963       }
964       // For all other types, UO_Imag returns 0.
965       ProgramStateRef state = (*I)->getState();
966       const LocationContext *LCtx = (*I)->getLocationContext();
967       SVal X = svalBuilder.makeZeroVal(Ex->getType());
968       Bldr.generateNode(U, *I, state->BindExpr(U, LCtx, X));
969       break;
970     }
971 
972     case UO_AddrOf: {
973       // Process pointer-to-member address operation.
974       const Expr *Ex = U->getSubExpr()->IgnoreParens();
975       if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Ex)) {
976         const ValueDecl *VD = DRE->getDecl();
977 
978         if (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD)) {
979           ProgramStateRef State = (*I)->getState();
980           const LocationContext *LCtx = (*I)->getLocationContext();
981           SVal SV = svalBuilder.getMemberPointer(cast<DeclaratorDecl>(VD));
982           Bldr.generateNode(U, *I, State->BindExpr(U, LCtx, SV));
983           break;
984         }
985       }
986       // Explicitly proceed with default handler for this case cascade.
987       handleUOExtension(I, U, Bldr);
988       break;
989     }
990     case UO_Plus:
991       assert(!U->isGLValue());
992       LLVM_FALLTHROUGH;
993     case UO_Deref:
994     case UO_Extension: {
995       handleUOExtension(I, U, Bldr);
996       break;
997     }
998 
999     case UO_LNot:
1000     case UO_Minus:
1001     case UO_Not: {
1002       assert (!U->isGLValue());
1003       const Expr *Ex = U->getSubExpr()->IgnoreParens();
1004       ProgramStateRef state = (*I)->getState();
1005       const LocationContext *LCtx = (*I)->getLocationContext();
1006 
1007       // Get the value of the subexpression.
1008       SVal V = state->getSVal(Ex, LCtx);
1009 
1010       if (V.isUnknownOrUndef()) {
1011         Bldr.generateNode(U, *I, state->BindExpr(U, LCtx, V));
1012         break;
1013       }
1014 
1015       switch (U->getOpcode()) {
1016         default:
1017           llvm_unreachable("Invalid Opcode.");
1018         case UO_Not:
1019           // FIXME: Do we need to handle promotions?
1020           state = state->BindExpr(U, LCtx, evalComplement(V.castAs<NonLoc>()));
1021           break;
1022         case UO_Minus:
1023           // FIXME: Do we need to handle promotions?
1024           state = state->BindExpr(U, LCtx, evalMinus(V.castAs<NonLoc>()));
1025           break;
1026         case UO_LNot:
1027           // C99 6.5.3.3: "The expression !E is equivalent to (0==E)."
1028           //
1029           //  Note: technically we do "E == 0", but this is the same in the
1030           //    transfer functions as "0 == E".
1031           SVal Result;
1032           if (Optional<Loc> LV = V.getAs<Loc>()) {
1033             Loc X = svalBuilder.makeNullWithType(Ex->getType());
1034             Result = evalBinOp(state, BO_EQ, *LV, X, U->getType());
1035           } else if (Ex->getType()->isFloatingType()) {
1036             // FIXME: handle floating point types.
1037             Result = UnknownVal();
1038           } else {
1039             nonloc::ConcreteInt X(getBasicVals().getValue(0, Ex->getType()));
1040             Result = evalBinOp(state, BO_EQ, V.castAs<NonLoc>(), X,
1041                                U->getType());
1042           }
1043 
1044           state = state->BindExpr(U, LCtx, Result);
1045           break;
1046       }
1047       Bldr.generateNode(U, *I, state);
1048       break;
1049     }
1050     }
1051   }
1052 
1053   getCheckerManager().runCheckersForPostStmt(Dst, EvalSet, U, *this);
1054 }
1055 
1056 void ExprEngine::VisitIncrementDecrementOperator(const UnaryOperator* U,
1057                                                  ExplodedNode *Pred,
1058                                                  ExplodedNodeSet &Dst) {
1059   // Handle ++ and -- (both pre- and post-increment).
1060   assert (U->isIncrementDecrementOp());
1061   const Expr *Ex = U->getSubExpr()->IgnoreParens();
1062 
1063   const LocationContext *LCtx = Pred->getLocationContext();
1064   ProgramStateRef state = Pred->getState();
1065   SVal loc = state->getSVal(Ex, LCtx);
1066 
1067   // Perform a load.
1068   ExplodedNodeSet Tmp;
1069   evalLoad(Tmp, U, Ex, Pred, state, loc);
1070 
1071   ExplodedNodeSet Dst2;
1072   StmtNodeBuilder Bldr(Tmp, Dst2, *currBldrCtx);
1073   for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end();I!=E;++I) {
1074 
1075     state = (*I)->getState();
1076     assert(LCtx == (*I)->getLocationContext());
1077     SVal V2_untested = state->getSVal(Ex, LCtx);
1078 
1079     // Propagate unknown and undefined values.
1080     if (V2_untested.isUnknownOrUndef()) {
1081       state = state->BindExpr(U, LCtx, V2_untested);
1082 
1083       // Perform the store, so that the uninitialized value detection happens.
1084       Bldr.takeNodes(*I);
1085       ExplodedNodeSet Dst3;
1086       evalStore(Dst3, U, Ex, *I, state, loc, V2_untested);
1087       Bldr.addNodes(Dst3);
1088 
1089       continue;
1090     }
1091     DefinedSVal V2 = V2_untested.castAs<DefinedSVal>();
1092 
1093     // Handle all other values.
1094     BinaryOperator::Opcode Op = U->isIncrementOp() ? BO_Add : BO_Sub;
1095 
1096     // If the UnaryOperator has non-location type, use its type to create the
1097     // constant value. If the UnaryOperator has location type, create the
1098     // constant with int type and pointer width.
1099     SVal RHS;
1100     SVal Result;
1101 
1102     if (U->getType()->isAnyPointerType())
1103       RHS = svalBuilder.makeArrayIndex(1);
1104     else if (U->getType()->isIntegralOrEnumerationType())
1105       RHS = svalBuilder.makeIntVal(1, U->getType());
1106     else
1107       RHS = UnknownVal();
1108 
1109     // The use of an operand of type bool with the ++ operators is deprecated
1110     // but valid until C++17. And if the operand of the ++ operator is of type
1111     // bool, it is set to true until C++17. Note that for '_Bool', it is also
1112     // set to true when it encounters ++ operator.
1113     if (U->getType()->isBooleanType() && U->isIncrementOp())
1114       Result = svalBuilder.makeTruthVal(true, U->getType());
1115     else
1116       Result = evalBinOp(state, Op, V2, RHS, U->getType());
1117 
1118     // Conjure a new symbol if necessary to recover precision.
1119     if (Result.isUnknown()){
1120       DefinedOrUnknownSVal SymVal =
1121         svalBuilder.conjureSymbolVal(nullptr, U, LCtx,
1122                                      currBldrCtx->blockCount());
1123       Result = SymVal;
1124 
1125       // If the value is a location, ++/-- should always preserve
1126       // non-nullness.  Check if the original value was non-null, and if so
1127       // propagate that constraint.
1128       if (Loc::isLocType(U->getType())) {
1129         DefinedOrUnknownSVal Constraint =
1130         svalBuilder.evalEQ(state, V2,svalBuilder.makeZeroVal(U->getType()));
1131 
1132         if (!state->assume(Constraint, true)) {
1133           // It isn't feasible for the original value to be null.
1134           // Propagate this constraint.
1135           Constraint = svalBuilder.evalEQ(state, SymVal,
1136                                        svalBuilder.makeZeroVal(U->getType()));
1137 
1138           state = state->assume(Constraint, false);
1139           assert(state);
1140         }
1141       }
1142     }
1143 
1144     // Since the lvalue-to-rvalue conversion is explicit in the AST,
1145     // we bind an l-value if the operator is prefix and an lvalue (in C++).
1146     if (U->isGLValue())
1147       state = state->BindExpr(U, LCtx, loc);
1148     else
1149       state = state->BindExpr(U, LCtx, U->isPostfix() ? V2 : Result);
1150 
1151     // Perform the store.
1152     Bldr.takeNodes(*I);
1153     ExplodedNodeSet Dst3;
1154     evalStore(Dst3, U, Ex, *I, state, loc, Result);
1155     Bldr.addNodes(Dst3);
1156   }
1157   Dst.insert(Dst2);
1158 }
1159