cprover
cpp_typecheck_compound_type.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 
12 #include "cpp_typecheck.h"
13 
14 #ifdef DEBUG
15 #include <iostream>
16 #endif
17 
18 #include <algorithm>
19 
20 #include <util/arith_tools.h>
21 #include <util/simplify_expr.h>
22 #include <util/std_types.h>
23 #include <util/c_types.h>
24 
25 #include <ansi-c/c_qualifiers.h>
26 
27 #include "cpp_type2name.h"
29 #include "cpp_convert_type.h"
30 #include "cpp_name.h"
31 
33 {
34  if(type.id()==ID_const)
35  return true;
36  else if(type.id()==ID_merged_type)
37  {
38  forall_subtypes(it, type)
39  if(has_const(*it))
40  return true;
41 
42  return false;
43  }
44  else
45  return false;
46 }
47 
49 {
50  if(type.id()==ID_volatile)
51  return true;
52  else if(type.id()==ID_merged_type)
53  {
54  forall_subtypes(it, type)
55  if(has_volatile(*it))
56  return true;
57 
58  return false;
59  }
60  else
61  return false;
62 }
63 
65 {
66  if(type.id() == ID_auto)
67  return true;
68  else if(
69  type.id() == ID_merged_type || type.id() == ID_frontend_pointer ||
70  type.id() == ID_pointer)
71  {
72  forall_subtypes(it, type)
73  if(has_auto(*it))
74  return true;
75 
76  return false;
77  }
78  else
79  return false;
80 }
81 
83  const irep_idt &base_name,
84  bool has_body,
85  bool tag_only_declaration)
86 {
87  // The scope of a compound identifier is difficult,
88  // and is different from C.
89  //
90  // For instance:
91  // class A { class B {} } --> A::B
92  // class A { class B; } --> A::B
93  // class A { class B *p; } --> ::B
94  // class B { }; class A { class B *p; } --> ::B
95  // class B { }; class A { class B; class B *p; } --> A::B
96 
97  // If there is a body, or it's a tag-only declaration,
98  // it's always in the current scope, even if we already have
99  // it in an upwards scope.
100 
101  if(has_body || tag_only_declaration)
102  return cpp_scopes.current_scope();
103 
104  // No body. Not a tag-only-declaration.
105  // Check if we have it already. If so, take it.
106 
107  // we should only look for tags, but we don't
108  const auto id_set =
110 
111  for(const auto &id : id_set)
112  if(id->is_class())
113  return static_cast<cpp_scopet &>(id->get_parent());
114 
115  // Tags without body that we don't have already
116  // and that are not a tag-only declaration go into
117  // the global scope of the namespace.
118  return cpp_scopes.get_global_scope();
119 }
120 
122  struct_union_typet &type)
123 {
124  // first save qualifiers
125  c_qualifierst qualifiers(type);
126 
127  // now clear them from the type
128  type.remove(ID_C_constant);
129  type.remove(ID_C_volatile);
130  type.remove(ID_C_restricted);
131 
132  // get the tag name
133  bool has_tag=type.find(ID_tag).is_not_nil();
134  irep_idt base_name;
135  cpp_scopet *dest_scope=nullptr;
136  bool has_body=type.find(ID_body).is_not_nil();
137  bool tag_only_declaration=type.get_bool(ID_C_tag_only_declaration);
138  bool is_union = type.id() == ID_union;
139 
140  if(!has_tag)
141  {
142  // most of these should be named by now; see
143  // cpp_declarationt::name_anon_struct_union()
144 
145  base_name=std::string("#anon_")+std::to_string(++anon_counter);
146  type.set(ID_C_is_anonymous, true);
147  dest_scope=&cpp_scopes.current_scope();
148  }
149  else
150  {
151  const cpp_namet &cpp_name=
152  to_cpp_name(type.find(ID_tag));
153 
154  // scope given?
155  if(cpp_name.is_simple_name())
156  {
157  base_name=cpp_name.get_base_name();
158 
159  // anonymous structs always go into the current scope
160  if(type.get_bool(ID_C_is_anonymous))
161  dest_scope=&cpp_scopes.current_scope();
162  else
163  dest_scope=&tag_scope(base_name, has_body, tag_only_declaration);
164  }
165  else
166  {
167  cpp_save_scopet cpp_save_scope(cpp_scopes);
168  cpp_typecheck_resolvet cpp_typecheck_resolve(*this);
170  dest_scope=
171  &cpp_typecheck_resolve.resolve_scope(cpp_name, base_name, t_args);
172  }
173  }
174 
175  // The identifier 'tag-X' matches what the C front-end does!
176  // The hyphen is deliberate to avoid collisions with other
177  // identifiers.
178  const irep_idt symbol_name=
179  dest_scope->prefix+
180  "tag-"+id2string(base_name)+
181  dest_scope->suffix;
182 
183  // check if we have it already
184 
185  if(const auto maybe_symbol=symbol_table.lookup(symbol_name))
186  {
187  // we do!
188  const symbolt &symbol=*maybe_symbol;
189 
190  if(has_body)
191  {
192  if(
193  symbol.type.id() == type.id() &&
195  {
196  // a previously incomplete struct/union becomes complete
197  symbolt &writeable_symbol = symbol_table.get_writeable_ref(symbol_name);
198  writeable_symbol.type.swap(type);
199  typecheck_compound_body(writeable_symbol);
200  }
201  else if(symbol.type.get_bool(ID_C_is_anonymous))
202  {
203  // we silently ignore
204  }
205  else
206  {
208  error() << "error: compound tag '" << base_name
209  << "' declared previously\n"
210  << "location of previous definition: " << symbol.location
211  << eom;
212  throw 0;
213  }
214  }
215  }
216  else
217  {
218  // produce new symbol
219  symbolt symbol;
220 
221  symbol.name=symbol_name;
222  symbol.base_name=base_name;
223  symbol.value.make_nil();
224  symbol.location=type.source_location();
225  symbol.mode=ID_cpp;
226  symbol.module=module;
227  symbol.type.swap(type);
228  symbol.is_type=true;
229  symbol.is_macro=false;
230  symbol.pretty_name=
232  id2string(symbol.base_name)+
234  symbol.type.set(
236 
237  // move early, must be visible before doing body
238  symbolt *new_symbol;
239 
240  if(symbol_table.move(symbol, new_symbol))
241  {
242  error().source_location=symbol.location;
243  error() << "cpp_typecheckt::typecheck_compound_type: "
244  << "symbol_table.move() failed" << eom;
245  throw 0;
246  }
247 
248  // put into dest_scope
249  cpp_idt &id=cpp_scopes.put_into_scope(*new_symbol, *dest_scope);
250 
252  id.is_scope=true;
253  id.prefix=cpp_scopes.current_scope().prefix+
254  id2string(new_symbol->base_name)+
256  id.class_identifier=new_symbol->name;
257  id.id_class=cpp_idt::id_classt::CLASS;
258 
259  if(has_body)
260  typecheck_compound_body(*new_symbol);
261  else
262  {
263  struct_union_typet new_type(new_symbol->type.id());
264  new_type.set(ID_tag, new_symbol->base_name);
265  new_type.make_incomplete();
266  new_type.add_source_location() = type.source_location();
267  new_symbol->type.swap(new_type);
268  }
269  }
270 
271  if(is_union)
272  {
273  // create union tag
274  union_tag_typet tag_type(symbol_name);
275  qualifiers.write(tag_type);
276  type.swap(tag_type);
277  }
278  else
279  {
280  // create struct tag
281  struct_tag_typet tag_type(symbol_name);
282  qualifiers.write(tag_type);
283  type.swap(tag_type);
284  }
285 }
286 
288  const symbolt &symbol,
289  const cpp_declarationt &declaration,
290  cpp_declaratort &declarator,
291  struct_typet::componentst &components,
292  const irep_idt &access,
293  bool is_static,
294  bool is_typedef,
295  bool is_mutable)
296 {
297  bool is_cast_operator=
298  declaration.type().id()=="cpp-cast-operator";
299 
300  if(is_cast_operator)
301  {
302  assert(declarator.name().get_sub().size()==2 &&
303  declarator.name().get_sub().front().id()==ID_operator);
304 
305  typet type=static_cast<typet &>(declarator.name().get_sub()[1]);
306  declarator.type().subtype()=type;
307 
308  cpp_namet::namet name("(" + cpp_type2name(type) + ")");
309  declarator.name().get_sub().back().swap(name);
310  }
311 
312  typet final_type=
313  declarator.merge_type(declaration.type());
314 
315  // this triggers template elaboration
316  elaborate_class_template(final_type);
317 
318  typecheck_type(final_type);
319 
320  cpp_namet cpp_name;
321  cpp_name.swap(declarator.name());
322 
323  irep_idt base_name;
324 
325  if(cpp_name.is_nil())
326  {
327  // Yes, there can be members without name.
328  base_name=irep_idt();
329  }
330  else if(cpp_name.is_simple_name())
331  {
332  base_name=cpp_name.get_base_name();
333  }
334  else
335  {
337  error() << "declarator in compound needs to be simple name"
338  << eom;
339  throw 0;
340  }
341 
342  bool is_method=!is_typedef && final_type.id()==ID_code;
343  bool is_constructor=declaration.is_constructor();
344  bool is_destructor=declaration.is_destructor();
345  bool is_virtual=declaration.member_spec().is_virtual();
346  bool is_explicit=declaration.member_spec().is_explicit();
347  bool is_inline=declaration.member_spec().is_inline();
348 
349  final_type.set(ID_C_member_name, symbol.name);
350 
351  // first do some sanity checks
352 
353  if(is_virtual && !is_method)
354  {
356  error() << "only methods can be virtual" << eom;
357  throw 0;
358  }
359 
360  if(is_inline && !is_method)
361  {
363  error() << "only methods can be inlined" << eom;
364  throw 0;
365  }
366 
367  if(is_virtual && is_static)
368  {
370  error() << "static methods cannot be virtual" << eom;
371  throw 0;
372  }
373 
374  if(is_cast_operator && is_static)
375  {
377  error() << "cast operators cannot be static" << eom;
378  throw 0;
379  }
380 
381  if(is_constructor && is_virtual)
382  {
384  error() << "constructors cannot be virtual" << eom;
385  throw 0;
386  }
387 
388  if(!is_constructor && is_explicit)
389  {
391  error() << "only constructors can be explicit" << eom;
392  throw 0;
393  }
394 
395  if(is_constructor && base_name != symbol.base_name)
396  {
398  error() << "member function must return a value or void" << eom;
399  throw 0;
400  }
401 
402  if(is_destructor &&
403  base_name!="~"+id2string(symbol.base_name))
404  {
406  error() << "destructor with wrong name" << eom;
407  throw 0;
408  }
409 
410  // now do actual work
411 
412  irep_idt identifier;
413 
414  // the below is a temporary hack
415  // if(is_method || is_static)
416  if(id2string(cpp_scopes.current_scope().prefix).find("#anon")==
417  std::string::npos ||
418  is_method || is_static)
419  {
420  // Identifiers for methods include the scope prefix.
421  // Identifiers for static members include the scope prefix.
422  identifier=
424  id2string(base_name);
425  }
426  else
427  {
428  // otherwise, we keep them simple
429  identifier=base_name;
430  }
431 
432  struct_typet::componentt component(identifier, final_type);
433  component.set(ID_access, access);
434  component.set_base_name(base_name);
435  component.set_pretty_name(base_name);
436  component.add_source_location()=cpp_name.source_location();
437 
438  if(cpp_name.is_operator())
439  {
440  component.set(ID_is_operator, true);
441  component.type().set(ID_C_is_operator, true);
442  }
443 
444  if(is_cast_operator)
445  component.set(ID_is_cast_operator, true);
446 
447  if(declaration.member_spec().is_explicit())
448  component.set(ID_is_explicit, true);
449 
450  // either blank, const, volatile, or const volatile
451  const typet &method_qualifier=
452  static_cast<const typet &>(declarator.add(ID_method_qualifier));
453 
454  if(is_static)
455  {
456  component.set(ID_is_static, true);
457  component.type().set(ID_C_is_static, true);
458  }
459 
460  if(is_typedef)
461  component.set(ID_is_type, true);
462 
463  if(is_mutable)
464  component.set(ID_is_mutable, true);
465 
466  exprt &value=declarator.value();
467  irept &initializers=declarator.member_initializers();
468 
469  if(is_method)
470  {
471  if(
472  value.id() == ID_code &&
473  to_code(value).get_statement() == ID_cpp_delete)
474  {
475  value.make_nil();
476  component.set(ID_access, ID_noaccess);
477  }
478 
479  component.set(ID_is_inline, declaration.member_spec().is_inline());
480 
481  // the 'virtual' name of the function
482  std::string virtual_name = id2string(component.get_base_name()) +
484 
485  if(has_const(method_qualifier))
486  virtual_name+="$const";
487 
488  if(has_volatile(method_qualifier))
489  virtual_name += "$volatile";
490 
491  if(to_code_type(component.type()).return_type().id() == ID_destructor)
492  virtual_name="@dtor";
493 
494  // The method may be virtual implicitly.
495  std::set<irep_idt> virtual_bases;
496 
497  for(const auto &comp : components)
498  {
499  if(comp.get_bool(ID_is_virtual))
500  {
501  if(comp.get(ID_virtual_name) == virtual_name)
502  {
503  is_virtual=true;
504  const code_typet &code_type=to_code_type(comp.type());
505  assert(!code_type.parameters().empty());
506  const typet &pointer_type=code_type.parameters()[0].type();
507  assert(pointer_type.id()==ID_pointer);
508  virtual_bases.insert(pointer_type.subtype().get(ID_identifier));
509  }
510  }
511  }
512 
513  if(!is_virtual)
514  {
516  symbol, component, initializers,
517  method_qualifier, value);
518 
519  if(!value.is_nil() && !is_static)
520  {
522  error() << "no initialization allowed here" << eom;
523  throw 0;
524  }
525  }
526  else // virtual
527  {
528  component.type().set(ID_C_is_virtual, true);
529  component.type().set(ID_C_virtual_name, virtual_name);
530 
531  // Check if it is a pure virtual method
532  if(value.is_not_nil() && value.id() == ID_constant)
533  {
534  mp_integer i;
535  to_integer(to_constant_expr(value), i);
536  if(i!=0)
537  {
538  error().source_location = declarator.name().source_location();
539  error() << "expected 0 to mark pure virtual method, got " << i << eom;
540  throw 0;
541  }
542  component.set(ID_is_pure_virtual, true);
543  value.make_nil();
544  }
545 
547  symbol,
548  component,
549  initializers,
550  method_qualifier,
551  value);
552 
553  // get the virtual-table symbol type
554  irep_idt vt_name="virtual_table::"+id2string(symbol.name);
555 
556  if(!symbol_table.has_symbol(vt_name))
557  {
558  // first time: create a virtual-table symbol type
559  symbolt vt_symb_type;
560  vt_symb_type.name= vt_name;
561  vt_symb_type.base_name="virtual_table::"+id2string(symbol.base_name);
562  vt_symb_type.pretty_name=vt_symb_type.base_name;
563  vt_symb_type.mode=ID_cpp;
564  vt_symb_type.module=module;
565  vt_symb_type.location=symbol.location;
566  vt_symb_type.type=struct_typet();
567  vt_symb_type.type.set(ID_name, vt_symb_type.name);
568  vt_symb_type.is_type=true;
569 
570  const bool failed=!symbol_table.insert(std::move(vt_symb_type)).second;
572 
573  // add a virtual-table pointer
575  id2string(symbol.name) + "::@vtable_pointer",
576  pointer_type(struct_tag_typet(vt_name)));
577  compo.set_base_name("@vtable_pointer");
578  compo.set_pretty_name(id2string(symbol.base_name) + "@vtable_pointer");
579  compo.set(ID_is_vtptr, true);
580  compo.set(ID_access, ID_public);
581  components.push_back(compo);
583  }
584 
586  INVARIANT(vt.id()==ID_struct, "Virtual tables must be stored as struct");
587  struct_typet &virtual_table=to_struct_type(vt);
588 
589  component.set(ID_virtual_name, virtual_name);
590  component.set(ID_is_virtual, is_virtual);
591 
592  // add an entry to the virtual table
593  struct_typet::componentt vt_entry(
594  id2string(vt_name) + "::" + virtual_name,
595  pointer_type(component.type()));
596  vt_entry.set_base_name(virtual_name);
597  vt_entry.set_pretty_name(virtual_name);
598  vt_entry.set(ID_access, ID_public);
599  vt_entry.add_source_location()=symbol.location;
600  virtual_table.components().push_back(vt_entry);
601 
602  // take care of overloading
603  while(!virtual_bases.empty())
604  {
605  irep_idt virtual_base=*virtual_bases.begin();
606 
607  // a new function that does 'late casting' of the 'this' parameter
608  symbolt func_symb;
609  func_symb.name=
610  id2string(component.get_name())+"::"+id2string(virtual_base);
611  func_symb.base_name = component.get_base_name();
612  func_symb.pretty_name = component.get_base_name();
613  func_symb.mode = symbol.mode;
614  func_symb.module=module;
615  func_symb.location=component.source_location();
616  func_symb.type=component.type();
617 
618  // change the type of the 'this' pointer
619  code_typet &code_type=to_code_type(func_symb.type);
620  code_typet::parametert &this_parameter = code_type.parameters().front();
621  this_parameter.type().subtype().set(ID_identifier, virtual_base);
622 
623  // create symbols for the parameters
624  code_typet::parameterst &args=code_type.parameters();
625  std::size_t i=0;
626  for(auto &arg : args)
627  {
628  irep_idt param_base_name = arg.get_base_name();
629 
630  if(param_base_name.empty())
631  param_base_name = "arg" + std::to_string(i++);
632 
633  symbolt arg_symb;
634  arg_symb.name =
635  id2string(func_symb.name) + "::" + id2string(param_base_name);
636  arg_symb.base_name = param_base_name;
637  arg_symb.pretty_name = param_base_name;
638  arg_symb.mode = symbol.mode;
639  arg_symb.location=func_symb.location;
640  arg_symb.type=arg.type();
641 
642  arg.set_identifier(arg_symb.name);
643 
644  // add the parameter to the symbol table
645  const bool failed=!symbol_table.insert(std::move(arg_symb)).second;
647  }
648 
649  // do the body of the function
650  typecast_exprt late_cast(
651  lookup(args[0].get_identifier()).symbol_expr(),
652  to_code_type(component.type()).parameters()[0].type());
653 
655  symbol_exprt(component.get_name(), component.type()),
656  {late_cast},
658  source_locationt{});
659  expr_call.arguments().reserve(args.size());
660 
661  for(const auto &arg : args)
662  {
663  expr_call.arguments().push_back(
664  lookup(arg.get_identifier()).symbol_expr());
665  }
666 
667  if(code_type.return_type().id()!=ID_empty &&
668  code_type.return_type().id()!=ID_destructor)
669  {
670  expr_call.type()=to_code_type(component.type()).return_type();
671 
672  func_symb.value = code_blockt{
673  {code_returnt(already_typechecked_exprt{std::move(expr_call)})}};
674  }
675  else
676  {
677  func_symb.value = code_blockt{{code_expressiont(
678  already_typechecked_exprt{std::move(expr_call)})}};
679  }
680 
681  // add this new function to the list of components
682 
684  new_compo.type()=func_symb.type;
685  new_compo.set_name(func_symb.name);
686  components.push_back(new_compo);
687 
688  // add the function to the symbol table
689  {
690  const bool failed=!symbol_table.insert(std::move(func_symb)).second;
692  }
693 
694  put_compound_into_scope(new_compo);
695 
696  // next base
697  virtual_bases.erase(virtual_bases.begin());
698  }
699  }
700  }
701 
702  if(is_static && !is_method) // static non-method member
703  {
704  // add as global variable to symbol_table
705  symbolt static_symbol;
706  static_symbol.mode=symbol.mode;
707  static_symbol.name=identifier;
708  static_symbol.type=component.type();
709  static_symbol.base_name = component.get_base_name();
710  static_symbol.is_lvalue=true;
711  static_symbol.is_static_lifetime=true;
712  static_symbol.location=cpp_name.source_location();
713  static_symbol.is_extern=true;
714 
715  // TODO: not sure about this: should be defined separately!
716  dynamic_initializations.push_back(static_symbol.name);
717 
718  symbolt *new_symbol;
719  if(symbol_table.move(static_symbol, new_symbol))
720  {
722  error() << "redeclaration of static member '" << static_symbol.base_name
723  << "'" << eom;
724  throw 0;
725  }
726 
727  if(value.is_not_nil())
728  {
729  if(cpp_is_pod(new_symbol->type))
730  {
731  new_symbol->value.swap(value);
733  }
734  else
735  {
736  symbol_exprt symexpr = symbol_exprt::typeless(new_symbol->name);
737 
738  exprt::operandst ops;
739  ops.push_back(value);
740  auto defcode = cpp_constructor(source_locationt(), symexpr, ops);
741  CHECK_RETURN(defcode.has_value());
742 
743  new_symbol->value.swap(defcode.value());
744  }
745  }
746  }
747 
748  // array members must have fixed size
750 
752 
753  components.push_back(component);
754 }
755 
758 {
759  if(type.id()==ID_array)
760  {
761  array_typet &array_type=to_array_type(type);
762 
763  if(array_type.size().is_not_nil())
764  {
765  if(array_type.size().id() == ID_symbol)
766  {
767  const symbol_exprt &s = to_symbol_expr(array_type.size());
768  const symbolt &symbol = lookup(s.get_identifier());
769 
770  if(cpp_is_pod(symbol.type) && symbol.type.get_bool(ID_C_constant))
771  array_type.size() = symbol.value;
772  }
773 
774  make_constant_index(array_type.size());
775  }
776 
777  // recursive call for multi-dimensional arrays
778  check_fixed_size_array(array_type.subtype());
779  }
780 }
781 
783  const struct_union_typet::componentt &compound)
784 {
785  const irep_idt &base_name=compound.get_base_name();
786  const irep_idt &name=compound.get_name();
787 
788  // nothing to do if no base_name (e.g., an anonymous bitfield)
789  if(base_name.empty())
790  return;
791 
792  if(compound.type().id()==ID_code)
793  {
794  // put the symbol into scope
795  cpp_idt &id=cpp_scopes.current_scope().insert(base_name);
796  id.id_class = compound.get_bool(ID_is_type) ? cpp_idt::id_classt::TYPEDEF
798  id.identifier=name;
799  id.class_identifier=cpp_scopes.current_scope().identifier;
800  id.is_member=true;
801  id.is_constructor =
802  to_code_type(compound.type()).return_type().id() == ID_constructor;
803  id.is_method=true;
804  id.is_static_member=compound.get_bool(ID_is_static);
805 
806  // create function block-scope in the scope
807  cpp_idt &id_block=
809  irep_idt(std::string("$block:") + base_name.c_str()));
810 
812  id_block.identifier=name;
814  id_block.is_method=true;
815  id_block.is_static_member=compound.get_bool(ID_is_static);
816 
817  id_block.is_scope=true;
818  id_block.prefix = compound.get_string(ID_prefix);
819  cpp_scopes.id_map[id.identifier]=&id_block;
820  }
821  else
822  {
823  // check if it's already there
824  const auto id_set =
826 
827  for(const auto &id_it : id_set)
828  {
829  const cpp_idt &id=*id_it;
830 
831  // the name is already in the scope
832  // this is ok if they belong to different categories
833  if(!id.is_class() && !id.is_enum())
834  {
836  error() << "'" << base_name << "' already in compound scope" << eom;
837  throw 0;
838  }
839  }
840 
841  // put into the scope
842  cpp_idt &id=cpp_scopes.current_scope().insert(base_name);
843  id.id_class=compound.get_bool(ID_is_type)?
846  id.identifier=name;
847  id.class_identifier=cpp_scopes.current_scope().identifier;
848  id.is_member=true;
849  id.is_method=false;
850  id.is_static_member=compound.get_bool(ID_is_static);
851  }
852 }
853 
855  symbolt &symbol,
856  cpp_declarationt &declaration)
857 {
858  // A friend of a class can be a function/method,
859  // or a struct/class/union type.
860 
861  if(declaration.is_template())
862  {
863  error().source_location=declaration.type().source_location();
864  error() << "friend template not supported" << eom;
865  throw 0;
866  }
867 
868  // we distinguish these whether there is a declarator
869  if(declaration.declarators().empty())
870  {
871  typet &ftype=declaration.type();
872 
873  // must be struct or union
874  if(ftype.id()!=ID_struct && ftype.id()!=ID_union)
875  {
876  error().source_location=declaration.type().source_location();
877  error() << "unexpected friend" << eom;
878  throw 0;
879  }
880 
881  if(ftype.find(ID_body).is_not_nil())
882  {
883  error().source_location=declaration.type().source_location();
884  error() << "friend declaration must not have compound body" << eom;
885  throw 0;
886  }
887 
888  cpp_save_scopet saved_scope(cpp_scopes);
890  typecheck_type(ftype);
891  symbol.type.add(ID_C_friends).move_to_sub(ftype);
892 
893  return;
894  }
895 
896  // It should be a friend function.
897  // Do the declarators.
898 
899 #ifdef DEBUG
900  std::cout << "friend declaration: " << declaration.pretty() << '\n';
901 #endif
902 
903  for(auto &sub_it : declaration.declarators())
904  {
905 #ifdef DEBUG
906  std::cout << "decl: " << sub_it.pretty() << "\n with value "
907  << sub_it.value().pretty() << '\n';
908  std::cout << " scope: " << cpp_scopes.current_scope().prefix << '\n';
909 #endif
910 
911  if(sub_it.value().is_not_nil())
912  declaration.member_spec().set_inline(true);
913 
914  cpp_declarator_convertert cpp_declarator_converter(*this);
915  cpp_declarator_converter.is_friend = true;
916  const symbolt &conv_symb = cpp_declarator_converter.convert(
917  declaration.type(),
918  declaration.storage_spec(),
919  declaration.member_spec(),
920  sub_it);
921  exprt symb_expr = cpp_symbol_expr(conv_symb);
922  symbol.type.add(ID_C_friends).move_to_sub(symb_expr);
923  }
924 }
925 
927 {
928  cpp_save_scopet saved_scope(cpp_scopes);
929 
930  // enter scope of compound
931  cpp_scopes.set_scope(symbol.name);
932 
933  assert(symbol.type.id()==ID_struct ||
934  symbol.type.id()==ID_union);
935 
936  struct_union_typet &type=
937  to_struct_union_type(symbol.type);
938 
939  // pull the base types in
940  if(!type.find(ID_bases).get_sub().empty())
941  {
942  if(type.id()==ID_union)
943  {
944  error().source_location=symbol.location;
945  error() << "union types must not have bases" << eom;
946  throw 0;
947  }
948 
950  }
951 
952  exprt &body=static_cast<exprt &>(type.add(ID_body));
953  struct_union_typet::componentst &components=type.components();
954 
955  symbol.type.set(ID_name, symbol.name);
956 
957  // default access
958  irep_idt access = type.default_access();
959 
960  bool found_ctor=false;
961  bool found_dtor=false;
962 
963  // we first do everything _but_ the constructors
964 
965  Forall_operands(it, body)
966  {
967  if(it->id()==ID_cpp_declaration)
968  {
969  cpp_declarationt &declaration=
970  to_cpp_declaration(*it);
971 
972  if(declaration.member_spec().is_friend())
973  {
974  typecheck_friend_declaration(symbol, declaration);
975  continue; // done
976  }
977 
978  if(declaration.is_template())
979  {
980  // remember access mode
981  declaration.set(ID_C_access, access);
982  convert_template_declaration(declaration);
983  continue;
984  }
985 
986  if(declaration.type().id().empty())
987  continue;
988 
989  bool is_typedef=declaration.is_typedef();
990 
991  // is it tag-only?
992  if(declaration.type().id()==ID_struct ||
993  declaration.type().id()==ID_union ||
994  declaration.type().id()==ID_c_enum)
995  if(declaration.declarators().empty())
996  declaration.type().set(ID_C_tag_only_declaration, true);
997 
998  declaration.name_anon_struct_union();
999  typecheck_type(declaration.type());
1000 
1001  bool is_static=declaration.storage_spec().is_static();
1002  bool is_mutable=declaration.storage_spec().is_mutable();
1003 
1004  if(declaration.storage_spec().is_extern() ||
1005  declaration.storage_spec().is_auto() ||
1006  declaration.storage_spec().is_register())
1007  {
1008  error().source_location=declaration.storage_spec().location();
1009  error() << "invalid storage class specified for field" << eom;
1010  throw 0;
1011  }
1012 
1013  typet final_type=follow(declaration.type());
1014 
1015  // anonymous member?
1016  if(declaration.declarators().empty() &&
1017  final_type.get_bool(ID_C_is_anonymous))
1018  {
1019  // we only allow this on struct/union types
1020  if(final_type.id()!=ID_union &&
1021  final_type.id()!=ID_struct)
1022  {
1023  error().source_location=declaration.type().source_location();
1024  error() << "member declaration does not declare anything"
1025  << eom;
1026  throw 0;
1027  }
1028 
1030  declaration, access, components);
1031 
1032  continue;
1033  }
1034 
1035  // declarators
1036  for(auto &declarator : declaration.declarators())
1037  {
1038  // Skip the constructors until all the data members
1039  // are discovered
1040  if(declaration.is_destructor())
1041  found_dtor=true;
1042 
1043  if(declaration.is_constructor())
1044  {
1045  found_ctor=true;
1046  continue;
1047  }
1048 
1050  symbol,
1051  declaration, declarator, components,
1052  access, is_static, is_typedef, is_mutable);
1053  }
1054  }
1055  else if(it->id()=="cpp-public")
1056  access=ID_public;
1057  else if(it->id()=="cpp-private")
1058  access=ID_private;
1059  else if(it->id()=="cpp-protected")
1060  access=ID_protected;
1061  else
1062  {
1063  }
1064  }
1065 
1066  // Add the default dtor, if needed
1067  // (we have to do the destructor before building the virtual tables,
1068  // as the destructor may be virtual!)
1069 
1070  if((found_ctor || !cpp_is_pod(symbol.type)) && !found_dtor)
1071  {
1072  // build declaration
1074  default_dtor(symbol, dtor);
1075 
1077  symbol,
1078  dtor, dtor.declarators()[0], components,
1079  ID_public, false, false, false);
1080  }
1081 
1082  // set up virtual tables before doing the constructors
1083  if(symbol.type.id()==ID_struct)
1084  do_virtual_table(symbol);
1085 
1086  if(!found_ctor && !cpp_is_pod(symbol.type))
1087  {
1088  // it's public!
1089  exprt cpp_public("cpp-public");
1090  body.add_to_operands(std::move(cpp_public));
1091 
1092  // build declaration
1093  cpp_declarationt ctor;
1094  default_ctor(symbol.type.source_location(), symbol.base_name, ctor);
1095  body.add_to_operands(std::move(ctor));
1096  }
1097 
1098  // Reset the access type
1099  access = type.default_access();
1100 
1101  // All the data members are now known.
1102  // We now deal with the constructors that we are given.
1103  Forall_operands(it, body)
1104  {
1105  if(it->id()==ID_cpp_declaration)
1106  {
1107  cpp_declarationt &declaration=
1108  to_cpp_declaration(*it);
1109 
1110  if(!declaration.is_constructor())
1111  continue;
1112 
1113  for(auto &declarator : declaration.declarators())
1114  {
1115  #if 0
1116  irep_idt ctor_base_name=
1117  declarator.name().get_base_name();
1118  #endif
1119 
1120  if(declarator.value().is_not_nil()) // body?
1121  {
1122  if(declarator.find(ID_member_initializers).is_nil())
1123  declarator.set(ID_member_initializers, ID_member_initializers);
1124 
1125  if(type.id() == ID_union)
1126  {
1128  {}, type.components(), declarator.member_initializers());
1129  }
1130  else
1131  {
1133  to_struct_type(type).bases(),
1134  type.components(),
1135  declarator.member_initializers());
1136  }
1137 
1139  type,
1140  declarator.member_initializers());
1141  }
1142 
1143  // Finally, we typecheck the constructor with the
1144  // full member-initialization list
1145  // Shall all be false
1146  bool is_static=declaration.storage_spec().is_static();
1147  bool is_mutable=declaration.storage_spec().is_mutable();
1148  bool is_typedef=declaration.is_typedef();
1149 
1151  symbol,
1152  declaration, declarator, components,
1153  access, is_static, is_typedef, is_mutable);
1154  }
1155  }
1156  else if(it->id()=="cpp-public")
1157  access=ID_public;
1158  else if(it->id()=="cpp-private")
1159  access=ID_private;
1160  else if(it->id()=="cpp-protected")
1161  access=ID_protected;
1162  else
1163  {
1164  }
1165  }
1166 
1167  if(!cpp_is_pod(symbol.type))
1168  {
1169  // Add the default copy constructor
1171 
1172  if(!find_cpctor(symbol))
1173  {
1174  // build declaration
1175  cpp_declarationt cpctor;
1176  default_cpctor(symbol, cpctor);
1177  assert(cpctor.declarators().size()==1);
1178 
1179  exprt value(ID_cpp_not_typechecked);
1180  value.copy_to_operands(cpctor.declarators()[0].value());
1181  cpctor.declarators()[0].value()=value;
1182 
1184  symbol,
1185  cpctor, cpctor.declarators()[0], components,
1186  ID_public, false, false, false);
1187  }
1188 
1189  // Add the default assignment operator
1190  if(!find_assignop(symbol))
1191  {
1192  // build declaration
1193  cpp_declarationt assignop;
1194  default_assignop(symbol, assignop);
1195  assert(assignop.declarators().size()==1);
1196 
1197  // The value will be typechecked only if the operator
1198  // is actually used
1199  cpp_declaratort declarator;
1200  assignop.declarators().push_back(declarator);
1201  assignop.declarators()[0].value() = exprt(ID_cpp_not_typechecked);
1202 
1204  symbol,
1205  assignop, assignop.declarators()[0], components,
1206  ID_public, false, false, false);
1207  }
1208  }
1209 
1210  // clean up!
1211  symbol.type.remove(ID_body);
1212 }
1213 
1215  irept &initializers,
1216  const code_typet &type,
1217  exprt &value)
1218 {
1219  // see if we have initializers
1220  if(!initializers.get_sub().empty())
1221  {
1222  const source_locationt &location=
1223  static_cast<const source_locationt &>(
1224  initializers.find(ID_C_source_location));
1225 
1226  if(type.return_type().id() != ID_constructor)
1227  {
1228  error().source_location=location;
1229  error() << "only constructors are allowed to "
1230  << "have member initializers" << eom;
1231  throw 0;
1232  }
1233 
1234  if(value.is_nil())
1235  {
1236  error().source_location=location;
1237  error() << "only constructors with body are allowed to "
1238  << "have member initializers" << eom;
1239  throw 0;
1240  }
1241 
1242  if(to_code(value).get_statement() != ID_block)
1243  value = code_blockt{{to_code(value)}};
1244 
1245  exprt::operandst::iterator o_it=value.operands().begin();
1246  forall_irep(it, initializers.get_sub())
1247  {
1248  o_it=value.operands().insert(o_it, static_cast<const exprt &>(*it));
1249  o_it++;
1250  }
1251  }
1252 }
1253 
1255  const symbolt &compound_symbol,
1257  irept &initializers,
1258  const typet &method_qualifier,
1259  exprt &value)
1260 {
1261  symbolt symbol;
1262 
1263  code_typet &type = to_code_type(component.type());
1264 
1265  if(component.get_bool(ID_is_static))
1266  {
1267  if(!method_qualifier.id().empty())
1268  {
1269  error().source_location=component.source_location();
1270  error() << "method is static -- no qualifiers allowed" << eom;
1271  throw 0;
1272  }
1273  }
1274  else
1275  {
1276  add_this_to_method_type(compound_symbol, type, method_qualifier);
1277  }
1278 
1279  if(value.id() == ID_cpp_not_typechecked && value.has_operands())
1280  {
1282  initializers, type, to_multi_ary_expr(value).op0());
1283  }
1284  else
1285  move_member_initializers(initializers, type, value);
1286 
1287  irep_idt f_id=
1289 
1290  const irep_idt identifier=
1292  id2string(component.get_base_name())+
1293  id2string(f_id);
1294 
1295  component.set_name(identifier);
1296  component.set(ID_prefix, id2string(identifier) + "::");
1297 
1298  if(value.is_not_nil())
1299  to_code_type(type).set_inlined(true);
1300 
1301  symbol.name=identifier;
1302  symbol.base_name=component.get_base_name();
1303  symbol.value.swap(value);
1304  symbol.mode = compound_symbol.mode;
1305  symbol.module=module;
1306  symbol.type=type;
1307  symbol.is_type=false;
1308  symbol.is_macro=false;
1309  symbol.location=component.source_location();
1310 
1311  // move early, it must be visible before doing any value
1312  symbolt *new_symbol;
1313 
1314  const bool symbol_exists = symbol_table.move(symbol, new_symbol);
1315  if(symbol_exists && new_symbol->is_weak)
1316  {
1317  // there might have been an earlier friend declaration
1318  *new_symbol = std::move(symbol);
1319  }
1320  else if(symbol_exists)
1321  {
1322  error().source_location=symbol.location;
1323  error() << "failed to insert new method symbol: " << symbol.name << '\n'
1324  << "name of previous symbol: " << new_symbol->name << '\n'
1325  << "location of previous symbol: " << new_symbol->location << eom;
1326 
1327  throw 0;
1328  }
1329 
1330  // Is this in a class template?
1331  // If so, we defer typechecking until used.
1333  deferred_typechecking.insert(new_symbol->name);
1334  else // remember for later typechecking of body
1335  add_method_body(new_symbol);
1336 }
1337 
1339  const symbolt &compound_symbol,
1340  code_typet &type,
1341  const typet &method_qualifier)
1342 {
1343  typet subtype;
1344 
1345  if(compound_symbol.type.id() == ID_union)
1346  subtype = union_tag_typet(compound_symbol.name);
1347  else
1348  subtype = struct_tag_typet(compound_symbol.name);
1349 
1350  if(has_const(method_qualifier))
1351  subtype.set(ID_C_constant, true);
1352 
1353  if(has_volatile(method_qualifier))
1354  subtype.set(ID_C_volatile, true);
1355 
1356  code_typet::parametert parameter(pointer_type(subtype));
1357  parameter.set_identifier(ID_this);
1358  parameter.set_base_name(ID_this);
1359  parameter.set_this();
1361  convert_parameter(compound_symbol.mode, parameter);
1362 
1363  code_typet::parameterst &parameters = type.parameters();
1364  parameters.insert(parameters.begin(), parameter);
1365 }
1366 
1368  const symbolt &struct_union_symbol)
1369 {
1370  const struct_union_typet &struct_union_type=
1371  to_struct_union_type(struct_union_symbol.type);
1372 
1373  const struct_union_typet::componentst &struct_union_components=
1374  struct_union_type.components();
1375 
1376  // do scoping -- the members of the struct/union
1377  // should be visible in the containing struct/union,
1378  // and that recursively!
1379 
1380  for(const auto &comp : struct_union_components)
1381  {
1382  if(comp.type().id()==ID_code)
1383  {
1384  error().source_location=struct_union_symbol.type.source_location();
1385  error() << "anonymous struct/union member '"
1386  << struct_union_symbol.base_name
1387  << "' shall not have function members" << eom;
1388  throw 0;
1389  }
1390 
1391  if(comp.get_anonymous())
1392  {
1393  const symbolt &symbol=lookup(comp.type().get(ID_identifier));
1394  // recursive call
1396  }
1397  else
1398  {
1399  const irep_idt &base_name=comp.get_base_name();
1400 
1401  if(cpp_scopes.current_scope().contains(base_name))
1402  {
1403  error().source_location=comp.source_location();
1404  error() << "'" << base_name << "' already in scope" << eom;
1405  throw 0;
1406  }
1407 
1408  cpp_idt &id=cpp_scopes.current_scope().insert(base_name);
1410  id.identifier=comp.get_name();
1411  id.class_identifier=struct_union_symbol.name;
1412  id.is_member=true;
1413  }
1414  }
1415 }
1416 
1418  const cpp_declarationt &declaration,
1419  const irep_idt &access,
1420  struct_typet::componentst &components)
1421 {
1422  symbolt &struct_union_symbol =
1423  symbol_table.get_writeable_ref(follow(declaration.type()).get(ID_name));
1424 
1425  if(declaration.storage_spec().is_static() ||
1426  declaration.storage_spec().is_mutable())
1427  {
1428  error().source_location=struct_union_symbol.type.source_location();
1429  error() << "storage class is not allowed here" << eom;
1430  throw 0;
1431  }
1432 
1433  if(!cpp_is_pod(struct_union_symbol.type))
1434  {
1435  error().source_location=struct_union_symbol.type.source_location();
1436  error() << "anonymous struct/union member is not POD" << eom;
1437  throw 0;
1438  }
1439 
1440  // produce an anonymous member
1441  irep_idt base_name="#anon_member"+std::to_string(components.size());
1442 
1443  irep_idt identifier=
1445  base_name.c_str();
1446 
1447  typet compound_type;
1448 
1449  if(struct_union_symbol.type.id() == ID_union)
1450  compound_type = union_tag_typet(struct_union_symbol.name);
1451  else
1452  compound_type = struct_tag_typet(struct_union_symbol.name);
1453 
1454  struct_typet::componentt component(identifier, compound_type);
1455  component.set_access(access);
1456  component.set_base_name(base_name);
1457  component.set_pretty_name(base_name);
1458  component.set_anonymous(true);
1459  component.add_source_location()=declaration.source_location();
1460 
1461  components.push_back(component);
1462 
1463  add_anonymous_members_to_scope(struct_union_symbol);
1464 
1466 
1467  struct_union_symbol.type.set(ID_C_unnamed_object, base_name);
1468 }
1469 
1471  const source_locationt &source_location,
1472  const exprt &object,
1473  const irep_idt &component_name,
1474  exprt &member)
1475 {
1476  const typet &followed_type=follow(object.type());
1477 
1478  assert(followed_type.id()==ID_struct ||
1479  followed_type.id()==ID_union);
1480 
1481  struct_union_typet final_type=
1482  to_struct_union_type(followed_type);
1483 
1484  const struct_union_typet::componentst &components=
1485  final_type.components();
1486 
1487  for(const auto &component : components)
1488  {
1489  member_exprt tmp(object, component.get_name(), component.type());
1490  tmp.add_source_location()=source_location;
1491 
1492  if(component.get_name()==component_name)
1493  {
1494  member.swap(tmp);
1495 
1496  bool not_ok=check_component_access(component, final_type);
1497  if(not_ok)
1498  {
1500  {
1501  member.set(ID_C_not_accessible, true);
1502  member.set(ID_C_access, component.get(ID_access));
1503  }
1504  else
1505  {
1506  error().source_location=source_location;
1507  error() << "error: member '" << component_name
1508  << "' is not accessible (" << component.get(ID_access) << ")"
1509  << eom;
1510  throw 0;
1511  }
1512  }
1513 
1514  if(object.get_bool(ID_C_lvalue))
1515  member.set(ID_C_lvalue, true);
1516 
1517  if(
1518  object.type().get_bool(ID_C_constant) &&
1519  !component.get_bool(ID_is_mutable))
1520  {
1521  member.type().set(ID_C_constant, true);
1522  }
1523 
1524  member.add_source_location()=source_location;
1525 
1526  return true; // component found
1527  }
1528  else if(follow(component.type()).find(ID_C_unnamed_object).is_not_nil())
1529  {
1530  // could be anonymous union or struct
1531 
1532  const typet &component_type=follow(component.type());
1533 
1534  if(component_type.id()==ID_union ||
1535  component_type.id()==ID_struct)
1536  {
1537  // recursive call!
1538  if(get_component(source_location, tmp, component_name, member))
1539  {
1540  if(check_component_access(component, final_type))
1541  {
1542  error().source_location=source_location;
1543  error() << "error: member '" << component_name
1544  << "' is not accessible" << eom;
1545  throw 0;
1546  }
1547 
1548  if(object.get_bool(ID_C_lvalue))
1549  member.set(ID_C_lvalue, true);
1550 
1551  if(
1552  object.get_bool(ID_C_constant) &&
1553  !component.get_bool(ID_is_mutable))
1554  {
1555  member.type().set(ID_C_constant, true);
1556  }
1557 
1558  member.add_source_location()=source_location;
1559  return true; // component found
1560  }
1561  }
1562  }
1563  }
1564 
1565  return false; // component not found
1566 }
1567 
1570  const struct_union_typet &struct_union_type)
1571 {
1572  const irep_idt &access=component.get(ID_access);
1573 
1574  if(access == ID_noaccess)
1575  return true; // not ok
1576 
1577  if(access==ID_public)
1578  return false; // ok
1579 
1580  assert(access==ID_private ||
1581  access==ID_protected);
1582 
1583  const irep_idt &struct_identifier=
1584  struct_union_type.get(ID_name);
1585 
1586  for(cpp_scopet *pscope = &(cpp_scopes.current_scope());
1587  !(pscope->is_root_scope());
1588  pscope = &(pscope->get_parent()))
1589  {
1590  if(pscope->is_class())
1591  {
1592  if(pscope->identifier==struct_identifier)
1593  return false; // ok
1594 
1595  const struct_typet &scope_struct=
1596  to_struct_type(lookup(pscope->identifier).type);
1597 
1598  if(subtype_typecast(
1599  to_struct_type(struct_union_type), scope_struct))
1600  return false; // ok
1601 
1602  else break;
1603  }
1604  }
1605 
1606  // check friendship
1607  const irept::subt &friends = struct_union_type.find(ID_C_friends).get_sub();
1608 
1609  forall_irep(f_it, friends)
1610  {
1611  const irept &friend_symb=*f_it;
1612 
1613  const cpp_scopet &friend_scope =
1614  cpp_scopes.get_scope(friend_symb.get(ID_identifier));
1615 
1616  for(cpp_scopet *pscope = &(cpp_scopes.current_scope());
1617  !(pscope->is_root_scope());
1618  pscope = &(pscope->get_parent()))
1619  {
1620  if(friend_scope.identifier==pscope->identifier)
1621  return false; // ok
1622 
1623  if(pscope->is_class())
1624  break;
1625  }
1626  }
1627 
1628  return true; // not ok
1629 }
1630 
1632  const struct_typet &type,
1633  std::set<irep_idt> &set_bases) const
1634 {
1635  for(const auto &b : type.bases())
1636  {
1637  DATA_INVARIANT(b.id() == ID_base, "base class expression expected");
1638 
1639  const struct_typet &base = to_struct_type(lookup(b.type()).type);
1640 
1641  set_bases.insert(base.get(ID_name));
1642  get_bases(base, set_bases);
1643  }
1644 }
1645 
1647  const struct_typet &type,
1648  std::list<irep_idt> &vbases) const
1649 {
1650  if(std::find(vbases.begin(), vbases.end(), type.get(ID_name))!=vbases.end())
1651  return;
1652 
1653  for(const auto &b : type.bases())
1654  {
1655  DATA_INVARIANT(b.id() == ID_base, "base class expression expected");
1656 
1657  const struct_typet &base = to_struct_type(lookup(b.type()).type);
1658 
1659  if(b.get_bool(ID_virtual))
1660  vbases.push_back(base.get(ID_name));
1661 
1662  get_virtual_bases(base, vbases);
1663  }
1664 }
1665 
1667  const struct_typet &from,
1668  const struct_typet &to) const
1669 {
1670  if(from.get(ID_name)==to.get(ID_name))
1671  return true;
1672 
1673  std::set<irep_idt> bases;
1674 
1675  get_bases(from, bases);
1676 
1677  return bases.find(to.get(ID_name))!=bases.end();
1678 }
1679 
1681  exprt &expr,
1682  const typet &dest_type)
1683 {
1684  typet src_type=expr.type();
1685 
1686  assert(src_type.id()== ID_pointer);
1687  assert(dest_type.id()== ID_pointer);
1688 
1689  const struct_typet &src_struct =
1690  to_struct_type(static_cast<const typet &>(follow(src_type.subtype())));
1691 
1692  const struct_typet &dest_struct =
1693  to_struct_type(static_cast<const typet &>(follow(dest_type.subtype())));
1694 
1695  PRECONDITION(
1696  subtype_typecast(src_struct, dest_struct) ||
1697  subtype_typecast(dest_struct, src_struct));
1698 
1699  expr = typecast_exprt(expr, dest_type);
1700 }
c_typecheck_baset::do_initializer
virtual void do_initializer(exprt &initializer, const typet &type, bool force_constant)
Definition: c_typecheck_initializer.cpp:25
exprt::copy_to_operands
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
Definition: expr.h:150
cpp_typecheckt::do_virtual_table
void do_virtual_table(const symbolt &symbol)
Definition: cpp_typecheck_virtual_table.cpp:17
struct_union_typet::components
const componentst & components() const
Definition: std_types.h:142
symbol_table_baset::has_symbol
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
Definition: symbol_table_base.h:87
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
cpp_idt::class_identifier
irep_idt class_identifier
Definition: cpp_id.h:81
code_blockt
A codet representing sequential composition of program statements.
Definition: std_code.h:170
dstringt::c_str
const char * c_str() const
Definition: dstring.h:99
cpp_declarationt::storage_spec
const cpp_storage_spect & storage_spec() const
Definition: cpp_declaration.h:74
cpp_scopet::get_parent
cpp_scopet & get_parent() const
Definition: cpp_scope.h:88
typet::subtype
const typet & subtype() const
Definition: type.h:47
cpp_typecheckt::convert_anon_struct_union_member
void convert_anon_struct_union_member(const cpp_declarationt &declaration, const irep_idt &access, struct_typet::componentst &components)
Definition: cpp_typecheck_compound_type.cpp:1417
cpp_declarationt::is_typedef
bool is_typedef() const
Definition: cpp_declaration.h:135
cpp_typecheckt::tag_scope
cpp_scopet & tag_scope(const irep_idt &_base_name, bool has_body, bool tag_only_declaration)
Definition: cpp_typecheck_compound_type.cpp:82
cpp_scopet
Definition: cpp_scope.h:21
cpp_typecheckt::elaborate_class_template
void elaborate_class_template(const typet &type)
elaborate class template instances
Definition: cpp_instantiate_template.cpp:224
cpp_typecheckt::anon_counter
unsigned anon_counter
Definition: cpp_typecheck.h:226
Forall_operands
#define Forall_operands(it, expr)
Definition: expr.h:24
arith_tools.h
symbolt::is_macro
bool is_macro
Definition: symbol.h:61
cpp_idt::id_classt::CLASS
@ CLASS
cpp_member_spect::set_inline
void set_inline(bool value)
Definition: cpp_member_spec.h:29
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_typecheckt::check_component_access
bool check_component_access(const struct_union_typet::componentt &component, const struct_union_typet &struct_union_type)
Definition: cpp_typecheck_compound_type.cpp:1568
cpp_save_scopet
Definition: cpp_scopes.h:129
irept::move_to_sub
void move_to_sub(irept &irep)
Definition: irep.cpp:42
cpp_scopest::id_map
id_mapt id_map
Definition: cpp_scopes.h:69
to_struct_union_type
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
Definition: std_types.h:209
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
irept::make_nil
void make_nil()
Definition: irep.h:475
CHECK_RETURN
#define CHECK_RETURN(CONDITION)
Definition: invariant.h:496
typet
The type of an expression, extends irept.
Definition: type.h:29
code_typet::parameterst
std::vector< parametert > parameterst
Definition: std_types.h:738
cpp_namet::namet
Definition: cpp_name.h:27
irept::pretty
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
Definition: irep.cpp:488
to_cpp_declaration
cpp_declarationt & to_cpp_declaration(irept &irep)
Definition: cpp_declaration.h:148
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
struct_union_typet
Base type for structs and unions.
Definition: std_types.h:57
cpp_typecheckt::typecheck_compound_body
void typecheck_compound_body(symbolt &symbol)
Definition: cpp_typecheck_compound_type.cpp:926
symbolt::type
typet type
Type of symbol.
Definition: symbol.h:31
cpp_typecheckt::convert_parameter
void convert_parameter(const irep_idt &current_mode, code_typet::parametert &parameter)
Definition: cpp_typecheck_function.cpp:22
side_effect_expr_function_callt
A side_effect_exprt representation of a function call side effect.
Definition: std_code.h:2117
mp_integer
BigInt mp_integer
Definition: mp_arith.h:19
code_typet::parametert::set_identifier
void set_identifier(const irep_idt &identifier)
Definition: std_types.h:782
irept::add
irept & add(const irep_namet &name)
Definition: irep.cpp:113
symbol_exprt::typeless
static symbol_exprt typeless(const irep_idt &id)
Generate a symbol_exprt without a proper type.
Definition: std_expr.h:101
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
cpp_typecheckt::typecheck_member_function
void typecheck_member_function(const symbolt &compound_symbol, struct_typet::componentt &component, irept &initializers, const typet &method_qualifier, exprt &value)
Definition: cpp_typecheck_compound_type.cpp:1254
irept::find
const irept & find(const irep_namet &name) const
Definition: irep.cpp:103
cpp_typecheckt::typecheck_compound_bases
void typecheck_compound_bases(struct_typet &type)
Definition: cpp_typecheck_bases.cpp:16
cpp_typecheck_resolvet
Definition: cpp_typecheck_resolve.h:21
namespacet::lookup
const symbolt & lookup(const irep_idt &name) const
Lookup a symbol in the namespace.
Definition: namespace.h:44
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
cpp_scopest::get_scope
cpp_scopet & get_scope(const irep_idt &identifier)
Definition: cpp_scopes.h:81
exprt
Base class for all expressions.
Definition: expr.h:53
struct_union_typet::componentst
std::vector< componentt > componentst
Definition: std_types.h:135
cpp_typecheckt::cpp_constructor
optionalt< codet > cpp_constructor(const source_locationt &source_location, const exprt &object, const exprt::operandst &operands)
Definition: cpp_constructor.cpp:25
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
struct_tag_typet
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:490
cpp_typecheckt::dtor
codet dtor(const symbolt &symb, const symbol_exprt &this_expr)
produces destructor code for a class object
Definition: cpp_typecheck_destructor.cpp:50
component
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
Definition: std_expr.cpp:192
irep_idt
dstringt irep_idt
Definition: irep.h:32
to_integer
bool to_integer(const constant_exprt &expr, mp_integer &int_value)
Convert a constant expression expr to an arbitrary-precision integer.
Definition: arith_tools.cpp:19
cpp_declarationt::is_destructor
bool is_destructor() const
Definition: cpp_declaration.h:47
cpp_scopet::SCOPE_ONLY
@ SCOPE_ONLY
Definition: cpp_scope.h:30
struct_union_typet::make_incomplete
void make_incomplete()
A struct/union may be incomplete.
Definition: std_types.h:186
to_string
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
Definition: string_constraint.cpp:55
struct_union_typet::default_access
irep_idt default_access() const
Return the access specification for members where access has not been modified.
Definition: std_types.h:174
messaget::eom
static eomt eom
Definition: message.h:297
cpp_idt::suffix
std::string suffix
Definition: cpp_id.h:85
c_qualifiers.h
cpp_declarationt::name_anon_struct_union
void name_anon_struct_union()
Definition: cpp_declaration.h:144
symbol_exprt
Expression to hold a symbol (variable)
Definition: std_expr.h:82
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
struct_union_typet::componentt::set_name
void set_name(const irep_idt &name)
Definition: std_types.h:79
cpp_idt::id_classt::BLOCK_SCOPE
@ BLOCK_SCOPE
cpp_scopet::contains
bool contains(const irep_idt &base_name_to_lookup)
Definition: cpp_scope.cpp:203
cpp_storage_spect::is_static
bool is_static() const
Definition: cpp_storage_spec.h:37
cpp_idt
Definition: cpp_id.h:29
union_tag_typet
A union tag type, i.e., union_typet with an identifier.
Definition: std_types.h:530
cpp_declarationt::declarators
const declaratorst & declarators() const
Definition: cpp_declaration.h:64
cpp_declarationt::member_spec
const cpp_member_spect & member_spec() const
Definition: cpp_declaration.h:86
cpp_typecheckt::typecheck_friend_declaration
void typecheck_friend_declaration(symbolt &symbol, cpp_declarationt &cpp_declaration)
Definition: cpp_typecheck_compound_type.cpp:854
symbolt::pretty_name
irep_idt pretty_name
Language-specific display name.
Definition: symbol.h:52
to_code
const codet & to_code(const exprt &expr)
Definition: std_code.h:155
cpp_typecheckt::default_dtor
void default_dtor(const symbolt &symb, cpp_declarationt &dtor)
Note:
Definition: cpp_typecheck_destructor.cpp:28
cpp_scopest::get_global_scope
cpp_scopet & get_global_scope()
Definition: cpp_scopes.h:116
cpp_idt::is_scope
bool is_scope
Definition: cpp_id.h:49
array_typet::size
const exprt & size() const
Definition: std_types.h:973
cpp_typecheckt::cpp_is_pod
bool cpp_is_pod(const typet &type) const
Definition: cpp_is_pod.cpp:14
cpp_member_spect::is_inline
bool is_inline() const
Definition: cpp_member_spec.h:24
cpp_idt::is_method
bool is_method
Definition: cpp_id.h:48
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:81
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
cpp_typecheckt::has_const
static bool has_const(const typet &type)
Definition: cpp_typecheck_compound_type.cpp:32
cpp_member_spect::is_virtual
bool is_virtual() const
Definition: cpp_member_spec.h:23
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_typecheckt::default_ctor
void default_ctor(const source_locationt &source_location, const irep_idt &base_name, cpp_declarationt &ctor) const
Generate code for implicit default constructors.
Definition: cpp_typecheck_constructor.cpp:119
cpp_scopest::go_to_global_scope
void go_to_global_scope()
Definition: cpp_scopes.h:111
symbolt::mode
irep_idt mode
Language mode.
Definition: symbol.h:49
cpp_member_spect::is_explicit
bool is_explicit() const
Definition: cpp_member_spec.h:26
messaget::error
mstreamt & error() const
Definition: message.h:399
cpp_idt::id_classt::SYMBOL
@ SYMBOL
cpp_typecheckt::get_virtual_bases
void get_virtual_bases(const struct_typet &type, std::list< irep_idt > &vbases) const
Definition: cpp_typecheck_compound_type.cpp:1646
cpp_typecheckt::add_method_body
void add_method_body(symbolt *_method_symbol)
Definition: cpp_typecheck_method_bodies.cpp:51
cpp_typecheckt::typecheck_compound_declarator
void typecheck_compound_declarator(const symbolt &symbol, const cpp_declarationt &declaration, cpp_declaratort &declarator, struct_typet::componentst &components, const irep_idt &access, bool is_static, bool is_typedef, bool is_mutable)
Definition: cpp_typecheck_compound_type.cpp:287
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition: invariant.h:511
exprt::has_operands
bool has_operands() const
Return true if there is at least one operand.
Definition: expr.h:92
symbol_table_baset::get_writeable_ref
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
Definition: symbol_table_base.h:121
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
struct_union_typet::componentt::get_name
const irep_idt & get_name() const
Definition: std_types.h:74
failed
static bool failed(bool error_indicator)
Definition: symtab2gb_parse_options.cpp:34
messaget::mstreamt::source_location
source_locationt source_location
Definition: message.h:247
cpp_declarator_convertert
Definition: cpp_declarator_converter.h:26
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:464
typet::source_location
const source_locationt & source_location() const
Definition: type.h:71
cpp_declarator_convertert::is_friend
bool is_friend
Definition: cpp_declarator_converter.h:34
symbol_exprt::get_identifier
const irep_idt & get_identifier() const
Definition: std_expr.h:111
cpp_symbol_expr
symbol_exprt cpp_symbol_expr(const symbolt &symbol)
Definition: cpp_util.cpp:14
struct_union_typet::componentt::set_pretty_name
void set_pretty_name(const irep_idt &name)
Definition: std_types.h:109
struct_union_typet::componentt::set_base_name
void set_base_name(const irep_idt &base_name)
Definition: std_types.h:89
cpp_namet::is_simple_name
bool is_simple_name() const
Definition: cpp_name.h:89
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
cpp_storage_spect::is_mutable
bool is_mutable() const
Definition: cpp_storage_spec.h:41
c_qualifierst::write
virtual void write(typet &src) const override
Definition: c_qualifiers.cpp:89
symbolt::symbol_expr
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
Definition: symbol.cpp:122
code_typet::set_inlined
void set_inlined(bool value)
Definition: std_types.h:872
cpp_typecheckt::make_ptr_typecast
void make_ptr_typecast(exprt &expr, const typet &dest_type)
Definition: cpp_typecheck_compound_type.cpp:1680
symbol_tablet::insert
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
Definition: symbol_table.cpp:19
struct_typet::bases
const basest & bases() const
Get the collection of base classes/structs.
Definition: std_types.h:257
c_qualifierst
Definition: c_qualifiers.h:61
c_typecheck_baset::symbol_table
symbol_tablet & symbol_table
Definition: c_typecheck_base.h:67
pointer_type
pointer_typet pointer_type(const typet &subtype)
Definition: c_types.cpp:243
cpp_typecheckt::put_compound_into_scope
void put_compound_into_scope(const struct_union_typet::componentt &component)
Definition: cpp_typecheck_compound_type.cpp:782
cpp_typecheckt::deferred_typechecking
std::unordered_set< irep_idt > deferred_typechecking
Definition: cpp_typecheck.h:595
irept::swap
void swap(irept &irep)
Definition: irep.h:463
to_symbol_expr
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition: std_expr.h:177
cpp_typecheckt::subtype_typecast
bool subtype_typecast(const struct_typet &from, const struct_typet &to) const
Definition: cpp_typecheck_compound_type.cpp:1666
code_typet
Base type of functions.
Definition: std_types.h:736
cpp_convert_type.h
C++ Language Conversion.
cpp_declarationt
Definition: cpp_declaration.h:24
c_typecheck_baset::make_constant_index
virtual void make_constant_index(exprt &expr)
Definition: c_typecheck_expr.cpp:3573
irept::is_nil
bool is_nil() const
Definition: irep.h:398
irept::id
const irep_idt & id() const
Definition: irep.h:418
irept::remove
void remove(const irep_namet &name)
Definition: irep.cpp:93
cpp_storage_spect::is_auto
bool is_auto() const
Definition: cpp_storage_spec.h:39
exprt::operandst
std::vector< exprt > operandst
Definition: expr.h:55
dstringt::empty
bool empty() const
Definition: dstring.h:88
cpp_typecheckt::get_component
bool get_component(const source_locationt &source_location, const exprt &object, const irep_idt &component_name, exprt &member)
Definition: cpp_typecheck_compound_type.cpp:1470
cpp_typecheckt::function_identifier
irep_idt function_identifier(const typet &type)
for function overloading
Definition: cpp_typecheck_function.cpp:158
code_typet::parameters
const parameterst & parameters() const
Definition: std_types.h:857
cpp_declarationt::is_template
bool is_template() const
Definition: cpp_declaration.h:52
typet::add_source_location
source_locationt & add_source_location()
Definition: type.h:76
cpp_typecheckt::convert_template_declaration
void convert_template_declaration(cpp_declarationt &declaration)
Definition: cpp_typecheck_template.cpp:967
cpp_declaratort::member_initializers
irept & member_initializers()
Definition: cpp_declarator.h:71
cpp_typecheckt::typecheck_compound_type
void typecheck_compound_type(struct_union_typet &) override
Definition: cpp_typecheck_compound_type.cpp:121
forall_subtypes
#define forall_subtypes(it, type)
Definition: type.h:216
cpp_typecheck.h
C++ Language Type Checking.
cpp_storage_spect::location
source_locationt & location()
Definition: cpp_storage_spec.h:27
cpp_scopet::RECURSIVE
@ RECURSIVE
Definition: cpp_scope.h:30
cpp_typecheckt::get_bases
void get_bases(const struct_typet &type, std::set< irep_idt > &set_bases) const
Definition: cpp_typecheck_compound_type.cpp:1631
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
code_typet::parametert::set_this
void set_this()
Definition: std_types.h:807
cpp_storage_spect::is_register
bool is_register() const
Definition: cpp_storage_spec.h:40
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
simplify_expr.h
member_exprt
Extract member of struct or union.
Definition: std_expr.h:3405
struct_union_typet::componentt
Definition: std_types.h:64
irept::get_string
const std::string & get_string(const irep_namet &name) const
Definition: irep.h:431
symbolt::value
exprt value
Initial value of symbol.
Definition: symbol.h:34
forall_irep
#define forall_irep(it, irep)
Definition: irep.h:62
cpp_namet::is_operator
bool is_operator() const
Definition: cpp_name.h:97
cpp_typecheckt::add_anonymous_members_to_scope
void add_anonymous_members_to_scope(const symbolt &struct_union_symbol)
Definition: cpp_typecheck_compound_type.cpp:1367
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
array_typet
Arrays with given size.
Definition: std_types.h:965
cpp_idt::is_static_member
bool is_static_member
Definition: cpp_id.h:48
code_returnt
codet representation of a "return from a function" statement.
Definition: std_code.h:1310
symbolt::is_extern
bool is_extern
Definition: symbol.h:66
cpp_declarationt::is_constructor
bool is_constructor() const
Definition: cpp_declaration.h:37
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
namespace_baset::follow
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
Definition: namespace.cpp:51
cpp_type2name
std::string cpp_type2name(const typet &type)
Definition: cpp_type2name.cpp:97
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
side_effect_expr_function_callt::arguments
exprt::operandst & arguments()
Definition: std_code.h:2161
symbolt::is_type
bool is_type
Definition: symbol.h:61
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
to_array_type
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
Definition: std_types.h:1011
cpp_typecheckt::has_volatile
static bool has_volatile(const typet &type)
Definition: cpp_typecheck_compound_type.cpp:48
code_typet::parametert
Definition: std_types.h:753
exprt::add_to_operands
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
Definition: expr.h:157
symbolt::is_static_lifetime
bool is_static_lifetime
Definition: symbol.h:65
already_typechecked_exprt
Definition: c_typecheck_base.h:282
cpp_declaratort::value
exprt & value()
Definition: cpp_declarator.h:42
cpp_idt::prefix
std::string prefix
Definition: cpp_id.h:85
symbol_table_baset::lookup
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
Definition: symbol_table_base.h:95
code_typet::return_type
const typet & return_type() const
Definition: std_types.h:847
irept
There are a large number of kinds of tree structured or tree-like data in CPROVER.
Definition: irep.h:394
cpp_typecheckt::find_assignop
bool find_assignop(const symbolt &symbol) const
Definition: cpp_typecheck_constructor.cpp:815
exprt::operands
operandst & operands()
Definition: expr.h:95
symbolt::is_lvalue
bool is_lvalue
Definition: symbol.h:66
exprt::add_source_location
source_locationt & add_source_location()
Definition: expr.h:259
struct_union_typet::componentt::get_base_name
const irep_idt & get_base_name() const
Definition: std_types.h:84
typecast_exprt
Semantic type conversion.
Definition: std_expr.h:2013
is_constructor
static bool is_constructor(const irep_idt &method_name)
Definition: java_bytecode_convert_method.cpp:128
uninitialized_typet
Definition: cpp_parse_tree.h:32
codet::get_statement
const irep_idt & get_statement() const
Definition: std_code.h:71
symbolt::module
irep_idt module
Name of module the symbol belongs to.
Definition: symbol.h:43
cpp_namet::get_base_name
irep_idt get_base_name() const
Definition: cpp_name.cpp:17
cpp_typecheckt::find_cpctor
bool find_cpctor(const symbolt &symbol) const
Definition: cpp_typecheck_constructor.cpp:766
cpp_typecheckt::default_assignop
void default_assignop(const symbolt &symbol, cpp_declarationt &cpctor)
Generate declaration of the implicit default assignment operator.
Definition: cpp_typecheck_constructor.cpp:278
cpp_idt::is_template_scope
bool is_template_scope() const
Definition: cpp_id.h:73
to_multi_ary_expr
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
Definition: std_expr.h:866
cpp_typecheckt::default_cpctor
void default_cpctor(const symbolt &, cpp_declarationt &cpctor) const
Generate code for implicit default copy constructor.
Definition: cpp_typecheck_constructor.cpp:141
cpp_namet
Definition: cpp_name.h:17
exprt::source_location
const source_locationt & source_location() const
Definition: expr.h:254
struct_union_typet::is_incomplete
bool is_incomplete() const
A struct/union may be incomplete.
Definition: std_types.h:180
c_types.h
cpp_typecheckt::dynamic_initializations
dynamic_initializationst dynamic_initializations
Definition: cpp_typecheck.h:593
cpp_typecheckt::disable_access_control
bool disable_access_control
Definition: cpp_typecheck.h:594
symbolt::is_weak
bool is_weak
Definition: symbol.h:67
symbolt::name
irep_idt name
The unique identifier.
Definition: symbol.h:40
cpp_scopest::set_scope
cpp_scopet & set_scope(const irep_idt &identifier)
Definition: cpp_scopes.h:88
cpp_member_spect::is_friend
bool is_friend() const
Definition: cpp_member_spec.h:25
cpp_declaratort
Definition: cpp_declarator.h:20
cpp_typecheckt::move_member_initializers
void move_member_initializers(irept &initializers, const code_typet &type, exprt &value)
Definition: cpp_typecheck_compound_type.cpp:1214
to_cpp_name
cpp_namet & to_cpp_name(irept &cpp_name)
Definition: cpp_name.h:144
validation_modet::INVARIANT
@ INVARIANT
code_expressiont
codet representation of an expression statement.
Definition: std_code.h:1810
cpp_scopet::insert
cpp_idt & insert(const irep_idt &_base_name)
Definition: cpp_scope.h:52
cpp_declarator_converter.h
C++ Language Type Checking.
cpp_declaratort::merge_type
typet merge_type(const typet &declaration_type) const
Definition: cpp_declarator.cpp:28
to_constant_expr
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Definition: std_expr.h:3939
cpp_name.h