CBMC
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 <util/std_types.h>
16 
17 #include "cpp_template_args.h"
18 #include "cpp_scopes.h"
19 
20 class cpp_namet;
22 
24 {
25 public:
27  class cpp_typecheckt &_cpp_typecheck);
28 
29  enum class wantt { VAR, TYPE, BOTH };
30 
31  exprt resolve(
32  const cpp_namet &cpp_name,
33  const wantt want,
34  const cpp_typecheck_fargst &fargs,
35  bool fail_with_exception=true);
36 
37  // Returns the scope as a side-effect as 'current_scope'.
38  // Should really return explicitly.
40  const cpp_namet &cpp_name,
41  irep_idt &base_name,
42  cpp_template_args_non_tct &template_args);
43 
44  cpp_scopet &resolve_namespace(const cpp_namet &cpp_name);
45 
46 protected:
50 
51  typedef std::vector<exprt> resolve_identifierst;
52 
54  const cpp_scopest::id_sett &id_set,
55  const cpp_typecheck_fargst &fargs,
56  resolve_identifierst &identifiers);
57 
59  const cpp_idt &id);
60 
62  const cpp_idt &id,
63  const cpp_typecheck_fargst &fargs);
64 
66  resolve_identifierst &identifiers,
67  const cpp_typecheck_fargst &fargs);
68 
70  resolve_identifierst &identifiers,
71  const cpp_typecheck_fargst &fargs);
72 
73  void filter(
74  resolve_identifierst &identifiers,
75  const wantt want);
76 
78  const irep_idt &base_name,
79  const cpp_scopest::id_sett &id_set,
80  const cpp_template_args_non_tct &template_args);
81 
82  void make_constructors(
83  resolve_identifierst &identifiers);
84 
86  resolve_identifierst &identifiers,
87  const cpp_template_args_non_tct &template_args,
88  const cpp_typecheck_fargst &fargs);
89 
91  exprt &expr,
92  const cpp_template_args_non_tct &template_args,
93  const cpp_typecheck_fargst &fargs);
94 
96  resolve_identifierst &identifiers,
97  const cpp_typecheck_fargst &fargs);
98 
99  void remove_templates(
100  resolve_identifierst &identifiers);
101 
102  void remove_duplicates(
103  resolve_identifierst &identifiers);
104 
106  const exprt &expr,
107  const cpp_typecheck_fargst &fargs);
108 
109  void guess_template_args(
110  const typet &template_parameter,
111  const typet &desired_type);
112 
113  void guess_template_args(
114  const exprt &template_parameter,
115  const exprt &desired_expr);
116 
118  const exprt &expr,
119  unsigned &args_distance,
120  const cpp_typecheck_fargst &fargs);
121 
122  void resolve_argument(
123  exprt &argument,
124  const cpp_typecheck_fargst &fargs);
125 
127  const irep_idt &base_name,
128  const cpp_typecheck_fargst &fargs,
129  const cpp_template_args_non_tct &template_args);
130 
131  void show_identifiers(
132  const irep_idt &base_name,
133  const resolve_identifierst &identifiers,
134  std::ostream &out);
135 
137  cpp_scopest::id_sett &id_set,
138  const irep_idt &base_name,
139  const cpp_typecheck_fargst &fargs);
140 
143 
144  struct matcht
145  {
146  std::size_t cost;
151  cpp_template_args_tct _s_args,
152  cpp_template_args_tct _f_args,
153  irep_idt _id):
154  cost(_s_args.arguments().size()),
155  specialization_args(_s_args),
156  full_args(_f_args),
157  id(_id)
158  {
159  }
160 
161  bool operator<(const matcht &other) const
162  {
163  return cost<other.cost;
164  }
165  };
166 };
167 
168 #endif // CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H
Definition: cpp_id.h:23
std::set< cpp_idt * > id_sett
Definition: cpp_scopes.h:30
void remove_templates(resolve_identifierst &identifiers)
void filter(resolve_identifierst &identifiers, const wantt want)
exprt convert_template_parameter(const cpp_idt &id)
exprt convert_identifier(const cpp_idt &id, const cpp_typecheck_fargst &fargs)
cpp_scopet & resolve_namespace(const cpp_namet &cpp_name)
std::vector< exprt > resolve_identifierst
cpp_typecheck_resolvet(class cpp_typecheckt &_cpp_typecheck)
void remove_duplicates(resolve_identifierst &identifiers)
void filter_for_namespaces(cpp_scopest::id_sett &id_set)
exprt resolve(const cpp_namet &cpp_name, const wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
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 filter_for_named_scopes(cpp_scopest::id_sett &id_set)
void make_constructors(resolve_identifierst &identifiers)
void guess_function_template_args(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
guess arguments of function templates
void convert_identifiers(const cpp_scopest::id_sett &id_set, const cpp_typecheck_fargst &fargs, resolve_identifierst &identifiers)
source_locationt source_location
void disambiguate_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
void apply_template_args(resolve_identifierst &identifiers, const cpp_template_args_non_tct &template_args, const cpp_typecheck_fargst &fargs)
void resolve_with_arguments(cpp_scopest::id_sett &id_set, const irep_idt &base_name, const cpp_typecheck_fargst &fargs)
cpp_scopet & resolve_scope(const cpp_namet &cpp_name, irep_idt &base_name, cpp_template_args_non_tct &template_args)
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)
disambiguate partial specialization
cpp_typecheckt & cpp_typecheck
void exact_match_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
void guess_template_args(const typet &template_parameter, const typet &desired_type)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
Base class for all expressions.
Definition: expr.h:56
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:493
The type of an expression, extends irept.
Definition: type.h:29
C++ Language Type Checking.
C++ Language Type Checking.
Pre-defined types.
bool operator<(const matcht &other) const
matcht(cpp_template_args_tct _s_args, cpp_template_args_tct _f_args, irep_idt _id)
cpp_template_args_tct specialization_args