[clang] 8bc13c8 - [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.
Martin Braenne via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 10 06:43:22 PDT 2023
Author: Martin Braenne
Date: 2023-07-10T13:43:13Z
New Revision: 8bc13c884727f0b9be876303d654dd1eda300dc3
URL: https://github.com/llvm/llvm-project/commit/8bc13c884727f0b9be876303d654dd1eda300dc3
DIFF: https://github.com/llvm/llvm-project/commit/8bc13c884727f0b9be876303d654dd1eda300dc3.diff
LOG: [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D154833
Added:
Modified:
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
Removed:
################################################################################
diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index 93991d87d77f20..1568fc9a200e47 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -143,6 +143,12 @@ template <typename AnalysisT> struct AnalysisInputs {
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 @@ template <typename AnalysisT> struct AnalysisInputs {
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 @@ checkDataflow(AnalysisInputs<AnalysisT> AI,
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);
More information about the cfe-commits
mailing list