CBMC
cpp_enum_type.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: C++ Language Type Checking
4 
5 Author: Daniel Kroening, kroening@cs.cmu.edu
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_CPP_CPP_ENUM_TYPE_H
13 #define CPROVER_CPP_CPP_ENUM_TYPE_H
14 
15 #include <util/type.h>
16 
17 #include "cpp_name.h"
18 
19 class cpp_enum_typet:public typet
20 {
21 public:
23 
24  const cpp_namet &tag() const
25  {
26  return static_cast<const cpp_namet &>(find(ID_tag));
27  }
28 
29  bool has_tag() const
30  {
31  return find(ID_tag).is_not_nil();
32  }
33 
35  {
36  return static_cast<cpp_namet &>(add(ID_tag));
37  }
38 
39  const irept &body() const
40  {
41  return find(ID_body);
42  }
43 
45  {
46  return add(ID_body);
47  }
48 
49  bool has_body() const
50  {
51  return find(ID_body).is_not_nil();
52  }
53 
55  {
56  return get_bool(ID_C_tag_only_declaration);
57  }
58 
60 };
61 
62 inline const cpp_enum_typet &to_cpp_enum_type(const irept &irep)
63 {
64  PRECONDITION(irep.id() == ID_c_enum);
65  return static_cast<const cpp_enum_typet &>(irep);
66 }
67 
69 {
70  PRECONDITION(irep.id() == ID_c_enum);
71  return static_cast<cpp_enum_typet &>(irep);
72 }
73 
74 #endif // CPROVER_CPP_CPP_ENUM_TYPE_H
bool has_body() const
Definition: cpp_enum_type.h:49
cpp_namet & tag()
Definition: cpp_enum_type.h:34
const cpp_namet & tag() const
Definition: cpp_enum_type.h:24
bool has_tag() const
Definition: cpp_enum_type.h:29
irept & body()
Definition: cpp_enum_type.h:44
const irept & body() const
Definition: cpp_enum_type.h:39
irep_idt generate_anon_tag() const
bool get_tag_only_declaration() const
Definition: cpp_enum_type.h:54
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
There are a large number of kinds of tree structured or tree-like data in CPROVER.
Definition: irep.h:360
bool get_bool(const irep_idt &name) const
Definition: irep.cpp:57
const irept & find(const irep_idt &name) const
Definition: irep.cpp:93
bool is_not_nil() const
Definition: irep.h:368
const irep_idt & id() const
Definition: irep.h:384
irept & add(const irep_idt &name)
Definition: irep.cpp:103
The type of an expression, extends irept.
Definition: type.h:29
const cpp_enum_typet & to_cpp_enum_type(const irept &irep)
Definition: cpp_enum_type.h:62
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
Defines typet, type_with_subtypet and type_with_subtypest.