[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Thu May 15 06:17:52 PDT 2025


================
@@ -479,25 +479,20 @@ ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
     // in the trimmed graph, then add the corresponding edges with
     // `addPredecessor()`, otherwise add them to the worklist.
     for (const ExplodedNode *Pred : N->Preds) {
-      auto Iterator = ForwardMap->find(Pred);
-      if (Iterator != ForwardMap->end()) {
-        NewN->addPredecessor(const_cast<ExplodedNode *>(Iterator->second), *Trimmed);
-      } else {
+      if (const ExplodedNode *Mapped = ForwardMap->lookup(Pred))
+        NewN->addPredecessor(const_cast<ExplodedNode *>(Mapped), *Trimmed);
----------------
NagyDonat wrote:

I also had the same idea (`const_cast` is ugly) and I already implemented it before seeing your commit :grin:

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


More information about the cfe-commits mailing list