-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathcpp_declaration.h
158 lines (125 loc) · 3.32 KB
/
cpp_declaration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*******************************************************************\
Module: C++ Language Type Checking
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// C++ Language Type Checking
#ifndef CPROVER_CPP_CPP_DECLARATION_H
#define CPROVER_CPP_CPP_DECLARATION_H
#include "cpp_declarator.h"
#include "cpp_storage_spec.h"
#include "cpp_member_spec.h"
#include "cpp_template_type.h"
#include "cpp_template_args.h"
class cpp_declarationt:public exprt
{
public:
typedef std::vector<cpp_declaratort> declaratorst;
cpp_declarationt():exprt(ID_cpp_declaration)
{
}
bool is_empty() const
{
return type().is_nil() && !has_operands();
}
bool is_constructor() const
{
return type().id()==ID_constructor;
}
bool is_static_assert() const
{
return get_bool(ID_is_static_assert);
}
bool is_destructor() const
{
return type().id()==ID_destructor;
}
bool is_template() const
{
return get_bool(ID_is_template);
}
bool is_class_template() const
{
return is_template() &&
type().id()==ID_struct &&
declarators().empty();
}
const declaratorst &declarators() const
{
return (const declaratorst &)operands();
}
declaratorst &declarators()
{
return (declaratorst &)operands();
}
const cpp_storage_spect &storage_spec() const
{
return static_cast<const cpp_storage_spect &>(
find(ID_storage_spec));
}
cpp_storage_spect &storage_spec()
{
return static_cast<cpp_storage_spect &>(
add(ID_storage_spec));
}
const cpp_member_spect &member_spec() const
{
return static_cast<const cpp_member_spect &>(
find(ID_member_spec));
}
cpp_member_spect &member_spec()
{
return static_cast<cpp_member_spect &>(
add(ID_member_spec));
}
template_typet &template_type()
{
return static_cast<template_typet &>(add(ID_template_type));
}
const template_typet &template_type() const
{
return static_cast<const template_typet &>(find(ID_template_type));
}
cpp_template_args_non_tct &partial_specialization_args()
{
return static_cast<cpp_template_args_non_tct &>(
add(ID_partial_specialization_args));
}
const cpp_template_args_non_tct &partial_specialization_args() const
{
return static_cast<const cpp_template_args_non_tct &>(
find(ID_partial_specialization_args));
}
void set_specialization_of(const irep_idt &id)
{
set(ID_specialization_of, id);
}
irep_idt get_specialization_of() const
{
return get(ID_specialization_of);
}
void set_is_typedef()
{
set(ID_is_typedef, true);
}
bool is_typedef() const
{
return get_bool(ID_is_typedef);
}
void output(std::ostream &out) const;
// for assigning a tag for struct/union in the type based on
// the name of the first declarator
void name_anon_struct_union() { name_anon_struct_union(type()); }
void name_anon_struct_union(typet &dest);
};
inline cpp_declarationt &to_cpp_declaration(irept &irep)
{
PRECONDITION(irep.id() == ID_cpp_declaration);
return static_cast<cpp_declarationt &>(irep);
}
inline const cpp_declarationt &to_cpp_declaration(const irept &irep)
{
PRECONDITION(irep.id() == ID_cpp_declaration);
return static_cast<const cpp_declarationt &>(irep);
}
#endif // CPROVER_CPP_CPP_DECLARATION_H