[clang] [NFC][analyzer] Refactor switch handling in the engine (PR #178678)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 29 07:37:49 PST 2026


================
@@ -449,10 +449,7 @@ void CoreEngine::HandleBlockExit(const CFGBlock * B, ExplodedNode *Pred) {
         return;
 
       case Stmt::SwitchStmtClass: {
-        SwitchNodeBuilder builder(Pred, B, cast<SwitchStmt>(Term)->getCond(),
-                                    this);
-
-        ExprEng.processSwitch(builder);
+        ExprEng.processSwitch(cast<SwitchStmt>(Term), *this, B, Pred);
----------------
NagyDonat wrote:

I'm not sure what would be the natural order of arguments in this method. Ending the argument list with `B` (the `CFGBlock` and `Pred` (the `ExplodedNode`) is modeled after `HandleBranch`, but I'm also open to changing those.

I had an attempted rewrite where I would "pack" `*this`, `B` and `Pred` into a single `NodeBuilderContext` (because `NodeBuilderContext` is _almost_ a `CoreEngine*` + `CFGBlock` + `ExplodedNode` triple), but I couldn't quite make it work. (It seems that `NodeBuilderContext` only stores a `LocationContext` and not an `ExplodedNode`. )

Note that `ExprEngine::processBranch` takes a `NodeBuilderContext` (which is initialized in `CoreEngine::HandleBlock`, but  `BranchNodeBuilder` is not derived from `NodeBuilder` so it is not designed to "work together well" with a `NodeBuilderContext`.

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


More information about the cfe-commits mailing list