cprover
cpp_declarator_converter.cpp
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 
13 
14 #include <util/c_types.h>
16 #include <util/source_location.h>
17 #include <util/std_types.h>
18 
19 #include "cpp_type2name.h"
20 #include "cpp_typecheck.h"
21 
23  class cpp_typecheckt &_cpp_typecheck):
24  is_typedef(false),
25  is_template(false),
26  is_template_parameter(false),
27  is_friend(false),
28  linkage_spec(_cpp_typecheck.current_linkage_spec),
29  cpp_typecheck(_cpp_typecheck),
30  is_code(false)
31 {
32 }
33 
35  const typet &declaration_type,
36  const cpp_storage_spect &storage_spec,
37  const cpp_member_spect &member_spec,
38  cpp_declaratort &declarator)
39 {
40  assert(declaration_type.is_not_nil());
41 
42  if(declaration_type.id()=="cpp-cast-operator")
43  {
44  typet type;
45  type.swap(declarator.name().get_sub().back());
46  declarator.type().subtype()=type;
48  cpp_namet::namet name("(" + cpp_type2name(type) + ")");
49  declarator.name().get_sub().back().swap(name);
50  }
51 
52  assert(declarator.id()==ID_cpp_declarator);
53  final_type=declarator.merge_type(declaration_type);
54  assert(final_type.is_not_nil());
55 
56  cpp_storage_spect final_storage_spec = storage_spec;
57  final_storage_spec |= cpp_storage_spect(final_type);
58 
59  cpp_template_args_non_tct template_args;
60 
61  // run resolver on scope
62  {
64 
65  cpp_typecheck_resolvet cpp_typecheck_resolve(cpp_typecheck);
66 
67  cpp_typecheck_resolve.resolve_scope(
68  declarator.name(), base_name, template_args);
69 
70  cpp_scopet *friend_scope = nullptr;
71 
72  if(is_friend)
73  {
74  friend_scope = &cpp_typecheck.cpp_scopes.current_scope();
75  save_scope.restore();
76  }
77 
79 
80  // check the declarator-part of the type, in the current scope
81  if(declarator.value().is_nil() || !cpp_typecheck.has_auto(final_type))
83 
84  if(friend_scope)
85  scope = friend_scope;
86  }
87 
89 
90  // global-scope arrays must have fixed size
91  if(scope->is_global_scope())
93 
95 
96  if(is_typedef)
97  final_type.set(ID_C_typedef, final_identifier);
98 
99  // first see if it is a member
101  {
102  // it's a member! it must be declared already, unless it's a friend
103 
104  typet &method_qualifier=
105  static_cast<typet &>(declarator.method_qualifier());
106 
107  // adjust template type
108  if(final_type.id()==ID_template)
109  {
110  UNREACHABLE;
111  typet tmp;
112  tmp.swap(final_type.subtype());
113  final_type.swap(tmp);
114  }
115 
116  // try static first
117  auto maybe_symbol=
119 
120  if(!maybe_symbol)
121  {
122  // adjust type if it's a non-static member function
123  if(final_type.id()==ID_code)
124  {
127 
131  method_qualifier);
132  }
133 
135 
136  // try again
138  if(!maybe_symbol && is_friend)
139  {
140  symbolt &friend_symbol =
141  convert_new_symbol(final_storage_spec, member_spec, declarator);
142  // mark it as weak so that the full declaration can replace the symbol
143  friend_symbol.is_weak = true;
144  return friend_symbol;
145  }
146  else if(!maybe_symbol)
147  {
149  declarator.name().source_location();
151  << "member '" << base_name << "' not found in scope '"
152  << scope->identifier << "'" << messaget::eom;
153  throw 0;
154  }
155  }
156 
157  symbolt &symbol=*maybe_symbol;
158 
159  combine_types(declarator.name().source_location(), final_type, symbol);
160  enforce_rules(symbol);
161 
162  // If it is a constructor, we take care of the
163  // object initialization
164  if(to_code_type(final_type).return_type().id() == ID_constructor)
165  {
166  const cpp_namet &name=declarator.name();
167 
168  exprt symbol_expr=
170  name,
173 
174  if(symbol_expr.id() != ID_type)
175  {
177  cpp_typecheck.error() << "error: expected type"
178  << messaget::eom;
179  throw 0;
180  }
181 
182  irep_idt identifier=symbol_expr.type().get(ID_identifier);
183  const symbolt &symb=cpp_typecheck.lookup(identifier);
184  const struct_typet &type = to_struct_type(symb.type);
185 
186  if(declarator.find(ID_member_initializers).is_nil())
187  declarator.set(ID_member_initializers, ID_member_initializers);
188 
190  type.bases(), type.components(), declarator.member_initializers());
191 
193  type, declarator.member_initializers());
194  }
195 
196  if(!final_storage_spec.is_extern())
197  symbol.is_extern=false;
198 
199  // initializer?
200  handle_initializer(symbol, declarator);
201 
202  return symbol;
203  }
204  else
205  {
206  // no, it's no way a method
207 
208  // we won't allow the constructor/destructor type
209  if(final_type.id()==ID_code &&
210  to_code_type(final_type).return_type().id()==ID_constructor)
211  {
213  cpp_typecheck.error() << "function must have return type"
214  << messaget::eom;
215  throw 0;
216  }
217 
218  // already there?
219  const auto maybe_symbol=
221  if(!maybe_symbol)
222  return convert_new_symbol(final_storage_spec, member_spec, declarator);
223  symbolt &symbol=*maybe_symbol;
224 
225  if(!final_storage_spec.is_extern())
226  symbol.is_extern = false;
227 
228  if(declarator.get_bool(ID_C_template_case))
229  return symbol;
230 
231  combine_types(declarator.name().source_location(), final_type, symbol);
232  enforce_rules(symbol);
233 
234  // initializer?
235  handle_initializer(symbol, declarator);
236 
237  if(symbol.type.id()=="cpp-template-type")
238  {
239  const auto id_set = scope->lookup_identifier(
241 
242  if(id_set.empty())
243  {
244  cpp_idt &identifier=
247  }
248  }
249 
250  return symbol;
251  }
252 }
253 
255  const source_locationt &source_location,
256  const typet &decl_type,
257  symbolt &symbol)
258 {
259  if(symbol.type.id()==decl_type.id() &&
260  decl_type.id()==ID_code)
261  {
262  // functions need special treatment due
263  // to argument names, default values, and inlined-ness
264  const code_typet &decl_code_type=to_code_type(decl_type);
265  code_typet &symbol_code_type=to_code_type(symbol.type);
266 
267  if(decl_code_type.get_inlined())
268  symbol_code_type.set_inlined(true);
269 
270  if(decl_code_type.return_type()==symbol_code_type.return_type() &&
271  decl_code_type.parameters().size()==symbol_code_type.parameters().size())
272  {
273  for(std::size_t i=0; i<decl_code_type.parameters().size(); i++)
274  {
275  const code_typet::parametert &decl_parameter=
276  decl_code_type.parameters()[i];
277  code_typet::parametert &symbol_parameter=
278  symbol_code_type.parameters()[i];
279 
280  // first check type
281  if(decl_parameter.type()!=symbol_parameter.type())
282  {
283  // The 'this' parameter of virtual functions mismatches
284  if(i != 0 || !symbol_code_type.get_bool(ID_C_is_virtual))
285  {
286  cpp_typecheck.error().source_location=source_location;
288  << "symbol '" << symbol.display_name() << "': parameter "
289  << (i + 1) << " type mismatch\n"
290  << "previous type: "
291  << cpp_typecheck.to_string(symbol_parameter.type())
292  << "\nnew type: "
293  << cpp_typecheck.to_string(decl_parameter.type())
294  << messaget::eom;
295  throw 0;
296  }
297  }
298 
299  if(symbol.value.is_nil())
300  {
301  symbol_parameter.set_base_name(decl_parameter.get_base_name());
302  // set an empty identifier when no body is available
303  symbol_parameter.set_identifier(irep_idt());
304  symbol_parameter.add_source_location()=
305  decl_parameter.source_location();
306  }
307  }
308 
309  // ok
310  return;
311  }
312  }
313  else if(symbol.type==decl_type)
314  return; // ok
315  else if(symbol.type.id()==ID_array &&
316  symbol.type.find(ID_size).is_nil() &&
317  decl_type.id()==ID_array &&
318  symbol.type.subtype()==decl_type.subtype())
319  {
320  symbol.type = decl_type;
321  return; // ok
322  }
323 
324  cpp_typecheck.error().source_location=source_location;
325  cpp_typecheck.error() << "symbol '" << symbol.display_name()
326  << "' already declared with different type:\n"
327  << "original: " << cpp_typecheck.to_string(symbol.type)
328  << "\n new: " << cpp_typecheck.to_string(final_type)
329  << messaget::eom;
330  throw 0;
331 }
332 
334 {
335  // enforce rules for operator overloading
337 
338  // enforce rules about main()
339  main_function_rules(symbol);
340 }
341 
343  symbolt &symbol,
344  cpp_declaratort &declarator)
345 {
346  exprt &value=declarator.value();
347 
348  // moves member initializers into 'value' - only methods have these
349  if(symbol.type.id() == ID_code)
351  declarator.member_initializers(), to_code_type(symbol.type), value);
352 
353  // any initializer to be done?
354  if(value.is_nil())
355  return;
356 
357  if(symbol.is_extern)
358  {
359  // the symbol is really located here
360  symbol.is_extern=false;
361  }
362 
363  if(symbol.value.is_nil())
364  {
365  // no initial value yet
366  symbol.value.swap(value);
367 
368  if(!is_code)
370  }
371  else
372  {
373 #if 0
374  cpp_typecheck.error().source_location=source_location;
375 
376  if(is_code)
377  {
378  cpp_typecheck.error() << "body of function '"
379  << symbol.display_name()
380  << "' has already been defined" << messaget::eom;
381  }
382  else
383  {
384  cpp_typecheck.error() << "symbol '"
385  << symbol.display_name()
386  << "' already has an initializer" << messaget::eom;
387  }
388 
389  throw 0;
390 #endif
391  }
392 }
393 
395 {
396  std::string identifier=id2string(base_name);
397 
398  // main is always "C" linkage, as a matter of principle
399  if(is_code && base_name == ID_main && scope->prefix.empty())
400  {
401  linkage_spec=ID_C;
402  }
403 
404  if(is_code)
405  {
406  if(linkage_spec==ID_C)
407  {
408  // fine as is
409  }
410  else if(linkage_spec==ID_auto ||
411  linkage_spec==ID_cpp)
412  {
413  // Is there already an `extern "C"' function with the same name
414  // and the same signature?
415  symbol_tablet::symbolst::const_iterator
416  c_it=cpp_typecheck.symbol_table.symbols.find(identifier);
417 
418  if(c_it!=cpp_typecheck.symbol_table.symbols.end() &&
419  c_it->second.type.id()==ID_code &&
421  cpp_typecheck.function_identifier(c_it->second.type))
422  {
423  // leave as is, no decoration
424  }
425  else
426  {
427  // add C++ decoration
429  }
430  }
431  }
432 
433  final_identifier = scope->prefix + identifier;
434 }
435 
437  const cpp_storage_spect &storage_spec,
438  const cpp_member_spect &member_spec,
439  cpp_declaratort &declarator)
440 {
441  irep_idt pretty_name=get_pretty_name();
442 
443  symbolt symbol;
444 
445  symbol.name=final_identifier;
446  symbol.base_name=base_name;
447  symbol.value=declarator.value();
448  symbol.location=declarator.name().source_location();
449  symbol.is_extern = storage_spec.is_extern();
450  symbol.is_parameter = declarator.get_is_parameter();
451  symbol.is_weak = storage_spec.is_weak();
452  symbol.mode=linkage_spec==ID_auto?ID_cpp:linkage_spec;
453  symbol.module=cpp_typecheck.module;
454  symbol.type=final_type;
455  symbol.is_type=is_typedef;
457  symbol.pretty_name=pretty_name;
458 
459  if(is_code && !symbol.is_type)
460  {
461  // it is a function
462  symbol.is_static_lifetime = false;
463  symbol.is_thread_local = false;
464 
465  symbol.is_file_local = storage_spec.is_static();
466 
467  if(member_spec.is_inline())
468  to_code_type(symbol.type).set_inlined(true);
469 
470  if(symbol.value.is_nil())
471  {
472  // we don't need the identifiers
473  for(auto &parameter : to_code_type(symbol.type).parameters())
474  parameter.set_identifier(irep_idt());
475  }
476  }
477  else
478  {
479  symbol.is_lvalue =
480  !is_reference(symbol.type) &&
481  !(symbol.type.get_bool(ID_C_constant) && is_number(symbol.type) &&
482  symbol.value.id() == ID_constant);
483 
484  symbol.is_static_lifetime =
485  !symbol.is_macro && !symbol.is_type &&
487  storage_spec.is_static());
488 
489  symbol.is_thread_local =
490  (!symbol.is_static_lifetime && !storage_spec.is_extern()) ||
491  storage_spec.is_thread_local();
492 
493  symbol.is_file_local =
494  symbol.is_macro ||
496  !storage_spec.is_extern()) ||
498  storage_spec.is_static()) ||
499  symbol.is_parameter;
500  }
501 
502  if(symbol.is_static_lifetime)
503  cpp_typecheck.dynamic_initializations.push_back(symbol.name);
504 
505  // move early, it must be visible before doing any value
506  symbolt *new_symbol;
507 
508  if(cpp_typecheck.symbol_table.move(symbol, new_symbol))
509  {
512  << "cpp_typecheckt::convert_declarator: symbol_table.move() failed"
513  << messaget::eom;
514  throw 0;
515  }
516 
517  if(!is_code)
518  {
519  const auto id_set = cpp_typecheck.cpp_scopes.current_scope().lookup(
521 
522  for(const auto &id_ptr : id_set)
523  {
524  const cpp_idt &id = *id_ptr;
525  // the name is already in the scope
526  // this is ok if they belong to different categories
527 
528  if(!id.is_class() && !id.is_enum())
529  {
532  << "'" << base_name << "' already in scope" << messaget::eom;
533  throw 0;
534  }
535  }
536  }
537 
538  // put into scope
539  cpp_idt &identifier=
541 
542  if(is_template)
544  else if(is_template_parameter)
546  else if(is_typedef)
548  else
550 
551  // do the value
552  if(!new_symbol->is_type)
553  {
554  if(is_code && declarator.type().id()!=ID_template)
555  cpp_typecheck.add_method_body(new_symbol);
556 
557  if(!is_code)
558  cpp_typecheck.convert_initializer(*new_symbol);
559  }
560 
561  enforce_rules(*new_symbol);
562 
563  return *new_symbol;
564 }
565 
567 {
568  if(is_code)
569  {
570  const irept::subt &parameters=
571  final_type.find(ID_parameters).get_sub();
572 
573  std::string result=scope->prefix+id2string(base_name)+"(";
574 
575  forall_irep(it, parameters)
576  {
577  const typet &parameter_type=((exprt &)*it).type();
578 
579  if(it!=parameters.begin())
580  result+=", ";
581 
582  result+=cpp_typecheck.to_string(parameter_type);
583  }
584 
585  result+=')';
586 
587  return result;
588  }
589 
590  return scope->prefix+id2string(base_name);
591 }
592 
594  const symbolt &)
595 {
596 }
597 
599  const symbolt &symbol)
600 {
601  if(symbol.name==ID_main)
602  {
603  if(symbol.type.id()!=ID_code)
604  {
606  cpp_typecheck.error() << "main must be function" << messaget::eom;
607  throw 0;
608  }
609 
610  const typet &return_type=
611  to_code_type(symbol.type).return_type();
612 
613  if(return_type!=signed_int_type())
614  {
615  // Too many embedded compilers ignore this rule.
616  #if 0
618  throw "main must return int";
619  #endif
620  }
621  }
622 }
cpp_declarator_convertert::final_type
typet final_type
Definition: cpp_declarator_converter.h:58
cpp_declarator_convertert::is_template
bool is_template
Definition: cpp_declarator_converter.h:32
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition: invariant.h:504
struct_union_typet::components
const componentst & components() const
Definition: std_types.h:142
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
cpp_storage_spect
Definition: cpp_storage_spec.h:16
typet::subtype
const typet & subtype() const
Definition: type.h:47
cpp_declarator_convertert::operator_overloading_rules
void operator_overloading_rules(const symbolt &symbol)
Definition: cpp_declarator_converter.cpp:593
cpp_scopet
Definition: cpp_scope.h:21
is_number
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv,...
Definition: mathematical_types.cpp:17
symbolt::is_macro
bool is_macro
Definition: symbol.h:61
cpp_typecheck_fargst
Definition: cpp_typecheck_fargs.h:23
cpp_idt::id_classt::CLASS
@ CLASS
to_struct_type
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition: std_types.h:303
cpp_save_scopet
Definition: cpp_scopes.h:129
cpp_idt::id_classt::TEMPLATE
@ TEMPLATE
cpp_typecheckt::cpp_scopes
cpp_scopest cpp_scopes
Definition: cpp_typecheck.h:109
cpp_scopet::lookup
id_sett lookup(const irep_idt &base_name_to_lookup, lookup_kindt kind)
Definition: cpp_scope.h:32
symbolt::display_name
const irep_idt & display_name() const
Return language specific display name if present.
Definition: symbol.h:55
typet
The type of an expression, extends irept.
Definition: type.h:29
cpp_namet::namet
Definition: cpp_name.h:27
cpp_declarator_convertert::main_function_rules
void main_function_rules(const symbolt &symbol)
Definition: cpp_declarator_converter.cpp:598
cpp_typecheckt::check_fixed_size_array
void check_fixed_size_array(typet &type)
check that an array has fixed size
Definition: cpp_typecheck_compound_type.cpp:757
symbolt::type
typet type
Type of symbol.
Definition: symbol.h:31
code_typet::parametert::set_identifier
void set_identifier(const irep_idt &identifier)
Definition: std_types.h:782
cpp_idt::identifier
irep_idt identifier
Definition: cpp_id.h:78
cpp_type2name.h
C++ Language Module.
cpp_declaratort::name
cpp_namet & name()
Definition: cpp_declarator.h:36
irept::find
const irept & find(const irep_namet &name) const
Definition: irep.cpp:103
cpp_typecheck_resolvet
Definition: cpp_typecheck_resolve.h:21
cpp_declarator_convertert::convert
symbolt & convert(const typet &type, const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, cpp_declaratort &declarator)
Definition: cpp_declarator_converter.cpp:34
exprt
Base class for all expressions.
Definition: expr.h:53
cpp_storage_spect::is_extern
bool is_extern() const
Definition: cpp_storage_spec.h:38
symbolt::base_name
irep_idt base_name
Base (non-scoped) name.
Definition: symbol.h:46
cpp_declaratort::get_is_parameter
bool get_is_parameter() const
Definition: cpp_declarator.h:48
irep_idt
dstringt irep_idt
Definition: irep.h:32
cpp_scopet::SCOPE_ONLY
@ SCOPE_ONLY
Definition: cpp_scope.h:30
messaget::eom
static eomt eom
Definition: message.h:297
cpp_declarator_convertert::get_final_identifier
void get_final_identifier()
Definition: cpp_declarator_converter.cpp:394
cpp_scopet::lookup_identifier
id_sett lookup_identifier(const irep_idt &id, cpp_idt::id_classt identifier_class)
Definition: cpp_scope.cpp:159
cpp_scopest::put_into_scope
cpp_idt & put_into_scope(const symbolt &symbol, cpp_scopet &scope, bool is_friend=false)
Definition: cpp_scopes.cpp:22
cpp_storage_spect::is_static
bool is_static() const
Definition: cpp_storage_spec.h:37
cpp_idt
Definition: cpp_id.h:29
cpp_typecheck
bool cpp_typecheck(cpp_parse_treet &cpp_parse_tree, symbol_tablet &symbol_table, const std::string &module, message_handlert &message_handler)
Definition: cpp_typecheck.cpp:89
symbolt::pretty_name
irep_idt pretty_name
Language-specific display name.
Definition: symbol.h:52
cpp_typecheck_resolvet::wantt::TYPE
@ TYPE
mathematical_types.h
Mathematical types.
cpp_member_spect::is_inline
bool is_inline() const
Definition: cpp_member_spec.h:24
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:81
symbolt::is_thread_local
bool is_thread_local
Definition: symbol.h:65
namespacet::lookup
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Definition: namespace.cpp:140
cpp_typecheckt::typecheck_type
void typecheck_type(typet &) override
Definition: cpp_typecheck_type.cpp:23
irept::get_bool
bool get_bool(const irep_namet &name) const
Definition: irep.cpp:64
irept::is_not_nil
bool is_not_nil() const
Definition: irep.h:402
c_typecheck_baset::module
const irep_idt module
Definition: c_typecheck_base.h:68
to_code_type
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
Definition: std_types.h:946
cpp_declarator_convertert::is_code_type
bool is_code_type(const typet &type) const
Definition: cpp_declarator_converter.h:84
symbolt::mode
irep_idt mode
Language mode.
Definition: symbol.h:49
messaget::error
mstreamt & error() const
Definition: message.h:399
cpp_idt::id_classt::SYMBOL
@ SYMBOL
code_typet::parametert::get_base_name
const irep_idt & get_base_name() const
Definition: std_types.h:797
signed_int_type
signedbv_typet signed_int_type()
Definition: c_types.cpp:30
cpp_typecheckt::add_method_body
void add_method_body(symbolt *_method_symbol)
Definition: cpp_typecheck_method_bodies.cpp:51
cpp_typecheckt::convert_initializer
void convert_initializer(symbolt &symbol)
Initialize an object with a value.
Definition: cpp_typecheck_initializer.cpp:22
cpp_idt::id_classt::TEMPLATE_PARAMETER
@ TEMPLATE_PARAMETER
id2string
const std::string & id2string(const irep_idt &d)
Definition: irep.h:44
cpp_scopest::current_scope
cpp_scopet & current_scope()
Definition: cpp_scopes.h:33
messaget::mstreamt::source_location
source_locationt source_location
Definition: message.h:247
cpp_declarator_convertert::is_friend
bool is_friend
Definition: cpp_declarator_converter.h:34
cpp_declarator_convertert::is_typedef
bool is_typedef
Definition: cpp_declarator_converter.h:31
std_types.h
Pre-defined types.
cpp_typecheckt::check_member_initializers
void check_member_initializers(const struct_typet::basest &bases, const struct_typet::componentst &components, const irept &initializers)
Check a constructor initialization-list.
Definition: cpp_typecheck_constructor.cpp:418
code_typet::set_inlined
void set_inlined(bool value)
Definition: std_types.h:872
source_location.h
struct_typet::bases
const basest & bases() const
Get the collection of base classes/structs.
Definition: std_types.h:257
c_typecheck_baset::symbol_table
symbol_tablet & symbol_table
Definition: c_typecheck_base.h:67
cpp_declarator_convertert::get_pretty_name
irep_idt get_pretty_name()
Definition: cpp_declarator_converter.cpp:566
cpp_declarator_convertert::is_template_parameter
bool is_template_parameter
Definition: cpp_declarator_converter.h:33
irept::swap
void swap(irept &irep)
Definition: irep.h:463
code_typet
Base type of functions.
Definition: std_types.h:736
cpp_typecheckt
Definition: cpp_typecheck.h:45
symbolt::is_parameter
bool is_parameter
Definition: symbol.h:67
irept::is_nil
bool is_nil() const
Definition: irep.h:398
irept::id
const irep_idt & id() const
Definition: irep.h:418
cpp_declarator_convertert::convert_new_symbol
symbolt & convert_new_symbol(const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, cpp_declaratort &declarator)
Definition: cpp_declarator_converter.cpp:436
cpp_scopet::is_global_scope
bool is_global_scope() const
Definition: cpp_scope.h:82
cpp_typecheckt::function_identifier
irep_idt function_identifier(const typet &type)
for function overloading
Definition: cpp_typecheck_function.cpp:158
cpp_scopest::go_to
void go_to(cpp_idt &id)
Definition: cpp_scopes.h:104
code_typet::parameters
const parameterst & parameters() const
Definition: std_types.h:857
cpp_declaratort::member_initializers
irept & member_initializers()
Definition: cpp_declarator.h:71
cpp_typecheck.h
C++ Language Type Checking.
sharing_treet< irept, std::map< irep_namet, irept > >::subt
typename dt::subt subt
Definition: irep.h:182
cpp_template_args_non_tct
Definition: cpp_template_args.h:45
code_typet::parametert::set_base_name
void set_base_name(const irep_idt &name)
Definition: std_types.h:787
symbol_tablet::move
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
Definition: symbol_table.cpp:69
source_locationt
Definition: source_location.h:20
cpp_typecheckt::full_member_initialization
void full_member_initialization(const struct_union_typet &struct_union_type, irept &initializers)
Build the full initialization list of the constructor.
Definition: cpp_typecheck_constructor.cpp:545
cpp_declarator_convertert::handle_initializer
void handle_initializer(symbolt &symbol, cpp_declaratort &declarator)
Definition: cpp_declarator_converter.cpp:342
symbol_tablet::get_writeable
virtual symbolt * get_writeable(const irep_idt &name) override
Find a symbol in the symbol table for read-write access.
Definition: symbol_table.h:96
symbolt::value
exprt value
Initial value of symbol.
Definition: symbol.h:34
forall_irep
#define forall_irep(it, irep)
Definition: irep.h:62
cpp_typecheckt::add_this_to_method_type
void add_this_to_method_type(const symbolt &compound_symbol, code_typet &method_type, const typet &method_qualifier)
Definition: cpp_typecheck_compound_type.cpp:1338
struct_typet
Structure type, corresponds to C style structs.
Definition: std_types.h:226
cpp_namet::source_location
const source_locationt & source_location() const
Definition: cpp_name.h:73
cpp_idt::id_classt::TYPEDEF
@ TYPEDEF
cpp_declarator_convertert::base_name
irep_idt base_name
Definition: cpp_declarator_converter.h:57
symbolt::is_extern
bool is_extern
Definition: symbol.h:66
cpp_save_scopet::restore
void restore()
Definition: cpp_scopes.h:142
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_type2name
std::string cpp_type2name(const typet &type)
Definition: cpp_type2name.cpp:97
is_reference
bool is_reference(const typet &type)
Returns true if the type is a reference.
Definition: std_types.cpp:133
irept::get
const irep_idt & get(const irep_namet &name) const
Definition: irep.cpp:51
symbolt::location
source_locationt location
Source code location of definition of symbol.
Definition: symbol.h:37
symbolt
Symbol table entry.
Definition: symbol.h:28
irept::set
void set(const irep_namet &name, const irep_idt &value)
Definition: irep.h:442
symbol_table_baset::symbols
const symbolst & symbols
Read-only field, used to look up symbols given their names.
Definition: symbol_table_base.h:30
symbolt::is_type
bool is_type
Definition: symbol.h:61
cpp_declaratort::method_qualifier
irept & method_qualifier()
Definition: cpp_declarator.h:68
cpp_typecheckt::has_auto
static bool has_auto(const typet &type)
Definition: cpp_typecheck_compound_type.cpp:64
cpp_idt::id_class
id_classt id_class
Definition: cpp_id.h:51
irept::get_sub
subt & get_sub()
Definition: irep.h:477
cpp_storage_spect::is_thread_local
bool is_thread_local() const
Definition: cpp_storage_spec.h:42
code_typet::parametert
Definition: std_types.h:753
symbolt::is_static_lifetime
bool is_static_lifetime
Definition: symbol.h:65
code_typet::get_inlined
bool get_inlined() const
Definition: std_types.h:867
cpp_declarator_convertert::enforce_rules
void enforce_rules(const symbolt &symbol)
Definition: cpp_declarator_converter.cpp:333
cpp_declaratort::value
exprt & value()
Definition: cpp_declarator.h:42
cpp_idt::prefix
std::string prefix
Definition: cpp_id.h:85
code_typet::return_type
const typet & return_type() const
Definition: std_types.h:847
cpp_declarator_convertert::combine_types
void combine_types(const source_locationt &source_location, const typet &decl_type, symbolt &symbol)
Definition: cpp_declarator_converter.cpp:254
cpp_declarator_convertert::linkage_spec
irep_idt linkage_spec
Definition: cpp_declarator_converter.h:35
cpp_declarator_convertert::final_identifier
irep_idt final_identifier
Definition: cpp_declarator_converter.h:60
cpp_typecheckt::to_string
std::string to_string(const typet &) override
Definition: cpp_typecheck.cpp:84
cpp_declarator_convertert::is_code
bool is_code
Definition: cpp_declarator_converter.h:61
symbolt::is_file_local
bool is_file_local
Definition: symbol.h:66
symbolt::is_lvalue
bool is_lvalue
Definition: symbol.h:66
cpp_declarator_convertert::cpp_declarator_convertert
cpp_declarator_convertert(class cpp_typecheckt &_cpp_typecheck)
Definition: cpp_declarator_converter.cpp:22
exprt::add_source_location
source_locationt & add_source_location()
Definition: expr.h:259
symbolt::module
irep_idt module
Name of module the symbol belongs to.
Definition: symbol.h:43
cpp_typecheckt::resolve
exprt resolve(const cpp_namet &cpp_name, const cpp_typecheck_resolvet::wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
Definition: cpp_typecheck.h:88
cpp_namet
Definition: cpp_name.h:17
exprt::source_location
const source_locationt & source_location() const
Definition: expr.h:254
cpp_member_spect
Definition: cpp_member_spec.h:17
c_types.h
cpp_typecheckt::dynamic_initializations
dynamic_initializationst dynamic_initializations
Definition: cpp_typecheck.h:593
symbolt::is_weak
bool is_weak
Definition: symbol.h:67
symbolt::name
irep_idt name
The unique identifier.
Definition: symbol.h:40
cpp_storage_spect::is_weak
bool is_weak() const
Definition: cpp_storage_spec.h:44
cpp_declaratort
Definition: cpp_declarator.h:20
cpp_declarator_convertert::cpp_typecheck
class cpp_typecheckt & cpp_typecheck
Definition: cpp_declarator_converter.h:54
cpp_typecheckt::move_member_initializers
void move_member_initializers(irept &initializers, const code_typet &type, exprt &value)
Definition: cpp_typecheck_compound_type.cpp:1214
cpp_declarator_converter.h
C++ Language Type Checking.
cpp_declarator_convertert::scope
cpp_scopet * scope
Definition: cpp_declarator_converter.h:59
cpp_declaratort::merge_type
typet merge_type(const typet &declaration_type) const
Definition: cpp_declarator.cpp:28