From: Mikhail R. Gadelha Date: Sat, 16 Jun 2018 14:36:17 +0000 (+0000) Subject: [analyzer] Add method to the generic SMT API to dump the SMT formula X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c36069cffc57a30a20782bf327a87bed4e48a6c2;p=clang [analyzer] Add method to the generic SMT API to dump the SMT formula Summary: New method dump the SMT formula and the Z3 implementation. There is no test because I only used it for debugging. However, if requested, I can add an option to the static analyzer to dump the formula (whole program? per path?), maybe something like the trimmed graph but for SMT formulas. Reviewers: NoQ, george.karpenkov, ddcc Reviewed By: george.karpenkov Subscribers: xazax.hun, szepet, a.sidorin Differential Revision: https://reviews.llvm.org/D48221 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334891 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h index 277f25d2c5..28e31896a7 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h @@ -35,6 +35,8 @@ public: /// Checks if the added constraints are satisfiable virtual clang::ento::ConditionTruthVal isModelFeasible() = 0; + /// Dumps SMT formula + LLVM_DUMP_METHOD virtual void dump() const = 0; }; // end class SMTConstraintManager } // namespace ento diff --git a/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp b/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp index dccd158489..0454825c6c 100644 --- a/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp +++ b/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp @@ -911,6 +911,8 @@ public: ConditionTruthVal isModelFeasible() override; + LLVM_DUMP_METHOD void dump() const override; + //===------------------------------------------------------------------===// // Implementation for interface from ConstraintManager. //===------------------------------------------------------------------===// @@ -1299,6 +1301,11 @@ clang::ento::ConditionTruthVal Z3ConstraintManager::isModelFeasible() { return ConditionTruthVal(); } +LLVM_DUMP_METHOD void Z3ConstraintManager::dump() const +{ + Solver.dump(); +} + //===------------------------------------------------------------------===// // Internal implementation. //===------------------------------------------------------------------===//