cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
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 <memory>
14
#include <string>
15
16
class
typet
;
17
18
class
c_qualifierst
19
{
20
public
:
21
c_qualifierst
()
22
{
23
clear
();
24
}
25
26
explicit
c_qualifierst
(
const
typet
&src)
27
{
28
clear
();
29
read
(src);
30
}
31
32
virtual
~c_qualifierst
() =
default
;
33
34
protected
:
35
c_qualifierst
&
operator=
(
const
c_qualifierst
&other);
36
public
:
37
virtual
std::unique_ptr<c_qualifierst>
clone
()
const
;
38
39
virtual
void
clear
()
40
{
41
is_constant
=
false
;
42
is_volatile
=
false
;
43
is_restricted
=
false
;
44
is_atomic
=
false
;
45
is_ptr32
=
is_ptr64
=
false
;
46
is_transparent_union
=
false
;
47
is_nodiscard
=
false
;
48
is_noreturn
=
false
;
49
}
50
51
// standard ones
52
bool
is_constant
,
is_volatile
,
is_restricted
,
is_atomic
,
is_noreturn
,
53
is_nodiscard
;
54
55
// MS Visual Studio extension
56
bool
is_ptr32
,
is_ptr64
;
57
58
// gcc extension
59
bool
is_transparent_union
;
60
61
// will likely add alignment here as well
62
63
virtual
std::string
as_string
()
const
;
64
virtual
void
read
(
const
typet
&src);
65
virtual
void
write
(
typet
&src)
const
;
66
67
static
void
clear
(
typet
&dest);
68
69
bool
is_subset_of
(
const
c_qualifierst
&other)
const
70
{
71
return
(!
is_constant
|| other.
is_constant
) &&
72
(!
is_volatile
|| other.
is_volatile
) &&
73
(!
is_restricted
|| other.
is_restricted
) &&
74
(!
is_atomic
|| other.
is_atomic
) && (!
is_ptr32
|| other.
is_ptr32
) &&
75
(!
is_ptr64
|| other.
is_ptr64
) &&
76
(!
is_nodiscard
|| other.
is_nodiscard
) &&
77
(!
is_noreturn
|| other.
is_noreturn
);
78
79
// is_transparent_union isn't checked
80
}
81
82
bool
operator==
(
const
c_qualifierst
&other)
const
83
{
84
return
is_constant
== other.
is_constant
&&
85
is_volatile
== other.
is_volatile
&&
86
is_restricted
== other.
is_restricted
&&
87
is_atomic
== other.
is_atomic
&&
is_ptr32
== other.
is_ptr32
&&
88
is_ptr64
== other.
is_ptr64
&&
89
is_transparent_union
== other.
is_transparent_union
&&
90
is_nodiscard
== other.
is_nodiscard
&&
91
is_noreturn
== other.
is_noreturn
;
92
}
93
94
bool
operator!=
(
const
c_qualifierst
&other)
const
95
{
96
return
!(*
this
== other);
97
}
98
99
c_qualifierst
&
operator+=
(
const
c_qualifierst
&other)
100
{
101
is_constant
|= other.
is_constant
;
102
is_volatile
|= other.
is_volatile
;
103
is_restricted
|= other.
is_restricted
;
104
is_atomic
|= other.
is_atomic
;
105
is_ptr32
|= other.
is_ptr32
;
106
is_ptr64
|= other.
is_ptr64
;
107
is_transparent_union
|= other.
is_transparent_union
;
108
is_nodiscard
|= other.
is_nodiscard
;
109
is_noreturn
|= other.
is_noreturn
;
110
return
*
this
;
111
}
112
};
113
114
#endif
// CPROVER_ANSI_C_C_QUALIFIERS_H
c_qualifierst::c_qualifierst
c_qualifierst(const typet &src)
Definition
c_qualifiers.h:26
c_qualifierst::is_restricted
bool is_restricted
Definition
c_qualifiers.h:52
c_qualifierst::write
virtual void write(typet &src) const
Definition
c_qualifiers.cpp:95
c_qualifierst::operator!=
bool operator!=(const c_qualifierst &other) const
Definition
c_qualifiers.h:94
c_qualifierst::read
virtual void read(const typet &src)
Definition
c_qualifiers.cpp:65
c_qualifierst::~c_qualifierst
virtual ~c_qualifierst()=default
c_qualifierst::operator+=
c_qualifierst & operator+=(const c_qualifierst &other)
Definition
c_qualifiers.h:99
c_qualifierst::is_noreturn
bool is_noreturn
Definition
c_qualifiers.h:52
c_qualifierst::is_nodiscard
bool is_nodiscard
Definition
c_qualifiers.h:53
c_qualifierst::is_transparent_union
bool is_transparent_union
Definition
c_qualifiers.h:59
c_qualifierst::clone
virtual std::unique_ptr< c_qualifierst > clone() const
Definition
c_qualifiers.cpp:27
c_qualifierst::is_atomic
bool is_atomic
Definition
c_qualifiers.h:52
c_qualifierst::is_subset_of
bool is_subset_of(const c_qualifierst &other) const
Definition
c_qualifiers.h:69
c_qualifierst::is_ptr64
bool is_ptr64
Definition
c_qualifiers.h:56
c_qualifierst::clear
virtual void clear()
Definition
c_qualifiers.h:39
c_qualifierst::is_ptr32
bool is_ptr32
Definition
c_qualifiers.h:56
c_qualifierst::c_qualifierst
c_qualifierst()
Definition
c_qualifiers.h:21
c_qualifierst::as_string
virtual std::string as_string() const
Definition
c_qualifiers.cpp:34
c_qualifierst::operator=
c_qualifierst & operator=(const c_qualifierst &other)
Definition
c_qualifiers.cpp:13
c_qualifierst::is_constant
bool is_constant
Definition
c_qualifiers.h:52
c_qualifierst::operator==
bool operator==(const c_qualifierst &other) const
Definition
c_qualifiers.h:82
c_qualifierst::is_volatile
bool is_volatile
Definition
c_qualifiers.h:52
typet
The type of an expression, extends irept.
Definition
type.h:29
ansi-c
c_qualifiers.h
Generated by
1.17.0