[clang] [clang][dataflow] Add `reachedLimit()` to the `Solver` interface. (PR #91320)

via cfe-commits cfe-commits at lists.llvm.org
Tue May 7 04:51:49 PDT 2024


https://github.com/martinboehme created https://github.com/llvm/llvm-project/pull/91320

We may want code to call this that doesn't know which specific solver
implementation it is dealing with.


>From bdd1d2698f3e592bf4ec33a6ff56be661ff4afb9 Mon Sep 17 00:00:00 2001
From: Martin Braenne <mboehme at google.com>
Date: Tue, 7 May 2024 11:50:41 +0000
Subject: [PATCH] [clang][dataflow] Add `reachedLimit()` to the `Solver`
 interface.

We may want code to call this that doesn't know which specific solver
implementation it is dealing with.
---
 clang/include/clang/Analysis/FlowSensitive/Solver.h            | 3 +++
 .../clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h       | 3 +--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/Solver.h b/clang/include/clang/Analysis/FlowSensitive/Solver.h
index 079f6802f241ee..6166a503ab413a 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Solver.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Solver.h
@@ -87,6 +87,9 @@ class Solver {
   ///
   ///  All elements in `Vals` must not be null.
   virtual Result solve(llvm::ArrayRef<const Formula *> Vals) = 0;
+
+  // Did the solver reach its resource limit?
+  virtual bool reachedLimit() const = 0;
 };
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Solver::Result &);
diff --git a/clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h b/clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
index 5448eecf6d41a2..b5cd7aa10fd7d2 100644
--- a/clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
+++ b/clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
@@ -48,8 +48,7 @@ class WatchedLiteralsSolver : public Solver {
 
   Result solve(llvm::ArrayRef<const Formula *> Vals) override;
 
-  // The solver reached its maximum number of iterations.
-  bool reachedLimit() const { return MaxIterations == 0; }
+  bool reachedLimit() const override { return MaxIterations == 0; }
 };
 
 } // namespace dataflow



More information about the cfe-commits mailing list