Coverage Report

Created: 2022-08-24 06:40

/src/solidity/libsmtutil/SMTPortfolio.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
  This file is part of solidity.
3
4
  solidity is free software: you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation, either version 3 of the License, or
7
  (at your option) any later version.
8
9
  solidity is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
14
  You should have received a copy of the GNU General Public License
15
  along with solidity.  If not, see <http://www.gnu.org/licenses/>.
16
*/
17
// SPDX-License-Identifier: GPL-3.0
18
19
#pragma once
20
21
22
#include <libsmtutil/SolverInterface.h>
23
#include <libsolidity/interface/ReadFile.h>
24
#include <libsolutil/FixedHash.h>
25
26
#include <map>
27
#include <vector>
28
29
namespace solidity::smtutil
30
{
31
32
/**
33
 * The SMTPortfolio wraps all available solvers within a single interface,
34
 * propagating the functionalities to all solvers.
35
 * It also checks whether different solvers give conflicting answers
36
 * to SMT queries.
37
 */
38
class SMTPortfolio: public SolverInterface
39
{
40
public:
41
  /// Noncopyable.
42
  SMTPortfolio(SMTPortfolio const&) = delete;
43
  SMTPortfolio& operator=(SMTPortfolio const&) = delete;
44
45
  SMTPortfolio(
46
    std::map<util::h256, std::string> _smtlib2Responses = {},
47
    frontend::ReadCallback::Callback _smtCallback = {},
48
    SMTSolverChoice _enabledSolvers = SMTSolverChoice::All(),
49
    std::optional<unsigned> _queryTimeout = {}
50
  );
51
52
  void reset() override;
53
54
  void push() override;
55
  void pop() override;
56
57
  void declareVariable(std::string const&, SortPointer const&) override;
58
59
  void addAssertion(Expression const& _expr) override;
60
61
  std::pair<CheckResult, std::vector<std::string>> check(std::vector<Expression> const& _expressionsToEvaluate) override;
62
63
  std::vector<std::string> unhandledQueries() override;
64
0
  size_t solvers() override { return m_solvers.size(); }
65
private:
66
  static bool solverAnswered(CheckResult result);
67
68
  std::vector<std::unique_ptr<SolverInterface>> m_solvers;
69
70
  std::vector<Expression> m_assertions;
71
};
72
73
}