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
cpp_scopes.h
C++ Language Type Checking.
cpp_typecheck_resolvet::filter
void filter(resolve_identifierst &identifiers, const wantt want)
Definition: cpp_typecheck_resolve.cpp:376
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
cpp_typecheck_resolvet::matcht
Definition: cpp_typecheck_resolve.h:142
cpp_scopet
Definition: cpp_scope.h:21
cpp_typecheck_fargst
Definition: cpp_typecheck_fargs.h:23
cpp_typecheck_resolvet::convert_identifier
exprt convert_identifier(const cpp_idt &id, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:209
cpp_typecheck_resolvet::show_identifiers
void show_identifiers(const irep_idt &base_name, const resolve_identifierst &identifiers, std::ostream &out)
Definition: cpp_typecheck_resolve.cpp:1263
cpp_typecheck_resolvet::wantt
wantt
Definition: cpp_typecheck_resolve.h:26
typet
The type of an expression, extends irept.
Definition: type.h:29
cpp_typecheck_fargs.h
C++ Language Type Checking.
cpp_typecheck_resolvet::resolve_identifierst
std::vector< exprt > resolve_identifierst
Definition: cpp_typecheck_resolve.h:48
cpp_typecheck_resolvet
Definition: cpp_typecheck_resolve.h:21
cpp_typecheck_resolvet::disambiguate_template_classes
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
Definition: cpp_typecheck_resolve.cpp:988
exprt
Base class for all expressions.
Definition: expr.h:53
struct_tag_typet
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:490
cpp_typecheck_resolvet::cpp_typecheck
cpp_typecheckt & cpp_typecheck
Definition: cpp_typecheck_resolve.h:44
cpp_template_args.h
C++ Language Type Checking.
cpp_template_args_tct
Definition: cpp_template_args.h:65
cpp_idt
Definition: cpp_id.h:29
cpp_typecheck_resolvet::original_scope
cpp_scopet * original_scope
Definition: cpp_typecheck_resolve.h:46
cpp_typecheck_resolvet::wantt::TYPE
@ TYPE
cpp_typecheck_resolvet::matcht::full_args
cpp_template_args_tct full_args
Definition: cpp_typecheck_resolve.h:145
cpp_typecheck_resolvet::guess_function_template_args
void guess_function_template_args(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
guess arguments of function templates
Definition: cpp_typecheck_resolve.cpp:89
cpp_typecheck_resolvet::matcht::cost
std::size_t cost
Definition: cpp_typecheck_resolve.h:143
cpp_typecheck_resolvet::remove_duplicates
void remove_duplicates(resolve_identifierst &identifiers)
Definition: cpp_typecheck_resolve.cpp:150
cpp_scopest::id_sett
std::set< cpp_idt * > id_sett
Definition: cpp_scopes.h:31
cpp_typecheck_resolvet::resolve_namespace
cpp_scopet & resolve_namespace(const cpp_namet &cpp_name)
Definition: cpp_typecheck_resolve.cpp:1225
cpp_typecheck_resolvet::cpp_typecheck_resolvet
cpp_typecheck_resolvet(class cpp_typecheckt &_cpp_typecheck)
Definition: cpp_typecheck_resolve.cpp:39
cpp_typecheck_resolvet::matcht::specialization_args
cpp_template_args_tct specialization_args
Definition: cpp_typecheck_resolve.h:144
cpp_typecheck_resolvet::wantt::BOTH
@ BOTH
cpp_typecheckt
Definition: cpp_typecheck.h:45
cpp_typecheck_resolvet::filter_for_named_scopes
void filter_for_named_scopes(cpp_scopest::id_sett &id_set)
Definition: cpp_typecheck_resolve.cpp:2175
cpp_typecheck_resolvet::resolve
exprt resolve(const cpp_namet &cpp_name, const wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
Definition: cpp_typecheck_resolve.cpp:1357
cpp_typecheck_resolvet::matcht::id
irep_idt id
Definition: cpp_typecheck_resolve.h:146
cpp_typecheck_resolvet::remove_templates
void remove_templates(resolve_identifierst &identifiers)
Definition: cpp_typecheck_resolve.cpp:137
cpp_typecheck_resolvet::resolve_argument
void resolve_argument(exprt &argument, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:644
cpp_template_args_non_tct
Definition: cpp_template_args.h:45
cpp_typecheck_resolvet::exact_match_functions
void exact_match_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:410
source_locationt
Definition: source_location.h:20
cpp_typecheck_resolvet::guess_template_args
void guess_template_args(const typet &template_parameter, const typet &desired_type)
Definition: cpp_typecheck_resolve.cpp:1740
cpp_typecheck_resolvet::convert_template_parameter
exprt convert_template_parameter(const cpp_idt &id)
Definition: cpp_typecheck_resolve.cpp:183
cpp_typecheck_resolvet::matcht::matcht
matcht(cpp_template_args_tct _s_args, cpp_template_args_tct _f_args, irep_idt _id)
Definition: cpp_typecheck_resolve.h:147
cpp_typecheck_resolvet::resolve_scope
cpp_scopet & resolve_scope(const cpp_namet &cpp_name, irep_idt &base_name, cpp_template_args_non_tct &template_args)
Definition: cpp_typecheck_resolve.cpp:854
cpp_typecheck_resolvet::convert_identifiers
void convert_identifiers(const cpp_scopest::id_sett &id_set, const cpp_typecheck_fargst &fargs, resolve_identifierst &identifiers)
Definition: cpp_typecheck_resolve.cpp:45
cpp_typecheck_resolvet::wantt::VAR
@ VAR
cpp_typecheck_resolvet::matcht::operator<
bool operator<(const matcht &other) const
Definition: cpp_typecheck_resolve.h:158
cpp_typecheck_resolvet::apply_template_args
void apply_template_args(resolve_identifierst &identifiers, const cpp_template_args_non_tct &template_args, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:65
cpp_typecheck_resolvet::disambiguate_functions
void disambiguate_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:432
cpp_typecheck_resolvet::filter_for_namespaces
void filter_for_namespaces(cpp_scopest::id_sett &id_set)
Definition: cpp_typecheck_resolve.cpp:2293
cpp_typecheck_resolvet::do_builtin
exprt do_builtin(const irep_idt &base_name, const cpp_typecheck_fargst &fargs, const cpp_template_args_non_tct &template_args)
Definition: cpp_typecheck_resolve.cpp:658
cpp_namet
Definition: cpp_name.h:17
cpp_typecheck_resolvet::resolve_with_arguments
void resolve_with_arguments(cpp_scopest::id_sett &id_set, const irep_idt &base_name, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:2313
cpp_typecheck_resolvet::make_constructors
void make_constructors(resolve_identifierst &identifiers)
Definition: cpp_typecheck_resolve.cpp:569
cpp_typecheck_resolvet::source_location
source_locationt source_location
Definition: cpp_typecheck_resolve.h:45
cpp_name.h