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/source_location.h>
15 #include <util/std_types.h>
16 
17 #include <util/c_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_template_args_non_tct template_args;
57 
58  // run resolver on scope
59  {
61 
62  cpp_typecheck_resolvet cpp_typecheck_resolve(cpp_typecheck);
63 
64  cpp_typecheck_resolve.resolve_scope(
65  declarator.name(), base_name, template_args);
66 
68 
69  // check the declarator-part of the type, in that scope
70  if(declarator.value().is_nil() || !cpp_typecheck.has_auto(final_type))
72  }
73 
75 
76  // global-scope arrays must have fixed size
77  if(scope->is_global_scope())
79 
81 
82  // first see if it is a member
84  {
85  // it's a member! it must be declared already
86 
87  typet &method_qualifier=
88  static_cast<typet &>(declarator.method_qualifier());
89 
90  // adjust template type
91  if(final_type.id()==ID_template)
92  {
94  typet tmp;
95  tmp.swap(final_type.subtype());
96  final_type.swap(tmp);
97  }
98 
99  // try static first
100  auto maybe_symbol=
102 
103  if(!maybe_symbol)
104  {
105  // adjust type if it's a non-static member function
106  if(final_type.id()==ID_code)
110  method_qualifier);
111 
113 
114  // try again
116  if(!maybe_symbol)
117  {
119  declarator.name().source_location();
120  cpp_typecheck.error() << "member `" << base_name
121  << "' not found in scope `"
122  << scope->identifier << "'"
123  << messaget::eom;
124  throw 0;
125  }
126  }
127 
128  symbolt &symbol=*maybe_symbol;
129 
130  combine_types(declarator.name().source_location(), final_type, symbol);
131  enforce_rules(symbol);
132 
133  // If it is a constructor, we take care of the
134  // object initialization
135  if(to_code_type(final_type).return_type().id() == ID_constructor)
136  {
137  const cpp_namet &name=declarator.name();
138 
139  exprt symbol_expr=
141  name,
144 
145  if(
146  symbol_expr.id() != ID_type ||
147  symbol_expr.type().id() != ID_symbol_type)
148  {
150  cpp_typecheck.error() << "error: expected type"
151  << messaget::eom;
152  throw 0;
153  }
154 
155  irep_idt identifier=symbol_expr.type().get(ID_identifier);
156  const symbolt &symb=cpp_typecheck.lookup(identifier);
157  const struct_typet &type = to_struct_type(symb.type);
158 
159  if(declarator.find(ID_member_initializers).is_nil())
160  declarator.set(ID_member_initializers, ID_member_initializers);
161 
163  type.bases(), type.components(), declarator.member_initializers());
164 
166  type, declarator.member_initializers());
167  }
168 
169  if(!storage_spec.is_extern())
170  symbol.is_extern=false;
171 
172  // initializer?
173  handle_initializer(symbol, declarator);
174 
175  return symbol;
176  }
177  else
178  {
179  // no, it's no way a method
180 
181  // we won't allow the constructor/destructor type
182  if(final_type.id()==ID_code &&
183  to_code_type(final_type).return_type().id()==ID_constructor)
184  {
186  cpp_typecheck.error() << "function must have return type"
187  << messaget::eom;
188  throw 0;
189  }
190 
191  // already there?
192  const auto maybe_symbol=
194  if(!maybe_symbol)
195  return convert_new_symbol(storage_spec, member_spec, declarator);
196  symbolt &symbol=*maybe_symbol;
197 
198  if(!storage_spec.is_extern())
199  symbol.is_extern = false;
200 
201  if(declarator.get_bool(ID_C_template_case))
202  return symbol;
203 
204  combine_types(declarator.name().source_location(), final_type, symbol);
205  enforce_rules(symbol);
206 
207  // initializer?
208  handle_initializer(symbol, declarator);
209 
210  if(symbol.type.id()=="cpp-template-type")
211  {
212  const auto id_set = scope->lookup_identifier(
214 
215  if(id_set.empty())
216  {
217  cpp_idt &identifier=
220  }
221  }
222 
223  return symbol;
224  }
225 }
226 
228  const source_locationt &source_location,
229  const typet &decl_type,
230  symbolt &symbol)
231 {
232  if(symbol.type.id()==decl_type.id() &&
233  decl_type.id()==ID_code)
234  {
235  // functions need special treatment due
236  // to argument names, default values, and inlined-ness
237  const code_typet &decl_code_type=to_code_type(decl_type);
238  code_typet &symbol_code_type=to_code_type(symbol.type);
239 
240  if(decl_code_type.get_inlined())
241  symbol_code_type.set_inlined(true);
242 
243  if(decl_code_type.return_type()==symbol_code_type.return_type() &&
244  decl_code_type.parameters().size()==symbol_code_type.parameters().size())
245  {
246  for(std::size_t i=0; i<decl_code_type.parameters().size(); i++)
247  {
248  const code_typet::parametert &decl_parameter=
249  decl_code_type.parameters()[i];
250  code_typet::parametert &symbol_parameter=
251  symbol_code_type.parameters()[i];
252 
253  // first check type
254  if(decl_parameter.type()!=symbol_parameter.type())
255  {
256  // The 'this' parameter of virtual functions mismatches
257  if(i != 0 || !symbol_code_type.get_bool(ID_C_is_virtual))
258  {
259  cpp_typecheck.error().source_location=source_location;
260  cpp_typecheck.error() << "symbol `" << symbol.display_name()
261  << "': parameter " << (i+1)
262  << " type mismatch\n"
263  << "previous type: "
265  symbol_parameter.type())
266  << "\nnew type: "
268  decl_parameter.type())
269  << messaget::eom;
270  throw 0;
271  }
272  }
273 
274  if(symbol.value.is_nil())
275  {
276  symbol_parameter.set_base_name(decl_parameter.get_base_name());
277  symbol_parameter.set_identifier(decl_parameter.get_identifier());
278  symbol_parameter.add_source_location()=
279  decl_parameter.source_location();
280  }
281  }
282 
283  // ok
284  return;
285  }
286  }
287  else if(symbol.type==decl_type)
288  return; // ok
289  else if(symbol.type.id()==ID_array &&
290  symbol.type.find(ID_size).is_nil() &&
291  decl_type.id()==ID_array &&
292  symbol.type.subtype()==decl_type.subtype())
293  {
294  symbol.type = decl_type;
295  return; // ok
296  }
297 
298  cpp_typecheck.error().source_location=source_location;
299  cpp_typecheck.error() << "symbol `" << symbol.display_name()
300  << "' already declared with different type:\n"
301  << "original: "
302  << cpp_typecheck.to_string(symbol.type)
303  << "\n new: "
305  << messaget::eom;
306  throw 0;
307 }
308 
310 {
311  // enforce rules for operator overloading
313 
314  // enforce rules about main()
315  main_function_rules(symbol);
316 }
317 
319  symbolt &symbol,
320  cpp_declaratort &declarator)
321 {
322  exprt &value=declarator.value();
323 
324  // moves member initializers into 'value' - only methods have these
325  if(symbol.type.id() == ID_code)
327  declarator.member_initializers(), to_code_type(symbol.type), value);
328 
329  // any initializer to be done?
330  if(value.is_nil())
331  return;
332 
333  if(symbol.is_extern)
334  {
335  // the symbol is really located here
336  symbol.is_extern=false;
337  }
338 
339  if(symbol.value.is_nil())
340  {
341  // no initial value yet
342  symbol.value.swap(value);
343 
344  if(!is_code)
346  }
347  else
348  {
349  #if 0
350  cpp_typecheck.error().source_location=declarator.name());
351 
352  if(is_code)
353  cpp_typecheck.str << "body of function `"
354  << symbol.display_name()
355  << "' has already been defined";
356  else
357  cpp_typecheck.str << "symbol `"
358  << symbol.display_name()
359  << "' already has an initializer";
360 
361  throw 0;
362  #endif
363  }
364 }
365 
367 {
368  std::string identifier=id2string(base_name);
369 
370  // main is always "C" linkage, as a matter of principle
371  if(is_code &&
372  base_name==ID_main &&
373  scope->prefix=="")
374  {
375  linkage_spec=ID_C;
376  }
377 
378  if(is_code)
379  {
380  if(linkage_spec==ID_C)
381  {
382  // fine as is
383  }
384  else if(linkage_spec==ID_auto ||
385  linkage_spec==ID_cpp)
386  {
387  // Is there already an `extern "C"' function with the same name
388  // and the same signature?
389  symbol_tablet::symbolst::const_iterator
390  c_it=cpp_typecheck.symbol_table.symbols.find(identifier);
391 
392  if(c_it!=cpp_typecheck.symbol_table.symbols.end() &&
393  c_it->second.type.id()==ID_code &&
395  cpp_typecheck.function_identifier(c_it->second.type))
396  {
397  // leave as is, no decoration
398  }
399  else
400  {
401  // add C++ decoration
403  }
404  }
405  }
406 
408  scope->prefix+
409  identifier;
410 }
411 
413  const cpp_storage_spect &storage_spec,
414  const cpp_member_spect &member_spec,
415  cpp_declaratort &declarator)
416 {
417  irep_idt pretty_name=get_pretty_name();
418 
419  symbolt symbol;
420 
421  symbol.name=final_identifier;
422  symbol.base_name=base_name;
423  symbol.value=declarator.value();
424  symbol.location=declarator.name().source_location();
425  symbol.mode=linkage_spec==ID_auto?ID_cpp:linkage_spec;
426  symbol.module=cpp_typecheck.module;
427  symbol.type=final_type;
428  symbol.is_type=is_typedef;
430  symbol.pretty_name=pretty_name;
431 
432  // Constant? These are propagated.
433  if(symbol.type.get_bool(ID_C_constant) &&
434  symbol.value.is_not_nil())
435  symbol.is_macro=true;
436 
437  if(member_spec.is_inline())
438  symbol.type.set(ID_C_inlined, true);
439 
440  if(!symbol.is_type)
441  {
442  if(is_code)
443  {
444  // it is a function
445  if(storage_spec.is_static())
446  symbol.is_file_local=true;
447  }
448  else
449  {
450  // it is a variable
451  symbol.is_state_var=true;
452  symbol.is_lvalue = !is_reference(symbol.type) &&
453  !(symbol.type.get_bool(ID_C_constant) &&
454  is_number(symbol.type) &&
455  symbol.value.id() == ID_constant);
456 
458  {
459  symbol.is_static_lifetime=true;
460 
461  if(storage_spec.is_extern())
462  symbol.is_extern=true;
463  }
464  else
465  {
466  if(storage_spec.is_static())
467  {
468  symbol.is_static_lifetime=true;
469  symbol.is_file_local=true;
470  }
471  else if(storage_spec.is_extern())
472  {
473  cpp_typecheck.error().source_location=storage_spec.location();
474  cpp_typecheck.error() << "external storage not permitted here"
475  << messaget::eom;
476  throw 0;
477  }
478  }
479  }
480  }
481 
482  if(symbol.is_static_lifetime)
483  cpp_typecheck.dynamic_initializations.push_back(symbol.name);
484 
485  // move early, it must be visible before doing any value
486  symbolt *new_symbol;
487 
488  if(cpp_typecheck.symbol_table.move(symbol, new_symbol))
489  {
492  << "cpp_typecheckt::convert_declarator: symbol_table.move() failed"
493  << messaget::eom;
494  throw 0;
495  }
496 
497  if(!is_code)
498  {
499  const auto id_set = cpp_typecheck.cpp_scopes.current_scope().lookup(
501 
502  for(const auto &id_ptr : id_set)
503  {
504  const cpp_idt &id = *id_ptr;
505  // the name is already in the scope
506  // this is ok if they belong to different categories
507 
508  if(!id.is_class() && !id.is_enum())
509  {
511  cpp_typecheck.error() << "`" << base_name
512  << "' already in scope"
513  << messaget::eom;
514  throw 0;
515  }
516  }
517  }
518 
519  // put into scope
520  cpp_idt &identifier=
522 
523  if(is_template)
525  else if(is_template_parameter)
527  else if(is_typedef)
529  else
531 
532  // do the value
533  if(!new_symbol->is_type)
534  {
535  if(is_code && declarator.type().id()!=ID_template)
536  cpp_typecheck.add_method_body(new_symbol);
537 
538  if(!is_code)
539  cpp_typecheck.convert_initializer(*new_symbol);
540  }
541 
542  enforce_rules(*new_symbol);
543 
544  return *new_symbol;
545 }
546 
548 {
549  if(is_code)
550  {
551  const irept::subt &parameters=
552  final_type.find(ID_parameters).get_sub();
553 
554  std::string result=scope->prefix+id2string(base_name)+"(";
555 
556  forall_irep(it, parameters)
557  {
558  const typet &parameter_type=((exprt &)*it).type();
559 
560  if(it!=parameters.begin())
561  result+=", ";
562 
563  result+=cpp_typecheck.to_string(parameter_type);
564  }
565 
566  result+=')';
567 
568  return result;
569  }
570 
571  return scope->prefix+id2string(base_name);
572 }
573 
575  const symbolt &)
576 {
577 }
578 
580  const symbolt &symbol)
581 {
582  if(symbol.name==ID_main)
583  {
584  if(symbol.type.id()!=ID_code)
585  {
587  cpp_typecheck.error() << "main must be function" << messaget::eom;
588  throw 0;
589  }
590 
591  const typet &return_type=
592  to_code_type(symbol.type).return_type();
593 
594  if(return_type!=signed_int_type())
595  {
596  // Too many embedded compilers ignore this rule.
597  #if 0
599  throw "main must return int";
600  #endif
601  }
602  }
603 }
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
struct_union_typet::components
const componentst & components() const
Definition: std_types.h:205
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:35
cpp_storage_spect
Definition: cpp_storage_spec.h:15
symbolt::is_state_var
bool is_state_var
Definition: symbol.h:61
typet::subtype
const typet & subtype() const
Definition: type.h:38
cpp_declarator_convertert::operator_overloading_rules
void operator_overloading_rules(const symbolt &symbol)
Definition: cpp_declarator_converter.cpp:574
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:22
cpp_idt::id_classt::CLASS
to_struct_type
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition: std_types.h:349
cpp_save_scopet
Definition: cpp_scopes.h:128
cpp_idt::id_classt::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:27
cpp_namet::namet
Definition: cpp_name.h:26
cpp_declarator_convertert::main_function_rules
void main_function_rules(const symbolt &symbol)
Definition: cpp_declarator_converter.cpp:579
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:764
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:818
cpp_idt::identifier
irep_idt identifier
Definition: cpp_id.h:73
cpp_type2name.h
cpp_declaratort::name
cpp_namet & name()
Definition: cpp_declarator.h:36
irept::find
const irept & find(const irep_namet &name) const
Definition: irep.cpp:284
cpp_typecheck_resolvet
Definition: cpp_typecheck_resolve.h:20
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:54
cpp_storage_spect::is_extern
bool is_extern() const
Definition: cpp_storage_spec.h:33
symbolt::base_name
irep_idt base_name
Base (non-scoped) name.
Definition: symbol.h:46
cpp_scopet::SCOPE_ONLY
Definition: cpp_scope.h:30
messaget::eom
static eomt eom
Definition: message.h:284
cpp_declarator_convertert::get_final_identifier
void get_final_identifier()
Definition: cpp_declarator_converter.cpp:366
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:32
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition: invariant.h:478
cpp_idt
Definition: cpp_id.h:28
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
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:68
namespacet::lookup
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Definition: namespace.cpp:166
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:239
irept::is_not_nil
bool is_not_nil() const
Definition: irep.h:173
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:982
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:386
cpp_idt::id_classt::SYMBOL
code_typet::parametert::get_base_name
const irep_idt & get_base_name() const
Definition: std_types.h:833
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:54
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
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:236
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
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:425
code_typet::set_inlined
void set_inlined(bool value)
Definition: std_types.h:908
source_location.h
struct_typet::bases
const basest & bases() const
Get the collection of base classes/structs.
Definition: std_types.h:303
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:547
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:303
code_typet
Base type of functions.
Definition: std_types.h:751
cpp_typecheckt
Definition: cpp_typecheck.h:44
irept::is_nil
bool is_nil() const
Definition: irep.h:172
irept::id
const irep_idt & id() const
Definition: irep.h:259
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:412
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:154
code_typet::parameters
const parameterst & parameters() const
Definition: std_types.h:893
cpp_declaratort::member_initializers
irept & member_initializers()
Definition: cpp_declarator.h:61
cpp_typecheck.h
cpp_storage_spect::location
source_locationt & location()
Definition: cpp_storage_spec.h:22
cpp_template_args_non_tct
Definition: cpp_template_args.h:44
code_typet::parametert::set_base_name
void set_base_name(const irep_idt &name)
Definition: std_types.h:823
symbol_tablet::move
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
Definition: symbol_table.cpp:63
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:551
cpp_declarator_convertert::handle_initializer
void handle_initializer(symbolt &symbol, cpp_declaratort &declarator)
Definition: cpp_declarator_converter.cpp:318
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:93
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:1344
struct_typet
Structure type, corresponds to C style structs.
Definition: std_types.h:276
cpp_namet::source_location
const source_locationt & source_location() const
Definition: cpp_name.h:73
cpp_idt::id_classt::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_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:864
cpp_type2name
std::string cpp_type2name(const typet &type)
Definition: cpp_type2name.cpp:92
is_reference
bool is_reference(const typet &type)
Returns true if the type is a reference.
Definition: std_types.cpp:132
irept::get
const irep_idt & get(const irep_namet &name) const
Definition: irep.cpp:212
symbolt::location
source_locationt location
Source code location of definition of symbol.
Definition: symbol.h:37
symbolt
Symbol table entry.
Definition: symbol.h:27
irept::set
void set(const irep_namet &name, const irep_idt &value)
Definition: irep.h:286
symbol_table_baset::symbols
const symbolst & symbols
Definition: symbol_table_base.h:27
symbolt::is_type
bool is_type
Definition: symbol.h:61
cpp_declaratort::method_qualifier
irept & method_qualifier()
Definition: cpp_declarator.h:58
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
code_typet::parametert::get_identifier
const irep_idt & get_identifier() const
Definition: std_types.h:828
irept::get_sub
subt & get_sub()
Definition: irep.h:317
code_typet::parametert
Definition: std_types.h:788
symbolt::is_static_lifetime
bool is_static_lifetime
Definition: symbol.h:65
code_typet::get_inlined
bool get_inlined() const
Definition: std_types.h:903
cpp_declarator_convertert::enforce_rules
void enforce_rules(const symbolt &symbol)
Definition: cpp_declarator_converter.cpp:309
cpp_declaratort::value
exprt & value()
Definition: cpp_declarator.h:42
cpp_idt::prefix
std::string prefix
Definition: cpp_id.h:80
code_typet::return_type
const typet & return_type() const
Definition: std_types.h:883
cpp_declarator_convertert::combine_types
void combine_types(const source_locationt &source_location, const typet &decl_type, symbolt &symbol)
Definition: cpp_declarator_converter.cpp:227
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:233
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
irept::subt
std::vector< irept > subt
Definition: irep.h:160
cpp_namet
Definition: cpp_name.h:16
exprt::source_location
const source_locationt & source_location() const
Definition: expr.h:228
cpp_member_spect
Definition: cpp_member_spec.h:16
c_types.h
cpp_typecheckt::dynamic_initializations
dynamic_initializationst dynamic_initializations
Definition: cpp_typecheck.h:592
symbolt::name
irep_idt name
The unique identifier.
Definition: symbol.h:40
cpp_declaratort
Definition: cpp_declarator.h:19
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:1226
cpp_declarator_converter.h
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