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 
52  const wantt want,
53  const cpp_typecheck_fargst &fargs,
54  resolve_identifierst &identifiers);
55 
57  const cpp_idt &id);
58 
60  const cpp_idt &id,
61  const wantt want,
62  const cpp_typecheck_fargst &fargs);
63 
65  resolve_identifierst &identifiers,
66  const cpp_typecheck_fargst &fargs);
67 
69  resolve_identifierst &identifiers,
70  const cpp_typecheck_fargst &fargs);
71 
72  void filter(
73  resolve_identifierst &identifiers,
74  const wantt want);
75 
77  const irep_idt &base_name,
79  const cpp_template_args_non_tct &template_args);
80 
81  void make_constructors(
82  resolve_identifierst &identifiers);
83 
85  resolve_identifierst &identifiers,
86  const cpp_template_args_non_tct &template_args,
87  const cpp_typecheck_fargst &fargs);
88 
90  exprt &expr,
91  const cpp_template_args_non_tct &template_args,
92  const cpp_typecheck_fargst &fargs);
93 
95  resolve_identifierst &identifiers,
96  const cpp_typecheck_fargst &fargs);
97 
98  void remove_templates(
99  resolve_identifierst &identifiers);
100 
101  void remove_duplicates(
102  resolve_identifierst &identifiers);
103 
105  const exprt &expr,
106  const cpp_typecheck_fargst &fargs);
107 
108  void guess_template_args(
109  const typet &template_parameter,
110  const typet &desired_type);
111 
112  void guess_template_args(
113  const exprt &template_parameter,
114  const exprt &desired_expr);
115 
117  const exprt &expr,
118  unsigned &args_distance,
119  const cpp_typecheck_fargst &fargs);
120 
122  const irep_idt &base_name,
123  const cpp_template_args_non_tct &template_args);
124 
125  void show_identifiers(
126  const irep_idt &base_name,
127  const resolve_identifierst &identifiers,
128  std::ostream &out);
129 
132  const irep_idt &base_name,
133  const cpp_typecheck_fargst &fargs);
134 
137 
138  struct matcht
139  {
140  std::size_t cost;
145  cpp_template_args_tct _s_args,
146  cpp_template_args_tct _f_args,
147  irep_idt _id):
148  cost(_s_args.arguments().size()),
149  specialization_args(_s_args),
150  full_args(_f_args),
151  id(_id)
152  {
153  }
154 
155  bool operator<(const matcht &other) const
156  {
157  return cost<other.cost;
158  }
159  };
160 };
161 
162 #endif // CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H
exprt convert_template_parameter(const cpp_idt &id)
The type of an expression.
Definition: type.h:20
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 disambiguate_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
void remove_templates(resolve_identifierst &identifiers)
exprt convert_identifier(const cpp_idt &id, const wantt want, const cpp_typecheck_fargst &fargs)
void exact_match_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
A reference into the symbol table.
Definition: std_types.h:109
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)
C++ Language Type Checking.
exprt do_builtin(const irep_idt &base_name, const cpp_template_args_non_tct &template_args)
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)
void convert_identifiers(const cpp_scopest::id_sett &id_set, const wantt want, const cpp_typecheck_fargst &fargs, resolve_identifierst &identifiers)
C++ Language Type Checking.
cpp_template_args_tct specialization_args
Base class for all expressions.
Definition: expr.h:46
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)