CBMC
smt_logics.h
Go to the documentation of this file.
1 // Author: Diffblue Ltd.
2 
3 #ifndef CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_LOGICS_H
4 #define CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_LOGICS_H
5 
7 
8 #include <util/irep.h>
9 
10 class smt_logict : protected irept
11 {
12 public:
13  // smt_logict does not support the notion of an empty / null state. Use
14  // std::optional<smt_logict> instead if an empty logic is required.
15  smt_logict() = delete;
16 
17  using irept::pretty;
18 
19  bool operator==(const smt_logict &) const;
20  bool operator!=(const smt_logict &) const;
21 
24 
30  template <typename derivedt>
31  class storert
32  {
33  protected:
35  static irept upcast(smt_logict logic);
36  static const smt_logict &downcast(const irept &);
37  };
38 
39 protected:
40  using irept::irept;
41 };
42 
43 template <typename derivedt>
45 {
46  static_assert(
47  std::is_base_of<irept, derivedt>::value &&
48  std::is_base_of<storert<derivedt>, derivedt>::value,
49  "Only irept based classes need to upcast smt_termt to store it.");
50 }
51 
52 template <typename derivedt>
54 {
55  return static_cast<irept &&>(std::move(logic));
56 }
57 
58 template <typename derivedt>
60 {
61  return static_cast<const smt_logict &>(irep);
62 }
63 
64 #define LOGIC_ID(the_id, the_name) \
65  /* NOLINTNEXTLINE(readability/identifiers) cpplint does not match the ## */ \
66  class smt_logic_##the_id##t : public smt_logict \
67  { \
68  public: \
69  smt_logic_##the_id##t(); \
70  };
71 #include "smt_logics.def"
72 #undef LOGIC_ID
73 
75 {
76 public:
77 #define LOGIC_ID(the_id, the_name) \
78  virtual void visit(const smt_logic_##the_id##t &) = 0;
79 #include "smt_logics.def"
80 #undef LOGIC_ID
81 };
82 
83 #endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_LOGICS_H
There are a large number of kinds of tree structured or tree-like data in CPROVER.
Definition: irep.h:364
irept()=default
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
Definition: irep.cpp:482
Class for adding the ability to up and down cast smt_logict to and from irept.
Definition: smt_logics.h:32
static const smt_logict & downcast(const irept &)
Definition: smt_logics.h:59
static irept upcast(smt_logict logic)
Definition: smt_logics.h:53
void accept(smt_logic_const_downcast_visitort &) const
Definition: smt_logics.cpp:35
bool operator==(const smt_logict &) const
Definition: smt_logics.cpp:12
bool operator!=(const smt_logict &) const
Definition: smt_logics.cpp:17
smt_logict()=delete