-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathcpp_typecheck_resolve.h
More file actions
168 lines (128 loc) · 4.09 KB
/
cpp_typecheck_resolve.h
File metadata and controls
168 lines (128 loc) · 4.09 KB
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
159
160
161
162
163
164
165
166
167
168
/*******************************************************************\
Module: C++ Language Type Checking
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// C++ Language Type Checking
#ifndef CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H
#define CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H
#include <util/std_types.h>
#include "cpp_template_args.h"
#include "cpp_scopes.h"
class cpp_namet;
class cpp_typecheck_fargst;
class cpp_typecheck_resolvet
{
public:
cpp_typecheck_resolvet(
class cpp_typecheckt &_cpp_typecheck);
enum class wantt { VAR, TYPE, BOTH };
exprt resolve(
const cpp_namet &cpp_name,
const wantt want,
const cpp_typecheck_fargst &fargs,
bool fail_with_exception=true);
// Returns the scope as a side-effect as 'current_scope'.
// Should really return explicitly.
cpp_scopet &resolve_scope(
const cpp_namet &cpp_name,
irep_idt &base_name,
cpp_template_args_non_tct &template_args);
cpp_scopet &resolve_namespace(const cpp_namet &cpp_name);
protected:
cpp_typecheckt &cpp_typecheck;
source_locationt source_location;
cpp_scopet *original_scope;
typedef std::vector<exprt> resolve_identifierst;
void convert_identifiers(
const cpp_scopest::id_sett &id_set,
const cpp_typecheck_fargst &fargs,
resolve_identifierst &identifiers);
exprt convert_template_parameter(
const cpp_idt &id);
exprt convert_identifier(
const cpp_idt &id,
const cpp_typecheck_fargst &fargs);
void disambiguate_functions(
resolve_identifierst &identifiers,
const cpp_typecheck_fargst &fargs);
void exact_match_functions(
resolve_identifierst &identifiers,
const cpp_typecheck_fargst &fargs);
void filter(
resolve_identifierst &identifiers,
const wantt want);
struct_tag_typet disambiguate_template_classes(
const irep_idt &base_name,
const cpp_scopest::id_sett &id_set,
const cpp_template_args_non_tct &template_args);
void make_constructors(
resolve_identifierst &identifiers);
void apply_template_args(
resolve_identifierst &identifiers,
const cpp_template_args_non_tct &template_args,
const cpp_typecheck_fargst &fargs);
void apply_template_args(
exprt &expr,
const cpp_template_args_non_tct &template_args,
const cpp_typecheck_fargst &fargs);
void guess_function_template_args(
resolve_identifierst &identifiers,
const cpp_typecheck_fargst &fargs);
void remove_templates(
resolve_identifierst &identifiers);
void remove_duplicates(
resolve_identifierst &identifiers);
exprt guess_function_template_args(
const exprt &expr,
const cpp_typecheck_fargst &fargs);
void guess_template_args(
const typet &template_parameter,
const typet &desired_type);
void guess_template_args(
const exprt &template_parameter,
const exprt &desired_expr);
bool disambiguate_functions(
const exprt &expr,
unsigned &args_distance,
const cpp_typecheck_fargst &fargs);
void resolve_argument(
exprt &argument,
const cpp_typecheck_fargst &fargs);
exprt do_builtin(
const irep_idt &base_name,
const cpp_typecheck_fargst &fargs,
const cpp_template_args_non_tct &template_args);
void show_identifiers(
const irep_idt &base_name,
const resolve_identifierst &identifiers,
std::ostream &out);
void resolve_with_arguments(
cpp_scopest::id_sett &id_set,
const irep_idt &base_name,
const cpp_typecheck_fargst &fargs);
void filter_for_named_scopes(cpp_scopest::id_sett &id_set);
void filter_for_namespaces(cpp_scopest::id_sett &id_set);
struct matcht
{
std::size_t cost;
cpp_template_args_tct specialization_args;
cpp_template_args_tct full_args;
irep_idt id;
matcht(
cpp_template_args_tct _s_args,
cpp_template_args_tct _f_args,
irep_idt _id):
cost(_s_args.arguments().size()),
specialization_args(_s_args),
full_args(_f_args),
id(_id)
{
}
bool operator<(const matcht &other) const
{
return cost<other.cost;
}
};
};
#endif // CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H