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
cpp_scopes.h
cpp_typecheck_resolvet::filter
void filter(resolve_identifierst &identifiers, const wantt want)
Definition: cpp_typecheck_resolve.cpp:378
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
cpp_typecheck_resolvet::matcht
Definition: cpp_typecheck_resolve.h:144
cpp_scopet
Definition: cpp_scope.h:20
cpp_typecheck_fargst
Definition: cpp_typecheck_fargs.h:21
cpp_typecheck_resolvet::convert_identifier
exprt convert_identifier(const cpp_idt &id, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:207
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:1265
cpp_typecheck_resolvet::wantt
wantt
Definition: cpp_typecheck_resolve.h:29
typet
The type of an expression, extends irept.
Definition: type.h:28
cpp_typecheck_resolvet::resolve_identifierst
std::vector< exprt > resolve_identifierst
Definition: cpp_typecheck_resolve.h:51
cpp_typecheck_resolvet
Definition: cpp_typecheck_resolve.h:23
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:990
exprt
Base class for all expressions.
Definition: expr.h:55
struct_tag_typet
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:448
cpp_typecheck_resolvet::cpp_typecheck
cpp_typecheckt & cpp_typecheck
Definition: cpp_typecheck_resolve.h:47
cpp_template_args.h
cpp_template_args_tct
Definition: cpp_template_args.h:64
cpp_idt
Definition: cpp_id.h:22
cpp_typecheck_resolvet::original_scope
cpp_scopet * original_scope
Definition: cpp_typecheck_resolve.h:49
cpp_typecheck_resolvet::wantt::TYPE
@ TYPE
cpp_typecheck_resolvet::matcht::full_args
cpp_template_args_tct full_args
Definition: cpp_typecheck_resolve.h:148
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:87
cpp_typecheck_resolvet::matcht::cost
std::size_t cost
Definition: cpp_typecheck_resolve.h:146
cpp_typecheck_resolvet::remove_duplicates
void remove_duplicates(resolve_identifierst &identifiers)
Definition: cpp_typecheck_resolve.cpp:148
cpp_scopest::id_sett
std::set< cpp_idt * > id_sett
Definition: cpp_scopes.h:30
cpp_typecheck_resolvet::resolve_namespace
cpp_scopet & resolve_namespace(const cpp_namet &cpp_name)
Definition: cpp_typecheck_resolve.cpp:1227
std_types.h
cpp_typecheck_resolvet::cpp_typecheck_resolvet
cpp_typecheck_resolvet(class cpp_typecheckt &_cpp_typecheck)
Definition: cpp_typecheck_resolve.cpp:37
cpp_typecheck_resolvet::matcht::specialization_args
cpp_template_args_tct specialization_args
Definition: cpp_typecheck_resolve.h:147
cpp_typecheck_resolvet::wantt::BOTH
@ BOTH
cpp_typecheckt
Definition: cpp_typecheck.h:39
cpp_typecheck_resolvet::filter_for_named_scopes
void filter_for_named_scopes(cpp_scopest::id_sett &id_set)
Definition: cpp_typecheck_resolve.cpp:2183
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:1359
cpp_typecheck_resolvet::matcht::id
irep_idt id
Definition: cpp_typecheck_resolve.h:149
cpp_typecheck_resolvet::remove_templates
void remove_templates(resolve_identifierst &identifiers)
Definition: cpp_typecheck_resolve.cpp:135
cpp_typecheck_resolvet::resolve_argument
void resolve_argument(exprt &argument, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:646
cpp_template_args_non_tct
Definition: cpp_template_args.h:44
cpp_typecheck_resolvet::exact_match_functions
void exact_match_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:412
source_locationt
Definition: source_location.h:18
cpp_typecheck_resolvet::guess_template_args
void guess_template_args(const typet &template_parameter, const typet &desired_type)
Definition: cpp_typecheck_resolve.cpp:1742
cpp_typecheck_resolvet::convert_template_parameter
exprt convert_template_parameter(const cpp_idt &id)
Definition: cpp_typecheck_resolve.cpp:181
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:150
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:856
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:43
cpp_typecheck_resolvet::wantt::VAR
@ VAR
cpp_typecheck_resolvet::matcht::operator<
bool operator<(const matcht &other) const
Definition: cpp_typecheck_resolve.h:161
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:63
cpp_typecheck_resolvet::disambiguate_functions
void disambiguate_functions(resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs)
Definition: cpp_typecheck_resolve.cpp:434
cpp_typecheck_resolvet::filter_for_namespaces
void filter_for_namespaces(cpp_scopest::id_sett &id_set)
Definition: cpp_typecheck_resolve.cpp:2301
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:660
cpp_namet
Definition: cpp_name.h:16
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:2321
cpp_typecheck_resolvet::make_constructors
void make_constructors(resolve_identifierst &identifiers)
Definition: cpp_typecheck_resolve.cpp:571
cpp_typecheck_resolvet::source_location
source_locationt source_location
Definition: cpp_typecheck_resolve.h:48