cprover
c_storage_spec.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_ANSI_C_C_STORAGE_SPEC_H
11 #define CPROVER_ANSI_C_C_STORAGE_SPEC_H
12 
13 #include <util/type.h>
14 
16 {
17 public:
19  {
20  clear();
21  }
22 
23  explicit c_storage_spect(const typet &type)
24  {
25  clear();
26  read(type);
27  }
28 
29  void clear()
30  {
31  is_typedef=false;
32  is_extern=false;
33  is_thread_local=false;
34  is_static=false;
35  is_register=false;
36  is_inline=false;
37  is_weak=false;
38  is_used = false;
39  is_always_inline = false;
40  alias.clear();
41  asm_label.clear();
42  section.clear();
43  }
44 
47 
48  // __attribute__((alias("foo")))
50 
51  // GCC asm labels __asm__("foo") - these change the symbol name
54 
55  bool operator==(const c_storage_spect &other) const
56  {
57  // clang-format off
58  return is_typedef==other.is_typedef &&
59  is_extern==other.is_extern &&
60  is_static==other.is_static &&
61  is_register==other.is_register &&
63  is_inline==other.is_inline &&
64  is_weak==other.is_weak &&
65  is_used == other.is_used &&
67  alias==other.alias &&
68  asm_label==other.asm_label &&
69  section==other.section;
70  // clang-format on
71  }
72 
73  bool operator!=(const c_storage_spect &other) const
74  {
75  return !(*this==other);
76  }
77 
79  {
80  is_typedef |=other.is_typedef;
81  is_extern |=other.is_extern;
82  is_static |=other.is_static;
83  is_register |=other.is_register;
84  is_inline |=other.is_inline;
86  is_weak |=other.is_weak;
87  is_used |=other.is_used;
89  if(alias.empty())
90  alias=other.alias;
91  if(asm_label.empty())
92  asm_label=other.asm_label;
93  if(section.empty())
94  section=other.section;
95 
96  return *this;
97  }
98 
99  void read(const typet &type);
100 };
101 
102 #endif // CPROVER_ANSI_C_C_STORAGE_SPEC_H
The type of an expression.
Definition: type.h:22
c_storage_spect & operator|=(const c_storage_spect &other)
c_storage_spect(const typet &type)
void read(const typet &type)
bool operator!=(const c_storage_spect &other) const
void clear()
Definition: dstring.h:115
bool operator==(const c_storage_spect &other) const
bool empty() const
Definition: dstring.h:61
irep_idt asm_label