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

via cfe-commits cfe-commits at lists.llvm.org
Tue May 7 05:59:01 PDT 2024


Author: martinboehme
Date: 2024-05-07T14:58:57+02:00
New Revision: 66364e65405d4964709e67574abf1b519a55296c

URL: https://github.com/llvm/llvm-project/commit/66364e65405d4964709e67574abf1b519a55296c
DIFF: https://github.com/llvm/llvm-project/commit/66364e65405d4964709e67574abf1b519a55296c.diff

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

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

Added: 
    

Modified: 
    clang/include/clang/Analysis/FlowSensitive/Solver.h
    clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Analysis/FlowSensitive/Solver.h b/clang/include/clang/Analysis/FlowSensitive/Solver.h
index 079f6802f241e..6166a503ab413 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 5448eecf6d41a..b5cd7aa10fd7d 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