This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG1defa781243f: [clang][dataflow] Add function to `WatchedLiteralsSolver` that reports whether… (authored by ymandel).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155636/new/ https://reviews.llvm.org/D155636 Files: clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h clang/unittests/Analysis/FlowSensitive/SolverTest.cpp Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp =================================================================== --- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp +++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp @@ -350,4 +350,23 @@ EXPECT_EQ(solver.solve({A, B}).getStatus(), Solver::Result::Status::TimedOut); } +TEST(SolverTest, ReachedLimitsReflectsTimeouts) { + WatchedLiteralsSolver solver(10); + ConstraintContext Ctx; + auto X = Ctx.atom(); + auto Y = Ctx.atom(); + auto Z = Ctx.atom(); + auto W = Ctx.atom(); + + // !(X v Y) <=> !X ^ !Y + auto A = Ctx.iff(Ctx.neg(Ctx.disj(X, Y)), Ctx.conj(Ctx.neg(X), Ctx.neg(Y))); + + // !(Z ^ W) <=> !Z v !W + auto B = Ctx.iff(Ctx.neg(Ctx.conj(Z, W)), Ctx.disj(Ctx.neg(Z), Ctx.neg(W))); + + // A ^ B + ASSERT_EQ(solver.solve({A, B}).getStatus(), Solver::Result::Status::TimedOut); + EXPECT_TRUE(solver.reachedLimit()); +} + } // namespace Index: clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h =================================================================== --- clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h +++ clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h @@ -47,6 +47,9 @@ : MaxIterations(WorkLimit) {} Result solve(llvm::ArrayRef<const Formula *> Vals) override; + + // The solver reached its maximum number of iterations. + bool reachedLimit() const { return MaxIterations == 0; } }; } // namespace dataflow
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp =================================================================== --- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp +++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp @@ -350,4 +350,23 @@ EXPECT_EQ(solver.solve({A, B}).getStatus(), Solver::Result::Status::TimedOut); } +TEST(SolverTest, ReachedLimitsReflectsTimeouts) { + WatchedLiteralsSolver solver(10); + ConstraintContext Ctx; + auto X = Ctx.atom(); + auto Y = Ctx.atom(); + auto Z = Ctx.atom(); + auto W = Ctx.atom(); + + // !(X v Y) <=> !X ^ !Y + auto A = Ctx.iff(Ctx.neg(Ctx.disj(X, Y)), Ctx.conj(Ctx.neg(X), Ctx.neg(Y))); + + // !(Z ^ W) <=> !Z v !W + auto B = Ctx.iff(Ctx.neg(Ctx.conj(Z, W)), Ctx.disj(Ctx.neg(Z), Ctx.neg(W))); + + // A ^ B + ASSERT_EQ(solver.solve({A, B}).getStatus(), Solver::Result::Status::TimedOut); + EXPECT_TRUE(solver.reachedLimit()); +} + } // namespace Index: clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h =================================================================== --- clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h +++ clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h @@ -47,6 +47,9 @@ : MaxIterations(WorkLimit) {} Result solve(llvm::ArrayRef<const Formula *> Vals) override; + + // The solver reached its maximum number of iterations. + bool reachedLimit() const { return MaxIterations == 0; } }; } // namespace dataflow
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits