[clang] [StaticAnalyzer] Fix state update in VisitObjCForCollectionStmt (PR #124477)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 03:15:25 PST 2025


================
@@ -124,24 +124,26 @@ void ExprEngine::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S,
 
   bool isContainerNull = state->isNull(collectionV).isConstrainedTrue();
 
-  ExplodedNodeSet dstLocation;
-  evalLocation(dstLocation, S, elem, Pred, state, elementV, false);
+  ExplodedNodeSet NewPreds; // evalLocation may alter `Pred`
+  evalLocation(NewPreds, S, elem, Pred, state, elementV, false);
 
-  ExplodedNodeSet Tmp;
-  StmtNodeBuilder Bldr(Pred, Tmp, *currBldrCtx);
+  for (ExplodedNode *Pred : NewPreds) {
----------------
steakhal wrote:

I wish we wouldn't shadow `Pred` here.
Maybe if we are iterating a collection called `NewPreds`, a variable `NewPred` would be a better, non-shadowing name.

https://github.com/llvm/llvm-project/pull/124477


More information about the cfe-commits mailing list