Author: DonĂ¡t Nagy Date: 2026-06-24T14:53:15+02:00 New Revision: 09939ace888b407dc984a7fc6c980fd6064a75c1
URL: https://github.com/llvm/llvm-project/commit/09939ace888b407dc984a7fc6c980fd6064a75c1 DIFF: https://github.com/llvm/llvm-project/commit/09939ace888b407dc984a7fc6c980fd6064a75c1.diff LOG: [NFC][analyzer] Remove the NodeBuilder from eagerly assume (#204371) Part of my commit series to gradually eliminate the class `NodeBuilder`. Admittedly this is one of the few places where the implementation with the `NodeBuilder` is more concise than the new code. This is caused by two factors: 1. This is an optional step in the analysis, so the "put source nodes in destination unless we generate a child node from them" behavior of `NodeBuilder` -- which is often completely useless -- was helpful on two branches. 2. Making nodes with tags is very rare, so I intentionally did not include support for tagging in `makeNodeWithBinding` -- but this is one of the few places where tags are applied. Added: Modified: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp Removed: ################################################################################ diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 4357f0fae4144..cfb294736ee02 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -3711,20 +3711,20 @@ REGISTER_TRAIT_WITH_PROGRAMSTATE(LastEagerlyAssumeExprIfSuccessful, void ExprEngine::evalEagerlyAssumeBifurcation(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, const Expr *Ex) { - NodeBuilder Bldr(Src, Dst, *currBldrCtx); - for (ExplodedNode *Pred : Src) { + const StackFrame *SF = Pred->getStackFrame(); // Test if the previous node was as the same expression. This can happen // when the expression fails to evaluate to anything meaningful and // (as an optimization) we don't generate a node. ProgramPoint P = Pred->getLocation(); if (!P.getAs<PostStmt>() || P.castAs<PostStmt>().getStmt() != Ex) { + Dst.insert(Pred); continue; } ProgramStateRef State = Pred->getState(); State = State->set<LastEagerlyAssumeExprIfSuccessful>(nullptr); - SVal V = State->getSVal(Ex, Pred->getStackFrame()); + SVal V = State->getSVal(Ex, SF); std::optional<nonloc::SymbolVal> SEV = V.getAs<nonloc::SymbolVal>(); if (SEV && SEV->isExpression()) { const auto &[TrueTag, FalseTag] = getEagerlyAssumeBifurcationTags(); @@ -3739,16 +3739,20 @@ void ExprEngine::evalEagerlyAssumeBifurcation(ExplodedNodeSet &Dst, // First assume that the condition is true. if (StateTrue) { SVal Val = svalBuilder.makeIntVal(1U, Ex->getType()); - StateTrue = StateTrue->BindExpr(Ex, Pred->getStackFrame(), Val); - Bldr.generateNode(Ex, Pred, StateTrue, TrueTag); + StateTrue = StateTrue->BindExpr(Ex, SF, Val); + PostStmt PostStmtTrue(Ex, SF, TrueTag); + Dst.insert(Engine.makeNode(PostStmtTrue, StateTrue, Pred)); } // Next, assume that the condition is false. if (StateFalse) { SVal Val = svalBuilder.makeIntVal(0U, Ex->getType()); - StateFalse = StateFalse->BindExpr(Ex, Pred->getStackFrame(), Val); - Bldr.generateNode(Ex, Pred, StateFalse, FalseTag); + StateFalse = StateFalse->BindExpr(Ex, SF, Val); + PostStmt PostStmtFalse(Ex, SF, FalseTag); + Dst.insert(Engine.makeNode(PostStmtFalse, StateFalse, Pred)); } + } else { + Dst.insert(Pred); } } } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
