[PATCH] D154833: [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 10 06:43:26 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bc13c884727: [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154833/new/

https://reviews.llvm.org/D154833

Files:
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h


Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===================================================================
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -143,6 +143,12 @@
     BuiltinOptions = std::move(Options);
     return std::move(*this);
   }
+  AnalysisInputs<AnalysisT> &&
+  withSolverFactory(std::function<std::unique_ptr<Solver>()> Factory) && {
+    assert(Factory);
+    SolverFactory = std::move(Factory);
+    return std::move(*this);
+  }
 
   /// Required. Input code that is analyzed.
   llvm::StringRef Code;
@@ -170,6 +176,10 @@
   tooling::FileContentMappings ASTBuildVirtualMappedFiles = {};
   /// Configuration options for the built-in model.
   DataflowAnalysisContext::Options BuiltinOptions;
+  /// SAT solver factory.
+  std::function<std::unique_ptr<Solver>()> SolverFactory = [] {
+    return std::make_unique<WatchedLiteralsSolver>();
+  };
 };
 
 /// Returns assertions based on annotations that are present after statements in
@@ -248,7 +258,7 @@
     auto &CFCtx = *MaybeCFCtx;
 
     // Initialize states for running dataflow analysis.
-    DataflowAnalysisContext DACtx(std::make_unique<WatchedLiteralsSolver>(),
+    DataflowAnalysisContext DACtx(AI.SolverFactory(),
                                   {/*Opts=*/AI.BuiltinOptions});
     Environment InitEnv(DACtx, *Target);
     auto Analysis = AI.MakeAnalysis(Context, InitEnv);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154833.538618.patch
Type: text/x-patch
Size: 1468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230710/75baaeaf/attachment.bin>


More information about the cfe-commits mailing list