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 */
148 struct enum_value_t {
160 bool address_taken : 1;
161 unsigned n_users; /* Reference counter to mature the label block as early as possible. */
162 statement_t *statement;
166 ir_node *indirect_block;
176 decl_modifiers_t modifiers;
178 il_alignment_t alignment;
182 struct declaration_t {
185 storage_class_t declared_storage_class;
186 storage_class_t storage_class;
187 decl_modifiers_t modifiers;
188 il_alignment_t alignment;
189 attribute_t *attributes;
190 bool used : 1; /**< Set if the declaration is used. */
191 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
197 struct compound_member_t {
199 il_size_t offset; /**< the offset of this member in the compound */
200 unsigned char bit_offset; /**< extra bit offset for bitfield members */
201 unsigned char bit_size; /**< bitsize for bitfield members */
202 bool bitfield : 1; /**< member is (part of) a bitfield */
210 bool thread_local : 1;
212 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
214 unsigned elf_visibility : 2;
216 initializer_t *initializer;
220 unsigned int value_number;
230 bool need_closure : 1; /**< Inner function needs closure. */
231 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
232 unsigned elf_visibility : 2;
237 symbol_t *actual_name; /**< gnu extension __REDIRECT */
241 ir_builtin_kind firm_builtin_kind;
242 unsigned chk_arg_pos;
245 ir_node *static_link; /**< if need_closure is set, the node
246 representing the static link. */
254 enum_value_t enum_value;
256 namespace_t namespacee;
258 declaration_t declaration;
261 compound_member_t compound_member;
264 #define DECLARATION_KIND_CASES \
266 case ENTITY_VARIABLE: \
267 case ENTITY_PARAMETER: \
268 case ENTITY_COMPOUND_MEMBER
270 static inline bool is_declaration(const entity_t *entity)
272 switch (entity->kind) {
273 case DECLARATION_KIND_CASES:
280 const char *get_entity_kind_name(entity_kind_t kind);
282 entity_t *allocate_entity_zero(entity_kind_t, entity_namespace_t, symbol_t*, position_t const*);
284 elf_visibility_tag_t get_elf_visibility_from_string(const char *string);
286 entity_t *skip_unnamed_bitfields(entity_t*);