================
@@ -233,6 +237,52 @@ class UnsafeBufferReachableAnalysis
 
       updateReachablesWithOutgoings(Node, Worklist);
     }
+  }
+
+public:
+  llvm::Error
+  initialize(const PointerFlowAnalysisResult &PtrFlowGraph,
+             const TypeConstrainedPointersAnalysisResult &TypeConstraints,
+             const UnsafeBufferUsageAnalysisResult &UnsafePtrs) override {
+    auto HasNoTypeConstraint =
+        [&TypeConstraints](const EntityPointerLevel &EPL) {
+          return !TypeConstraints.contains(EPL.getEntity());
+        };
+
+    // Filter out edges involving type-constrained pointers from 
`PtrFlowGraph`:
+    for (auto &[Id, SubGraph] : PtrFlowGraph.Edges) {
+      EdgeSet FilteredSubGraph;
+
+      for (const auto &[Src, Dsts] : SubGraph) {
+        if (TypeConstraints.contains(Src.getEntity()))
+          continue;
+
+        auto FilteredDstRange =
+            llvm::make_filter_range(Dsts, HasNoTypeConstraint);
+
+        if (!FilteredDstRange.empty())
+          FilteredSubGraph[Src].insert(FilteredDstRange.begin(),
+                                       FilteredDstRange.end());
+      }
+      if (!FilteredSubGraph.empty())
+        BPG.try_emplace(Id, std::move(FilteredSubGraph));
+    }
+
+    // Filter out type-constrained pointers from `UnsafePtrs`:
+    for (auto &[Contributor, EPLs] : UnsafePtrs) {
+      auto FilteredRange = llvm::make_filter_range(EPLs, HasNoTypeConstraint);
+
+      getResult().Reachables[Contributor].insert(FilteredRange.begin(),
+                                                 FilteredRange.end());
----------------
steakhal wrote:

If `FilteredRange` is empty, then this would construct an empty 
`Reachables[Contributor]`.
You intentionally avoided this for `FilteredSubGraph[Src]`. Is this intentional?

https://github.com/llvm/llvm-project/pull/209354
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to