2 * This file is part of cparser.
3 * Copyright (C) 2012 Matthias Braun <matze@braunis.de>
10 #include "attribute.h"
11 #include <libfirm/firm_types.h>
13 #include "jump_target.h"
18 ENTITY_COMPOUND_MEMBER,
31 typedef unsigned char entity_kind_t;
33 typedef enum namespace_tag_t {
38 typedef unsigned char entity_namespace_t;
40 typedef enum storage_class_tag_t {
44 STORAGE_CLASS_TYPEDEF,
46 STORAGE_CLASS_REGISTER,
47 } storage_class_tag_t;
48 typedef unsigned char storage_class_t;
50 typedef enum decl_modifier_t {
52 DM_DLLIMPORT = 1 << 0,
53 DM_DLLEXPORT = 1 << 1,
56 DM_MICROSOFT_INLINE = 1 << 4,
57 DM_FORCEINLINE = 1 << 5,
58 DM_SELECTANY = 1 << 6,
62 DM_NOINLINE = 1 << 10,
63 DM_RESTRICT = 1 << 11,
65 DM_TRANSPARENT_UNION = 1 << 13,
68 DM_CONSTRUCTOR = 1 << 16,
69 DM_DESTRUCTOR = 1 << 17,
73 DM_FASTCALL = 1 << 21,
75 DM_THISCALL = 1 << 23,
76 DM_DEPRECATED = 1 << 24,
77 DM_RETURNS_TWICE = 1 << 25,
83 typedef enum elf_visibility_tag_t {
84 ELF_VISIBILITY_DEFAULT,
85 ELF_VISIBILITY_HIDDEN,
86 ELF_VISIBILITY_INTERNAL,
87 ELF_VISIBILITY_PROTECTED,
89 } elf_visibility_tag_t;
92 * A scope containing entities.
96 entity_t *last_entity; /**< pointer to last entity (so appending is fast) */
97 unsigned depth; /**< while parsing, the depth of this scope in the
102 * a named entity is something which can be referenced by its name
105 struct entity_base_t {
107 entity_namespace_t namespc;
110 scope_t *parent_scope; /**< The scope where this entity
112 entity_t *parent_entity;
114 /** next declaration in a scope */
116 /** next declaration with same symbol */
117 entity_t *symbol_next;
122 entity_t *alias; /* used for name mangling of anonymous types */
124 decl_modifiers_t modifiers;
125 attribute_t *attributes;
128 bool transparent_union : 1;
131 il_alignment_t alignment;
136 bool irtype_complete : 1;
141 entity_t *alias; /* used for name mangling of anonymous types */
145 struct enum_value_t {
157 bool address_taken : 1;
158 unsigned n_users; /* Reference counter to mature the label block as early as possible. */
159 statement_t *statement;
163 ir_node *indirect_block;
173 decl_modifiers_t modifiers;
175 il_alignment_t alignment;
179 struct declaration_t {
182 storage_class_t declared_storage_class;
183 storage_class_t storage_class;
184 decl_modifiers_t modifiers;
185 il_alignment_t alignment;
186 attribute_t *attributes;
187 bool used : 1; /**< Set if the declaration is used. */
188 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
194 struct compound_member_t {
196 il_size_t offset; /**< the offset of this member in the compound */
197 unsigned char bit_offset; /**< extra bit offset for bitfield members */
198 unsigned char bit_size; /**< bitsize for bitfield members */
199 bool bitfield : 1; /**< member is (part of) a bitfield */
207 bool thread_local : 1;
209 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
211 unsigned elf_visibility : 2;
213 initializer_t *initializer;
217 unsigned int value_number;
227 bool need_closure : 1; /**< Inner function needs closure. */
228 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
229 unsigned elf_visibility : 2;
234 symbol_t *actual_name; /**< gnu extension __REDIRECT */
238 ir_builtin_kind firm_builtin_kind;
239 unsigned chk_arg_pos;
242 ir_node *static_link; /**< if need_closure is set, the node
243 representing the static link. */
251 enum_value_t enum_value;
253 namespace_t namespacee;
255 declaration_t declaration;
258 compound_member_t compound_member;
261 #define DECLARATION_KIND_CASES \
263 case ENTITY_VARIABLE: \
264 case ENTITY_PARAMETER: \
265 case ENTITY_COMPOUND_MEMBER
267 static inline bool is_declaration(const entity_t *entity)
269 switch (entity->kind) {
270 case DECLARATION_KIND_CASES:
277 const char *get_entity_kind_name(entity_kind_t kind);
279 entity_t *allocate_entity_zero(entity_kind_t, entity_namespace_t, symbol_t*, position_t const*);
281 elf_visibility_tag_t get_elf_visibility_from_string(const char *string);
283 entity_t *skip_unnamed_bitfields(entity_t*);