cprover
cpp_typecheck_resolve.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: C++ Language Type Checking
4 
5 Author: Daniel Kroening, kroening@cs.cmu.edu
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H
13 #define CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H
14 
15 #include "cpp_typecheck_fargs.h"
16 #include "cpp_name.h"
17 #include "cpp_template_args.h"
18 #include "cpp_scopes.h"
19 
21 {
22 public:
24  class cpp_typecheckt &_cpp_typecheck);
25 
26  enum class wantt { VAR, TYPE, BOTH };
27 
28  exprt resolve(
29  const cpp_namet &cpp_name,
30  const wantt want,
31  const cpp_typecheck_fargst &fargs,
32  bool fail_with_exception=true);
33 
34  // Returns the scope as a side-effect as 'current_scope'.
35  // Should really return explicitly.
37  const cpp_namet &cpp_name,
38  irep_idt &base_name,
39  cpp_template_args_non_tct &template_args);
40 
41  cpp_scopet &resolve_namespace(const cpp_namet &cpp_name);
42 
43 protected:
47 
48  typedef std::vector<exprt> resolve_identifierst;
49 
51  const cpp_scopest::id_sett &id_set,
52  const cpp_typecheck_fargst &fargs,
53  resolve_identifierst &identifiers);
54 
56  const cpp_idt &id);
57 
59  const cpp_idt &id,
60  const cpp_typecheck_fargst &fargs);
61 
63  resolve_identifierst &identifiers,
64  const cpp_typecheck_fargst &fargs);
65 
67  resolve_identifierst &identifiers,
68  const cpp_typecheck_fargst &fargs);
69 
70  void filter(
71  resolve_identifierst &identifiers,
72  const wantt want);
73 
75  const irep_idt &base_name,
76  const cpp_scopest::id_sett &id_set,
77  const cpp_template_args_non_tct &template_args);
78 
79  void make_constructors(
80  resolve_identifierst &identifiers);
81 
83  resolve_identifierst &identifiers,
84  const cpp_template_args_non_tct &template_args,
85  const cpp_typecheck_fargst &fargs);
86 
88  exprt &expr,
89  const cpp_template_args_non_tct &template_args,
90  const cpp_typecheck_fargst &fargs);
91 
93  resolve_identifierst &identifiers,
94  const cpp_typecheck_fargst &fargs);
95 
96  void remove_templates(
97  resolve_identifierst &identifiers);
98 
99  void remove_duplicates(
100  resolve_identifierst &identifiers);
101 
103  const exprt &expr,
104  const cpp_typecheck_fargst &fargs);
105 
106  void guess_template_args(
107  const typet &template_parameter,
108  const typet &desired_type);
109 
110  void guess_template_args(
111  const exprt &template_parameter,
112  const exprt &desired_expr);
113 
115  const exprt &expr,
116  unsigned &args_distance,
117  const cpp_typecheck_fargst &fargs);
118 
119  void resolve_argument(
120  exprt &argument,
121  const cpp_typecheck_fargst &fargs);
122 
124  const irep_idt &base_name,
125  const cpp_typecheck_fargst &fargs,
126  const cpp_template_args_non_tct &template_args);
127 
128  void show_identifiers(
129  const irep_idt &base_name,
130  const resolve_identifierst &identifiers,
131  std::ostream &out);
132 
134  cpp_scopest::id_sett &id_set,
135  const irep_idt &base_name,
136  const cpp_typecheck_fargst &fargs);
137 
140 
141  struct matcht
142  {
143  std::size_t cost;
148  cpp_template_args_tct _s_args,
149  cpp_template_args_tct _f_args,
150  irep_idt _id):
151  cost(_s_args.arguments().size()),
152  specialization_args(_s_args),
153  full_args(_f_args),
154  id(_id)
155  {
156  }
157 
158  bool operator<(const matcht &other) const
159  {
160  return cost<other.cost;
161  }
162  };
163 };
164 
165 #endif // CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H
exprt convert_template_parameter(const cpp_idt &id)
The type of an expression, extends irept.
Definition: type.h:27
void convert_identifiers(const cpp_scopest::id_sett &id_set, const cpp_typecheck_fargst &fargs, resolve_identifierst &identifiers)
source_locationt source_location
C++ Language Type Checking.
std::set< cpp_idt * > id_sett
Definition: cpp_scopes.h:31
exprt resolve(const cpp_namet &cpp_name, const wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
void guess_template_args(const typet &template_parameter, const typet &desired_type)
void remove_duplicates(resolve_identifierst &identifiers)
void resolve_argument(exprt &argument, const cpp_typecheck_fargst &fargs)
void disambiguate_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
void remove_templates(resolve_identifierst &identifiers)
exprt do_builtin(const irep_idt &base_name, const cpp_typecheck_fargst &fargs, const cpp_template_args_non_tct &template_args)
void exact_match_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
A reference into the symbol table.
Definition: std_types.h:62
void filter_for_namespaces(cpp_scopest::id_sett &id_set)
symbol_typet disambiguate_template_classes(const irep_idt &base_name, const cpp_scopest::id_sett &id_set, const cpp_template_args_non_tct &template_args)
disambiguate partial specialization
void filter(resolve_identifierst &identifiers, const wantt want)
matcht(cpp_template_args_tct _s_args, cpp_template_args_tct _f_args, irep_idt _id)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:35
C++ Language Type Checking.
exprt convert_identifier(const cpp_idt &id, const cpp_typecheck_fargst &fargs)
void guess_function_template_args(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
guess arguments of function templates
void resolve_with_arguments(cpp_scopest::id_sett &id_set, const irep_idt &base_name, const cpp_typecheck_fargst &fargs)
C++ Language Type Checking.
cpp_template_args_tct specialization_args
Base class for all expressions.
Definition: expr.h:54
bool operator<(const matcht &other) const
void show_identifiers(const irep_idt &base_name, const resolve_identifierst &identifiers, std::ostream &out)
cpp_typecheck_resolvet(class cpp_typecheckt &_cpp_typecheck)
std::vector< exprt > resolve_identifierst
Definition: cpp_id.h:28
void make_constructors(resolve_identifierst &identifiers)
void filter_for_named_scopes(cpp_scopest::id_sett &id_set)
void apply_template_args(resolve_identifierst &identifiers, const cpp_template_args_non_tct &template_args, const cpp_typecheck_fargst &fargs)
cpp_scopet & resolve_namespace(const cpp_namet &cpp_name)
cpp_typecheckt & cpp_typecheck
cpp_scopet & resolve_scope(const cpp_namet &cpp_name, irep_idt &base_name, cpp_template_args_non_tct &template_args)