cprover
c_qualifiers.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_ANSI_C_C_QUALIFIERS_H
11 #define CPROVER_ANSI_C_C_QUALIFIERS_H
12 
13 #include <iosfwd>
14 
15 #include <util/expr.h>
16 
18 {
19 public:
21  {
22  clear();
23  }
24 
25  explicit c_qualifierst(const typet &src)
26  {
27  clear();
28  read(src);
29  }
30 
31  void clear()
32  {
33  is_constant=false;
34  is_volatile=false;
35  is_restricted=false;
36  is_atomic=false;
37  is_ptr32=is_ptr64=false;
39  is_noreturn=false;
40  }
41 
42  // standard ones
44 
45  // MS Visual Studio extension
47 
48  // gcc extension
50 
51  // will likely add alignment here as well
52 
53  std::string as_string() const;
54  void read(const typet &src);
55  void write(typet &src) const;
56 
57  static void clear(typet &dest);
58 
59  bool is_subset_of(const c_qualifierst &q) const
60  {
61  return (!is_constant || q.is_constant) &&
62  (!is_volatile || q.is_volatile) &&
63  (!is_restricted || q.is_restricted) &&
64  (!is_atomic || q.is_atomic) &&
65  (!is_ptr32 || q.is_ptr32) &&
66  (!is_ptr64 || q.is_ptr64) &&
67  (!is_noreturn || q.is_noreturn);
68 
69  // is_transparent_union isn't checked
70  }
71 
72  bool operator==(const c_qualifierst &other) const
73  {
74  return is_constant==other.is_constant &&
75  is_volatile==other.is_volatile &&
76  is_restricted==other.is_restricted &&
77  is_atomic==other.is_atomic &&
78  is_ptr32==other.is_ptr32 &&
79  is_ptr64==other.is_ptr64 &&
80  is_transparent_union==other.is_transparent_union &&
81  is_noreturn==other.is_noreturn;
82  }
83 
84  bool operator!=(const c_qualifierst &other) const
85  {
86  return !(*this==other);
87  }
88 
90  {
91  is_constant|=b.is_constant;
92  is_volatile|=b.is_volatile;
93  is_restricted|=b.is_restricted;
94  is_atomic|=b.is_atomic;
95  is_ptr32|=b.is_ptr32;
96  is_ptr64|=b.is_ptr64;
97  is_transparent_union|=b.is_transparent_union;
98  is_noreturn|=b.is_noreturn;
99  return *this;
100  }
101 
102  unsigned count() const
103  {
104  return is_constant+is_volatile+is_restricted+is_atomic+
105  is_ptr32+is_ptr64+is_noreturn;
106  }
107 };
108 
109 std::ostream &operator << (std::ostream &, const c_qualifierst &);
110 
111 #endif // CPROVER_ANSI_C_C_QUALIFIERS_H
The type of an expression.
Definition: type.h:20
unsigned count() const
Definition: c_qualifiers.h:102
void read(const typet &src)
c_qualifierst & operator+=(const c_qualifierst &b)
Definition: c_qualifiers.h:89
void write(typet &src) const
bool is_transparent_union
Definition: c_qualifiers.h:49
bool operator==(const c_qualifierst &other) const
Definition: c_qualifiers.h:72
std::ostream & operator<<(std::ostream &, const c_qualifierst &)
pretty-print the qualifiers
std::string as_string() const
bool is_subset_of(const c_qualifierst &q) const
Definition: c_qualifiers.h:59
bool operator!=(const c_qualifierst &other) const
Definition: c_qualifiers.h:84
bool is_restricted
Definition: c_qualifiers.h:43
c_qualifierst(const typet &src)
Definition: c_qualifiers.h:25