CBMC
c_storage_spec.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #include "c_storage_spec.h"
10 
11 #include <util/string_constant.h>
12 
13 void c_storage_spect::read(const typet &type)
14 {
15  if(type.id()==ID_merged_type ||
16  type.id()==ID_code)
17  {
18  for(const typet &subtype : to_type_with_subtypes(type).subtypes())
19  read(subtype);
20  }
21  else if(type.id()==ID_static)
22  is_static=true;
23  else if(type.id()==ID_thread_local)
24  is_thread_local=true;
25  else if(type.id()==ID_inline)
26  is_inline=true;
27  else if(type.id()==ID_extern)
28  is_extern=true;
29  else if(type.id()==ID_typedef)
30  is_typedef=true;
31  else if(type.id()==ID_register)
32  is_register=true;
33  else if(type.id()==ID_weak)
34  is_weak=true;
35  else if(type.id() == ID_used)
36  is_used = true;
37  else if(type.id()==ID_auto)
38  {
39  // ignore
40  }
41  else if(type.id()==ID_msc_declspec)
42  {
43  const exprt &as_expr=
44  static_cast<const exprt &>(static_cast<const irept &>(type));
45  forall_operands(it, as_expr)
46  if(it->id()==ID_thread)
47  is_thread_local=true;
48  }
49  else if(
50  type.id() == ID_alias && type.has_subtype() &&
51  to_type_with_subtype(type).subtype().id() == ID_string_constant)
52  {
53  alias =
55  }
56  else if(
57  type.id() == ID_asm && !to_type_with_subtypes(type).subtypes().empty() &&
58  to_type_with_subtypes(type).subtypes()[0].id() == ID_string_constant)
59  {
60  asm_label =
61  to_string_constant(to_type_with_subtypes(type).subtypes()[0]).get_value();
62  }
63  else if(
64  type.id() == ID_section && type.has_subtype() &&
65  to_type_with_subtype(type).subtype().id() == ID_string_constant)
66  {
67  section =
69  }
70 }
typet
The type of an expression, extends irept.
Definition: type.h:28
typet::has_subtype
bool has_subtype() const
Definition: type.h:82
c_storage_spec.h
c_storage_spect::section
irep_idt section
Definition: c_storage_spec.h:54
c_storage_spect::is_extern
bool is_extern
Definition: c_storage_spec.h:46
to_string_constant
const string_constantt & to_string_constant(const exprt &expr)
Definition: string_constant.h:40
to_type_with_subtype
const type_with_subtypet & to_type_with_subtype(const typet &type)
Definition: type.h:193
to_type_with_subtypes
const type_with_subtypest & to_type_with_subtypes(const typet &type)
Definition: type.h:237
string_constant.h
exprt
Base class for all expressions.
Definition: expr.h:55
c_storage_spect::is_register
bool is_register
Definition: c_storage_spec.h:46
c_storage_spect::is_inline
bool is_inline
Definition: c_storage_spec.h:47
forall_operands
#define forall_operands(it, expr)
Definition: expr.h:20
c_storage_spect::asm_label
irep_idt asm_label
Definition: c_storage_spec.h:53
irept::id
const irep_idt & id() const
Definition: irep.h:396
c_storage_spect::alias
irep_idt alias
Definition: c_storage_spec.h:50
c_storage_spect::is_used
bool is_used
Definition: c_storage_spec.h:47
c_storage_spect::read
void read(const typet &type)
Definition: c_storage_spec.cpp:13
c_storage_spect::is_weak
bool is_weak
Definition: c_storage_spec.h:47
irept
There are a large number of kinds of tree structured or tree-like data in CPROVER.
Definition: irep.h:359
c_storage_spect::is_thread_local
bool is_thread_local
Definition: c_storage_spec.h:47
c_storage_spect::is_static
bool is_static
Definition: c_storage_spec.h:46
c_storage_spect::is_typedef
bool is_typedef
Definition: c_storage_spec.h:46
string_constantt::get_value
const irep_idt & get_value() const
Definition: string_constant.h:21