ExprEngineC.cpp 39 KB

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