[clang] [LifetimeSafety] Add multi-block support to buildOriginFlowChain (PR #204592)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 19 10:16:51 PDT 2026


================
@@ -145,12 +145,17 @@ void FactManager::dump(const CFG &Cfg, AnalysisDeclContext &AC) const {
 
 llvm::ArrayRef<const Fact *>
 FactManager::getBlockContaining(ProgramPoint P) const {
-  for (const auto &BlockToFactsVec : BlockToFacts) {
-    for (const Fact *F : BlockToFactsVec)
-      if (F == P)
-        return BlockToFactsVec;
-  }
+  std::optional<size_t> BlockIndex = getBlockID(P);
+  if (BlockIndex)
+    return BlockToFacts[BlockIndex.value()];
   return {};
 }
 
+std::optional<size_t> FactManager::getBlockID(ProgramPoint P) const {
+  for (size_t i = 0; i < BlockToFacts.size(); ++i)
+    for (const Fact *F : BlockToFacts[i])
+      if (F == P)
+        return i;
+  return std::nullopt;
----------------
usx95 wrote:

Can we ever have this ? If not, I would have llvm::unreachable here and remove the optional

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


More information about the cfe-commits mailing list