cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
c_typecast.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_TYPECAST_H
11
#define CPROVER_ANSI_C_C_TYPECAST_H
12
13
#include <list>
14
#include <optional>
15
#include <string>
16
17
class
exprt
;
18
class
namespacet
;
19
class
typet
;
20
21
// try a type cast from expr.type() to type
22
//
23
// false: typecast successful, expr modified
24
// true: typecast failed
25
26
bool
check_c_implicit_typecast
(
27
const
typet
&src_type,
28
const
typet
&dest_type);
29
30
bool
check_c_implicit_typecast
(
31
const
typet
&src_type,
32
const
typet
&dest_type,
33
const
namespacet
&ns);
34
35
bool
c_implicit_typecast
(
36
exprt
&expr,
37
const
typet
&dest_type,
38
const
namespacet
&ns);
39
40
bool
c_implicit_typecast_arithmetic
(
41
exprt
&expr1,
exprt
&expr2,
42
const
namespacet
&ns);
43
44
class
c_typecastt
45
{
46
public
:
47
explicit
c_typecastt
(
const
namespacet
&_ns):
ns
(_ns)
48
{
49
}
50
51
virtual
~c_typecastt
()
52
{
53
}
54
55
virtual
void
implicit_typecast
(
56
exprt
&expr,
57
const
typet
&type);
58
59
virtual
void
implicit_typecast_arithmetic
(
60
exprt
&expr);
61
62
virtual
void
implicit_typecast_arithmetic
(
63
exprt
&expr1,
64
exprt
&expr2);
65
66
std::list<std::string>
errors
;
67
std::list<std::string>
warnings
;
68
71
static
std::optional<std::string>
check_address_can_be_taken
(
const
typet
&);
72
73
protected
:
74
const
namespacet
&
ns
;
75
76
// these are in promotion order
77
78
enum
c_typet
79
{
80
BOOL
,
81
CHAR
,
82
UCHAR
,
83
SHORT
,
84
USHORT
,
85
INT
,
86
UINT
,
87
LONG
,
88
ULONG
,
89
LONGLONG
,
90
ULONGLONG
,
91
LARGE_SIGNED_INT
,
92
LARGE_UNSIGNED_INT
,
93
INTEGER
,
// these are unbounded integers, non-standard
94
NATURAL
,
// these are unbounded natural numbers, non-standard
95
FIXEDBV
,
// fixed-point, non-standard
96
SINGLE
,
97
DOUBLE
,
98
LONGDOUBLE
,
99
FLOAT128
,
// float
100
RATIONAL
,
// infinite precision, non-standard
101
REAL
,
// infinite precision, non-standard
102
COMPLEX
,
103
VOIDPTR
,
104
PTR
,
105
OTHER
106
};
107
108
c_typet
get_c_type
(
const
typet
&type)
const
;
109
110
void
implicit_typecast_arithmetic
(
111
exprt
&expr,
112
c_typet
c_type);
113
114
typet
follow_with_qualifiers
(
const
typet
&src);
115
116
// after follow_with_qualifiers
117
virtual
void
implicit_typecast_followed
(
118
exprt
&expr,
119
const
typet
&src_type,
120
const
typet
&orig_dest_type,
121
const
typet
&dest_type);
122
123
void
do_typecast
(
exprt
&dest,
const
typet
&type);
124
125
c_typet
minimum_promotion
(
const
typet
&type)
const
;
126
};
127
128
#endif
// CPROVER_ANSI_C_C_TYPECAST_H
c_implicit_typecast
bool c_implicit_typecast(exprt &expr, const typet &dest_type, const namespacet &ns)
Definition
c_typecast.cpp:27
c_implicit_typecast_arithmetic
bool c_implicit_typecast_arithmetic(exprt &expr1, exprt &expr2, const namespacet &ns)
perform arithmetic prompotions and conversions
Definition
c_typecast.cpp:50
check_c_implicit_typecast
bool check_c_implicit_typecast(const typet &src_type, const typet &dest_type)
Definition
c_typecast.cpp:74
c_typecastt::c_typet
c_typet
Definition
c_typecast.h:79
c_typecastt::CHAR
@ CHAR
Definition
c_typecast.h:81
c_typecastt::UCHAR
@ UCHAR
Definition
c_typecast.h:82
c_typecastt::PTR
@ PTR
Definition
c_typecast.h:104
c_typecastt::LARGE_UNSIGNED_INT
@ LARGE_UNSIGNED_INT
Definition
c_typecast.h:92
c_typecastt::SINGLE
@ SINGLE
Definition
c_typecast.h:96
c_typecastt::COMPLEX
@ COMPLEX
Definition
c_typecast.h:102
c_typecastt::INT
@ INT
Definition
c_typecast.h:85
c_typecastt::LONGDOUBLE
@ LONGDOUBLE
Definition
c_typecast.h:98
c_typecastt::RATIONAL
@ RATIONAL
Definition
c_typecast.h:100
c_typecastt::LARGE_SIGNED_INT
@ LARGE_SIGNED_INT
Definition
c_typecast.h:91
c_typecastt::FIXEDBV
@ FIXEDBV
Definition
c_typecast.h:95
c_typecastt::LONGLONG
@ LONGLONG
Definition
c_typecast.h:89
c_typecastt::REAL
@ REAL
Definition
c_typecast.h:101
c_typecastt::VOIDPTR
@ VOIDPTR
Definition
c_typecast.h:103
c_typecastt::BOOL
@ BOOL
Definition
c_typecast.h:80
c_typecastt::NATURAL
@ NATURAL
Definition
c_typecast.h:94
c_typecastt::OTHER
@ OTHER
Definition
c_typecast.h:105
c_typecastt::USHORT
@ USHORT
Definition
c_typecast.h:84
c_typecastt::FLOAT128
@ FLOAT128
Definition
c_typecast.h:99
c_typecastt::ULONGLONG
@ ULONGLONG
Definition
c_typecast.h:90
c_typecastt::SHORT
@ SHORT
Definition
c_typecast.h:83
c_typecastt::ULONG
@ ULONG
Definition
c_typecast.h:88
c_typecastt::INTEGER
@ INTEGER
Definition
c_typecast.h:93
c_typecastt::DOUBLE
@ DOUBLE
Definition
c_typecast.h:97
c_typecastt::LONG
@ LONG
Definition
c_typecast.h:87
c_typecastt::UINT
@ UINT
Definition
c_typecast.h:86
c_typecastt::implicit_typecast_followed
virtual void implicit_typecast_followed(exprt &expr, const typet &src_type, const typet &orig_dest_type, const typet &dest_type)
Definition
c_typecast.cpp:524
c_typecastt::c_typecastt
c_typecastt(const namespacet &_ns)
Definition
c_typecast.h:47
c_typecastt::follow_with_qualifiers
typet follow_with_qualifiers(const typet &src)
Definition
c_typecast.cpp:275
c_typecastt::do_typecast
void do_typecast(exprt &dest, const typet &type)
Definition
c_typecast.cpp:742
c_typecastt::implicit_typecast
virtual void implicit_typecast(exprt &expr, const typet &type)
Definition
c_typecast.cpp:510
c_typecastt::get_c_type
c_typet get_c_type(const typet &type) const
Definition
c_typecast.cpp:309
c_typecastt::implicit_typecast_arithmetic
virtual void implicit_typecast_arithmetic(exprt &expr)
Definition
c_typecast.cpp:504
c_typecastt::warnings
std::list< std::string > warnings
Definition
c_typecast.h:67
c_typecastt::ns
const namespacet & ns
Definition
c_typecast.h:74
c_typecastt::check_address_can_be_taken
static std::optional< std::string > check_address_can_be_taken(const typet &)
Definition
c_typecast.cpp:809
c_typecastt::~c_typecastt
virtual ~c_typecastt()
Definition
c_typecast.h:51
c_typecastt::minimum_promotion
c_typet minimum_promotion(const typet &type) const
Definition
c_typecast.cpp:472
c_typecastt::errors
std::list< std::string > errors
Definition
c_typecast.h:66
exprt
Base class for all expressions.
Definition
expr.h:57
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
typet
The type of an expression, extends irept.
Definition
type.h:29
ansi-c
c_typecast.h
Generated by
1.17.0