2 * This file is part of cparser.
3 * Copyright (C) 2012 Matthias Braun <matze@braunis.de>
11 #include "attribute.h"
12 #include <libfirm/firm_types.h>
14 #include "jump_target.h"
19 ENTITY_COMPOUND_MEMBER,
32 typedef unsigned char entity_kind_t;
34 typedef enum namespace_tag_t {
39 typedef unsigned char entity_namespace_t;
41 typedef enum storage_class_tag_t {
45 STORAGE_CLASS_TYPEDEF,
47 STORAGE_CLASS_REGISTER,
48 } storage_class_tag_t;
49 typedef unsigned char storage_class_t;
51 typedef enum decl_modifier_t {
53 DM_DLLIMPORT = 1 << 0,
54 DM_DLLEXPORT = 1 << 1,
57 DM_MICROSOFT_INLINE = 1 << 4,
58 DM_FORCEINLINE = 1 << 5,
59 DM_SELECTANY = 1 << 6,
63 DM_NOINLINE = 1 << 10,
64 DM_RESTRICT = 1 << 11,
66 DM_TRANSPARENT_UNION = 1 << 13,
69 DM_CONSTRUCTOR = 1 << 16,
70 DM_DESTRUCTOR = 1 << 17,
74 DM_FASTCALL = 1 << 21,
76 DM_THISCALL = 1 << 23,
77 DM_DEPRECATED = 1 << 24,
78 DM_RETURNS_TWICE = 1 << 25,
84 typedef enum elf_visibility_tag_t {
85 ELF_VISIBILITY_DEFAULT,
86 ELF_VISIBILITY_HIDDEN,
87 ELF_VISIBILITY_INTERNAL,
88 ELF_VISIBILITY_PROTECTED,
90 } elf_visibility_tag_t;
93 * A scope containing entities.
97 entity_t *last_entity; /**< pointer to last entity (so appending is fast) */
98 unsigned depth; /**< while parsing, the depth of this scope in the
103 * a named entity is something which can be referenced by its name
106 struct entity_base_t {
108 entity_namespace_t namespc;
111 scope_t *parent_scope; /**< The scope where this entity
113 entity_t *parent_entity;
115 /** next declaration in a scope */
117 /** next declaration with same symbol */
118 entity_t *symbol_next;
123 entity_t *alias; /* used for name mangling of anonymous types */
125 decl_modifiers_t modifiers;
126 attribute_t *attributes;
129 bool transparent_union : 1;
132 il_alignment_t alignment;
137 bool irtype_complete : 1;
142 entity_t *alias; /* used for name mangling of anonymous types */
146 struct enum_value_t {
158 bool address_taken : 1;
159 unsigned n_users; /* Reference counter to mature the label block as early as possible. */
160 statement_t *statement;
164 ir_node *indirect_block;
174 decl_modifiers_t modifiers;
176 il_alignment_t alignment;
180 struct declaration_t {
183 storage_class_t declared_storage_class;
184 storage_class_t storage_class;
185 decl_modifiers_t modifiers;
186 il_alignment_t alignment;
187 attribute_t *attributes;
188 bool used : 1; /**< Set if the declaration is used. */
189 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
195 struct compound_member_t {
197 il_size_t offset; /**< the offset of this member in the compound */
198 unsigned char bit_offset; /**< extra bit offset for bitfield members */
199 unsigned char bit_size; /**< bitsize for bitfield members */
200 bool bitfield : 1; /**< member is (part of) a bitfield */
208 bool thread_local : 1;
210 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
212 unsigned elf_visibility : 2;
214 initializer_t *initializer;
218 unsigned int value_number;
228 bool need_closure : 1; /**< Inner function needs closure. */
229 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
230 unsigned elf_visibility : 2;
235 symbol_t *actual_name; /**< gnu extension __REDIRECT */
239 ir_builtin_kind firm_builtin_kind;
240 unsigned chk_arg_pos;
243 ir_node *static_link; /**< if need_closure is set, the node
244 representing the static link. */
252 enum_value_t enum_value;
254 namespace_t namespacee;
256 declaration_t declaration;
259 compound_member_t compound_member;
262 #define DECLARATION_KIND_CASES \
264 case ENTITY_VARIABLE: \
265 case ENTITY_PARAMETER: \
266 case ENTITY_COMPOUND_MEMBER
268 static inline bool is_declaration(const entity_t *entity)
270 switch (entity->kind) {
271 case DECLARATION_KIND_CASES:
278 const char *get_entity_kind_name(entity_kind_t kind);
280 entity_t *allocate_entity_zero(entity_kind_t, entity_namespace_t, symbol_t*, position_t const*);
282 elf_visibility_tag_t get_elf_visibility_from_string(const char *string);
284 entity_t *skip_unnamed_bitfields(entity_t*);