| ... | @@ -113,7 +113,7 @@ static TransScopeSwitch *trans_scope_switch_create(Context *c, TransScope *paren | ... | @@ -113,7 +113,7 @@ static TransScopeSwitch *trans_scope_switch_create(Context *c, TransScope *paren |
| 113 | static TransScopeBlock *trans_scope_block_find(TransScope *scope); | 113 | static TransScopeBlock *trans_scope_block_find(TransScope *scope); |
| 114 | | 114 | |
| 115 | static AstNode *resolve_record_decl(Context *c, const ZigClangRecordDecl *record_decl); | 115 | static AstNode *resolve_record_decl(Context *c, const ZigClangRecordDecl *record_decl); |
| 116 | static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl); | 116 | static AstNode *resolve_enum_decl(Context *c, const ZigClangEnumDecl *enum_decl); |
| 117 | static AstNode *resolve_typedef_decl(Context *c, const clang::TypedefNameDecl *typedef_decl); | 117 | static AstNode *resolve_typedef_decl(Context *c, const clang::TypedefNameDecl *typedef_decl); |
| 118 | | 118 | |
| 119 | static int trans_stmt_extra(Context *c, TransScope *scope, const clang::Stmt *stmt, | 119 | static int trans_stmt_extra(Context *c, TransScope *scope, const clang::Stmt *stmt, |
| ... | @@ -1128,8 +1128,8 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -1128,8 +1128,8 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 1128 | } | 1128 | } |
| 1129 | case clang::Type::Enum: | 1129 | case clang::Type::Enum: |
| 1130 | { | 1130 | { |
| 1131 | const clang::EnumType *enum_ty = static_cast<const clang::EnumType*>(ty); | 1131 | const ZigClangEnumType *enum_ty = reinterpret_cast<const ZigClangEnumType*>(ty); |
| 1132 | return resolve_enum_decl(c, enum_ty->getDecl()); | 1132 | return resolve_enum_decl(c, ZigClangEnumType_getDecl(enum_ty)); |
| 1133 | } | 1133 | } |
| 1134 | case clang::Type::ConstantArray: | 1134 | case clang::Type::ConstantArray: |
| 1135 | { | 1135 | { |
| ... | @@ -2673,8 +2673,8 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2673,8 +2673,8 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2673 | | 2673 | |
| 2674 | case clang::Type::Enum: | 2674 | case clang::Type::Enum: |
| 2675 | { | 2675 | { |
| 2676 | const clang::EnumType *enum_ty = static_cast<const clang::EnumType*>(ty); | 2676 | const ZigClangEnumType *enum_ty = reinterpret_cast<const ZigClangEnumType *>(ty); |
| 2677 | AstNode *enum_type = resolve_enum_decl(c, enum_ty->getDecl()); | 2677 | AstNode *enum_type = resolve_enum_decl(c, ZigClangEnumType_getDecl(enum_ty)); |
| 2678 | return to_enum_zero_cmp(c, res, enum_type); | 2678 | return to_enum_zero_cmp(c, res, enum_type); |
| 2679 | } | 2679 | } |
| 2680 | | 2680 | |
| ... | @@ -4013,23 +4013,23 @@ static AstNode *resolve_typedef_decl(Context *c, const clang::TypedefNameDecl *t | ... | @@ -4013,23 +4013,23 @@ static AstNode *resolve_typedef_decl(Context *c, const clang::TypedefNameDecl *t |
| 4013 | return symbol_node; | 4013 | return symbol_node; |
| 4014 | } | 4014 | } |
| 4015 | | 4015 | |
| 4016 | struct AstNode *demote_enum_to_opaque(Context *c, const clang::EnumDecl *enum_decl, | 4016 | struct AstNode *demote_enum_to_opaque(Context *c, const ZigClangEnumDecl *enum_decl, Buf *full_type_name, |
| 4017 | Buf *full_type_name, Buf *bare_name) | 4017 | Buf *bare_name) |
| 4018 | { | 4018 | { |
| 4019 | AstNode *opaque_node = trans_create_node_opaque(c); | 4019 | AstNode *opaque_node = trans_create_node_opaque(c); |
| 4020 | if (full_type_name == nullptr) { | 4020 | if (full_type_name == nullptr) { |
| 4021 | c->decl_table.put(enum_decl->getCanonicalDecl(), opaque_node); | 4021 | c->decl_table.put(ZigClangEnumDecl_getCanonicalDecl(enum_decl), opaque_node); |
| 4022 | return opaque_node; | 4022 | return opaque_node; |
| 4023 | } | 4023 | } |
| 4024 | AstNode *symbol_node = trans_create_node_symbol(c, full_type_name); | 4024 | AstNode *symbol_node = trans_create_node_symbol(c, full_type_name); |
| 4025 | add_global_weak_alias(c, bare_name, full_type_name); | 4025 | add_global_weak_alias(c, bare_name, full_type_name); |
| 4026 | add_global_var(c, full_type_name, opaque_node); | 4026 | add_global_var(c, full_type_name, opaque_node); |
| 4027 | c->decl_table.put(enum_decl->getCanonicalDecl(), symbol_node); | 4027 | c->decl_table.put(ZigClangEnumDecl_getCanonicalDecl(enum_decl), symbol_node); |
| 4028 | return symbol_node; | 4028 | return symbol_node; |
| 4029 | } | 4029 | } |
| 4030 | | 4030 | |
| 4031 | static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) { | 4031 | static AstNode *resolve_enum_decl(Context *c, const ZigClangEnumDecl *enum_decl) { |
| 4032 | auto existing_entry = c->decl_table.maybe_get((void*)enum_decl->getCanonicalDecl()); | 4032 | auto existing_entry = c->decl_table.maybe_get(ZigClangEnumDecl_getCanonicalDecl(enum_decl)); |
| 4033 | if (existing_entry) { | 4033 | if (existing_entry) { |
| 4034 | return existing_entry->value; | 4034 | return existing_entry->value; |
| 4035 | } | 4035 | } |
| ... | @@ -4039,7 +4039,7 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) | ... | @@ -4039,7 +4039,7 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) |
| 4039 | Buf *bare_name = is_anonymous ? nullptr : buf_create_from_str(raw_name); | 4039 | Buf *bare_name = is_anonymous ? nullptr : buf_create_from_str(raw_name); |
| 4040 | Buf *full_type_name = is_anonymous ? nullptr : buf_sprintf("enum_%s", buf_ptr(bare_name)); | 4040 | Buf *full_type_name = is_anonymous ? nullptr : buf_sprintf("enum_%s", buf_ptr(bare_name)); |
| 4041 | | 4041 | |
| 4042 | const clang::EnumDecl *enum_def = enum_decl->getDefinition(); | 4042 | const ZigClangEnumDecl *enum_def = ZigClangEnumDecl_getDefinition(enum_decl); |
| 4043 | if (!enum_def) { | 4043 | if (!enum_def) { |
| 4044 | return demote_enum_to_opaque(c, enum_decl, full_type_name, bare_name); | 4044 | return demote_enum_to_opaque(c, enum_decl, full_type_name, bare_name); |
| 4045 | } | 4045 | } |
| ... | @@ -4047,8 +4047,8 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) | ... | @@ -4047,8 +4047,8 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) |
| 4047 | | 4047 | |
| 4048 | bool pure_enum = true; | 4048 | bool pure_enum = true; |
| 4049 | uint32_t field_count = 0; | 4049 | uint32_t field_count = 0; |
| 4050 | for (auto it = enum_def->enumerator_begin(), | 4050 | for (auto it = reinterpret_cast<const clang::EnumDecl *>(enum_def)->enumerator_begin(), |
| 4051 | it_end = enum_def->enumerator_end(); | 4051 | it_end = reinterpret_cast<const clang::EnumDecl *>(enum_def)->enumerator_end(); |
| 4052 | it != it_end; ++it, field_count += 1) | 4052 | it != it_end; ++it, field_count += 1) |
| 4053 | { | 4053 | { |
| 4054 | const clang::EnumConstantDecl *enum_const = *it; | 4054 | const clang::EnumConstantDecl *enum_const = *it; |
| ... | @@ -4056,7 +4056,9 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) | ... | @@ -4056,7 +4056,9 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) |
| 4056 | pure_enum = false; | 4056 | pure_enum = false; |
| 4057 | } | 4057 | } |
| 4058 | } | 4058 | } |
| 4059 | AstNode *tag_int_type = trans_qual_type(c, enum_decl->getIntegerType(), bitcast(enum_decl->getLocation())); | 4059 | AstNode *tag_int_type = trans_qual_type(c, |
| | 4060 | bitcast(ZigClangEnumDecl_getIntegerType(enum_decl)), |
| | 4061 | ZigClangEnumDecl_getLocation(enum_decl)); |
| 4060 | assert(tag_int_type); | 4062 | assert(tag_int_type); |
| 4061 | | 4063 | |
| 4062 | AstNode *enum_node = trans_create_node(c, NodeTypeContainerDecl); | 4064 | AstNode *enum_node = trans_create_node(c, NodeTypeContainerDecl); |
| ... | @@ -4065,15 +4067,15 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) | ... | @@ -4065,15 +4067,15 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) |
| 4065 | // TODO only emit this tag type if the enum tag type is not the default. | 4067 | // TODO only emit this tag type if the enum tag type is not the default. |
| 4066 | // I don't know what the default is, need to figure out how clang is deciding. | 4068 | // I don't know what the default is, need to figure out how clang is deciding. |
| 4067 | // it appears to at least be different across gcc/msvc | 4069 | // it appears to at least be different across gcc/msvc |
| 4068 | if (!c_is_builtin_type(c, enum_decl->getIntegerType(), clang::BuiltinType::UInt) && | 4070 | if (!c_is_builtin_type(c, bitcast(ZigClangEnumDecl_getIntegerType(enum_decl)), clang::BuiltinType::UInt) && |
| 4069 | !c_is_builtin_type(c, enum_decl->getIntegerType(), clang::BuiltinType::Int)) | 4071 | !c_is_builtin_type(c, bitcast(ZigClangEnumDecl_getIntegerType(enum_decl)), clang::BuiltinType::Int)) |
| 4070 | { | 4072 | { |
| 4071 | enum_node->data.container_decl.init_arg_expr = tag_int_type; | 4073 | enum_node->data.container_decl.init_arg_expr = tag_int_type; |
| 4072 | } | 4074 | } |
| 4073 | enum_node->data.container_decl.fields.resize(field_count); | 4075 | enum_node->data.container_decl.fields.resize(field_count); |
| 4074 | uint32_t i = 0; | 4076 | uint32_t i = 0; |
| 4075 | for (auto it = enum_def->enumerator_begin(), | 4077 | for (auto it = reinterpret_cast<const clang::EnumDecl *>(enum_def)->enumerator_begin(), |
| 4076 | it_end = enum_def->enumerator_end(); | 4078 | it_end = reinterpret_cast<const clang::EnumDecl *>(enum_def)->enumerator_end(); |
| 4077 | it != it_end; ++it, i += 1) | 4079 | it != it_end; ++it, i += 1) |
| 4078 | { | 4080 | { |
| 4079 | const clang::EnumConstantDecl *enum_const = *it; | 4081 | const clang::EnumConstantDecl *enum_const = *it; |
| ... | @@ -4106,13 +4108,13 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) | ... | @@ -4106,13 +4108,13 @@ static AstNode *resolve_enum_decl(Context *c, const clang::EnumDecl *enum_decl) |
| 4106 | } | 4108 | } |
| 4107 | | 4109 | |
| 4108 | if (is_anonymous) { | 4110 | if (is_anonymous) { |
| 4109 | c->decl_table.put(enum_decl->getCanonicalDecl(), enum_node); | 4111 | c->decl_table.put(ZigClangEnumDecl_getCanonicalDecl(enum_decl), enum_node); |
| 4110 | return enum_node; | 4112 | return enum_node; |
| 4111 | } else { | 4113 | } else { |
| 4112 | AstNode *symbol_node = trans_create_node_symbol(c, full_type_name); | 4114 | AstNode *symbol_node = trans_create_node_symbol(c, full_type_name); |
| 4113 | add_global_weak_alias(c, bare_name, full_type_name); | 4115 | add_global_weak_alias(c, bare_name, full_type_name); |
| 4114 | add_global_var(c, full_type_name, enum_node); | 4116 | add_global_var(c, full_type_name, enum_node); |
| 4115 | c->decl_table.put(enum_decl->getCanonicalDecl(), symbol_node); | 4117 | c->decl_table.put(ZigClangEnumDecl_getCanonicalDecl(enum_decl), symbol_node); |
| 4116 | return enum_node; | 4118 | return enum_node; |
| 4117 | } | 4119 | } |
| 4118 | } | 4120 | } |
| ... | @@ -4398,7 +4400,7 @@ static bool decl_visitor(void *context, const ZigClangDecl *zdecl) { | ... | @@ -4398,7 +4400,7 @@ static bool decl_visitor(void *context, const ZigClangDecl *zdecl) { |
| 4398 | resolve_typedef_decl(c, static_cast<const clang::TypedefNameDecl *>(decl)); | 4400 | resolve_typedef_decl(c, static_cast<const clang::TypedefNameDecl *>(decl)); |
| 4399 | break; | 4401 | break; |
| 4400 | case clang::Decl::Enum: | 4402 | case clang::Decl::Enum: |
| 4401 | resolve_enum_decl(c, static_cast<const clang::EnumDecl *>(decl)); | 4403 | resolve_enum_decl(c, reinterpret_cast<const ZigClangEnumDecl *>(decl)); |
| 4402 | break; | 4404 | break; |
| 4403 | case clang::Decl::Record: | 4405 | case clang::Decl::Record: |
| 4404 | resolve_record_decl(c, (const ZigClangRecordDecl *)(decl)); | 4406 | resolve_record_decl(c, (const ZigClangRecordDecl *)(decl)); |