mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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);


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);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to