-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathcpp_id.h
115 lines (88 loc) · 2.13 KB
/
cpp_id.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
/*******************************************************************\
Module: C++ Language Type Checking
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// C++ Language Type Checking
#ifndef CPROVER_CPP_CPP_ID_H
#define CPROVER_CPP_CPP_ID_H
#include <map>
#include <string>
#include <iosfwd>
#include <util/expr.h>
#include <util/invariant.h>
class cpp_idt
{
public:
cpp_idt();
enum class id_classt
{
UNKNOWN,
SYMBOL,
TYPEDEF,
CLASS,
ENUM,
TEMPLATE,
TEMPLATE_PARAMETER,
NAMESPACE,
BLOCK_SCOPE,
TEMPLATE_SCOPE,
ROOT_SCOPE,
};
bool is_member, is_method, is_static_member,
is_scope, is_constructor;
id_classt id_class;
bool is_class() const
{
return id_class==id_classt::CLASS;
}
bool is_enum() const
{
return id_class==id_classt::ENUM;
}
bool is_namespace() const
{
return id_class==id_classt::NAMESPACE;
}
bool is_typedef() const
{
return id_class==id_classt::TYPEDEF;
}
bool is_template_scope() const
{
return id_class == id_classt::TEMPLATE_SCOPE;
}
irep_idt identifier, base_name;
// if it is a member or method, what class is it in?
irep_idt class_identifier;
exprt this_expr;
// scope data
std::string prefix, suffix;
unsigned compound_counter;
cpp_idt &get_parent() const
{
PRECONDITION(parent!=nullptr);
return *parent;
}
void set_parent(cpp_idt &_parent)
{
PRECONDITION(_parent.is_scope);
parent=&_parent;
}
void clear()
{
*this=cpp_idt();
}
void print(std::ostream &out, unsigned indent=0) const;
void print_fields(std::ostream &out, unsigned indent=0) const;
protected:
typedef std::multimap<irep_idt, cpp_idt> cpp_id_mapt;
cpp_id_mapt sub;
// These are used for base classes and 'using' clauses.
typedef std::vector<cpp_idt *> scope_listt;
scope_listt using_scopes, secondary_scopes;
cpp_idt *parent;
};
std::ostream &operator<<(std::ostream &out, const cpp_idt &cpp_id);
std::ostream &operator<<(std::ostream &out, const cpp_idt::id_classt &id_class);
#endif // CPROVER_CPP_CPP_ID_H