authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-16 04:32:26-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-16 04:32:48-04:00
log3226b5315e4caa8fc8aaffaa258b07b212f230b1
tree690be370579aa290d345a85aa61e26cb6602e8d9
parentf488f3fd03d12ea02240855d4784cc2e283af7ed
signaturelock-open Commit is signed but in an unrecognized format.

translate-c: move some code to the C API

See #1964

3 files changed, 218 insertions(+), 70 deletions(-)

src/translate_c.cpp+51-34
......@@ -125,7 +125,16 @@ static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope
125125static AstNode *trans_qual_type(Context *c, ZigClangQualType qt, ZigClangSourceLocation source_loc);
126126static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope,
127127 const ZigClangExpr *expr, TransLRValue lrval);
128static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQualType qt, ZigClangSourceLocation source_loc);
128static AstNode *trans_ap_value(Context *c, const ZigClangAPValue *ap_value, ZigClangQualType qt,
129 ZigClangSourceLocation source_loc);
130
131static const ZigClangAPSInt *bitcast(const llvm::APSInt *src) {
132 return reinterpret_cast<const ZigClangAPSInt *>(src);
133}
134
135static const ZigClangAPValue *bitcast(const clang::APValue *src) {
136 return reinterpret_cast<const ZigClangAPValue *>(src);
137}
129138
130139static const ZigClangStmt *bitcast(const clang::Stmt *src) {
131140 return reinterpret_cast<const ZigClangStmt *>(src);
......@@ -497,16 +506,21 @@ static Buf *string_ref_to_buf(llvm::StringRef string_ref) {
497506 return buf_create_from_mem((const char *)string_ref.bytes_begin(), string_ref.size());
498507}
499508
500static AstNode *trans_create_node_apint(Context *c, const llvm::APSInt &aps_int) {
509static AstNode *trans_create_node_apint(Context *c, const ZigClangAPSInt *aps_int) {
501510 AstNode *node = trans_create_node(c, NodeTypeIntLiteral);
502511 node->data.int_literal.bigint = allocate<BigInt>(1);
503 bool is_negative = aps_int.isSigned() && aps_int.isNegative();
512 bool is_negative = ZigClangAPSInt_isSigned(aps_int) && ZigClangAPSInt_isNegative(aps_int);
504513 if (!is_negative) {
505 bigint_init_data(node->data.int_literal.bigint, aps_int.getRawData(), aps_int.getNumWords(), false);
514 bigint_init_data(node->data.int_literal.bigint,
515 ZigClangAPSInt_getRawData(aps_int),
516 ZigClangAPSInt_getNumWords(aps_int),
517 false);
506518 return node;
507519 }
508 llvm::APSInt negated = -aps_int;
509 bigint_init_data(node->data.int_literal.bigint, negated.getRawData(), negated.getNumWords(), true);
520 const ZigClangAPSInt *negated = ZigClangAPSInt_negate(aps_int);
521 bigint_init_data(node->data.int_literal.bigint, ZigClangAPSInt_getRawData(negated),
522 ZigClangAPSInt_getNumWords(negated), true);
523 ZigClangAPSInt_free(negated);
510524 return node;
511525
512526}
......@@ -1295,7 +1309,7 @@ static AstNode *trans_integer_literal(Context *c, ResultUsed result_used, const
12951309 emit_warning(c, bitcast(stmt->getBeginLoc()), "invalid integer literal");
12961310 return nullptr;
12971311 }
1298 AstNode *node = trans_create_node_apint(c, result.Val.getInt());
1312 AstNode *node = trans_create_node_apint(c, bitcast(&result.Val.getInt()));
12991313 return maybe_suppress_result(c, result_used, node);
13001314}
13011315
......@@ -1307,7 +1321,7 @@ static AstNode *trans_constant_expr(Context *c, ResultUsed result_used, const cl
13071321 emit_warning(c, bitcast(expr->getBeginLoc()), "invalid constant expression");
13081322 return nullptr;
13091323 }
1310 AstNode *node = trans_ap_value(c, &result.Val, bitcast(expr->getType()), bitcast(expr->getBeginLoc()));
1324 AstNode *node = trans_ap_value(c, bitcast(&result.Val), bitcast(expr->getType()), bitcast(expr->getBeginLoc()));
13111325 return maybe_suppress_result(c, result_used, node);
13121326}
13131327
......@@ -4103,7 +4117,8 @@ static AstNode *resolve_enum_decl(Context *c, const ZigClangEnumDecl *enum_decl)
41034117 field_name = enum_val_name;
41044118 }
41054119
4106 AstNode *int_node = pure_enum && !is_anonymous ? nullptr : trans_create_node_apint(c, enum_const->getInitVal());
4120 AstNode *int_node = pure_enum && !is_anonymous ?
4121 nullptr : trans_create_node_apint(c, bitcast(&enum_const->getInitVal()));
41074122 AstNode *field_node = trans_create_node(c, NodeTypeStructField);
41084123 field_node->data.struct_field.name = field_name;
41094124 field_node->data.struct_field.type = nullptr;
......@@ -4245,17 +4260,19 @@ static AstNode *resolve_record_decl(Context *c, const ZigClangRecordDecl *record
42454260 }
42464261}
42474262
4248static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQualType qt, ZigClangSourceLocation source_loc) {
4249 switch (ap_value->getKind()) {
4250 case clang::APValue::Int:
4251 return trans_create_node_apint(c, ap_value->getInt());
4252 case clang::APValue::Uninitialized:
4263static AstNode *trans_ap_value(Context *c, const ZigClangAPValue *ap_value, ZigClangQualType qt,
4264 ZigClangSourceLocation source_loc)
4265{
4266 switch (ZigClangAPValue_getKind(ap_value)) {
4267 case ZigClangAPValueInt:
4268 return trans_create_node_apint(c, ZigClangAPValue_getInt(ap_value));
4269 case ZigClangAPValueUninitialized:
42534270 return trans_create_node(c, NodeTypeUndefinedLiteral);
4254 case clang::APValue::Array: {
4271 case ZigClangAPValueArray: {
42554272 emit_warning(c, source_loc, "TODO add a test case for this code");
42564273
4257 unsigned init_count = ap_value->getArrayInitializedElts();
4258 unsigned all_count = ap_value->getArraySize();
4274 unsigned init_count = ZigClangAPValue_getArrayInitializedElts(ap_value);
4275 unsigned all_count = ZigClangAPValue_getArraySize(ap_value);
42594276 unsigned leftover_count = all_count - init_count;
42604277 AstNode *init_node = trans_create_node(c, NodeTypeContainerInitExpr);
42614278 AstNode *arr_type_node = trans_qual_type(c, qt, source_loc);
......@@ -4269,8 +4286,8 @@ static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQua
42694286 ZigClangQualType child_qt = bitcast(qt_type->getAsArrayTypeUnsafe()->getElementType());
42704287
42714288 for (size_t i = 0; i < init_count; i += 1) {
4272 clang::APValue &elem_ap_val = ap_value->getArrayInitializedElt(i);
4273 AstNode *elem_node = trans_ap_value(c, &elem_ap_val, child_qt, source_loc);
4289 const ZigClangAPValue *elem_ap_val = ZigClangAPValue_getArrayInitializedElt(ap_value, i);
4290 AstNode *elem_node = trans_ap_value(c, elem_ap_val, child_qt, source_loc);
42744291 if (elem_node == nullptr)
42754292 return nullptr;
42764293 init_node->data.container_init_expr.entries.append(elem_node);
......@@ -4279,8 +4296,8 @@ static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQua
42794296 return init_node;
42804297 }
42814298
4282 clang::APValue &filler_ap_val = ap_value->getArrayFiller();
4283 AstNode *filler_node = trans_ap_value(c, &filler_ap_val, child_qt, source_loc);
4299 const ZigClangAPValue *filler_ap_val = ZigClangAPValue_getArrayFiller(ap_value);
4300 AstNode *filler_node = trans_ap_value(c, filler_ap_val, child_qt, source_loc);
42844301 if (filler_node == nullptr)
42854302 return nullptr;
42864303
......@@ -4307,37 +4324,37 @@ static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQua
43074324
43084325 return trans_create_node_bin_op(c, init_node, BinOpTypeArrayCat, rhs_node);
43094326 }
4310 case clang::APValue::LValue: {
4311 const clang::APValue::LValueBase lval_base = ap_value->getLValueBase();
4312 if (const clang::Expr *expr = lval_base.dyn_cast<const clang::Expr *>()) {
4313 return trans_expr(c, ResultUsedYes, &c->global_scope->base, bitcast(expr), TransRValue);
4327 case ZigClangAPValueLValue: {
4328 const ZigClangAPValueLValueBase lval_base = ZigClangAPValue_getLValueBase(ap_value);
4329 if (const ZigClangExpr *expr = ZigClangAPValueLValueBase_dyn_cast_Expr(lval_base)) {
4330 return trans_expr(c, ResultUsedYes, &c->global_scope->base, expr, TransRValue);
43144331 }
43154332 //const clang::ValueDecl *value_decl = lval_base.get<const clang::ValueDecl *>();
43164333 emit_warning(c, source_loc, "TODO handle initializer LValue clang::ValueDecl");
43174334 return nullptr;
43184335 }
4319 case clang::APValue::Float:
4336 case ZigClangAPValueFloat:
43204337 emit_warning(c, source_loc, "unsupported initializer value kind: Float");
43214338 return nullptr;
4322 case clang::APValue::ComplexInt:
4339 case ZigClangAPValueComplexInt:
43234340 emit_warning(c, source_loc, "unsupported initializer value kind: ComplexInt");
43244341 return nullptr;
4325 case clang::APValue::ComplexFloat:
4342 case ZigClangAPValueComplexFloat:
43264343 emit_warning(c, source_loc, "unsupported initializer value kind: ComplexFloat");
43274344 return nullptr;
4328 case clang::APValue::Vector:
4345 case ZigClangAPValueVector:
43294346 emit_warning(c, source_loc, "unsupported initializer value kind: Vector");
43304347 return nullptr;
4331 case clang::APValue::Struct:
4348 case ZigClangAPValueStruct:
43324349 emit_warning(c, source_loc, "unsupported initializer value kind: Struct");
43334350 return nullptr;
4334 case clang::APValue::Union:
4351 case ZigClangAPValueUnion:
43354352 emit_warning(c, source_loc, "unsupported initializer value kind: Union");
43364353 return nullptr;
4337 case clang::APValue::MemberPointer:
4354 case ZigClangAPValueMemberPointer:
43384355 emit_warning(c, source_loc, "unsupported initializer value kind: MemberPointer");
43394356 return nullptr;
4340 case clang::APValue::AddrLabelDiff:
4357 case ZigClangAPValueAddrLabelDiff:
43414358 emit_warning(c, source_loc, "unsupported initializer value kind: AddrLabelDiff");
43424359 return nullptr;
43434360 }
......@@ -4374,7 +4391,7 @@ static void visit_var_decl(Context *c, const clang::VarDecl *var_decl) {
43744391 if (is_static && !is_extern) {
43754392 AstNode *init_node;
43764393 if (var_decl->hasInit()) {
4377 clang::APValue *ap_value = var_decl->evaluateValue();
4394 const ZigClangAPValue *ap_value = bitcast(var_decl->evaluateValue());
43784395 if (ap_value == nullptr) {
43794396 emit_warning(c, bitcast(var_decl->getLocation()),
43804397 "ignoring variable '%s' - unable to evaluate initializer", buf_ptr(name));
src/zig_clang.cpp+126-5
......@@ -28,7 +28,7 @@
2828#endif
2929
3030// Detect additions to the enum
31void zig2clang_BO(clang::BinaryOperatorKind op) {
31void ZigClang_detect_enum_BO(clang::BinaryOperatorKind op) {
3232 switch (op) {
3333 case clang::BO_PtrMemD:
3434 case clang::BO_PtrMemI:
......@@ -102,7 +102,7 @@ static_assert((clang::BinaryOperatorKind)ZigClangBO_Xor == clang::BO_Xor, "");
102102static_assert((clang::BinaryOperatorKind)ZigClangBO_XorAssign == clang::BO_XorAssign, "");
103103
104104// Detect additions to the enum
105void zig2clang_UO(clang::UnaryOperatorKind op) {
105void ZigClang_detect_enum_UO(clang::UnaryOperatorKind op) {
106106 switch (op) {
107107 case clang::UO_AddrOf:
108108 case clang::UO_Coawait:
......@@ -138,7 +138,7 @@ static_assert((clang::UnaryOperatorKind)ZigClangUO_PreInc == clang::UO_PreInc, "
138138static_assert((clang::UnaryOperatorKind)ZigClangUO_Real == clang::UO_Real, "");
139139
140140// Detect additions to the enum
141void zig2clang_CK(clang::CastKind x) {
141void ZigClang_detect_enum_CK(clang::CastKind x) {
142142 switch (x) {
143143 case clang::CK_ARCConsumeObject:
144144 case clang::CK_ARCExtendBlockObject:
......@@ -264,7 +264,7 @@ static_assert((clang::CastKind)ZigClangCK_AddressSpaceConversion == clang::CK_Ad
264264static_assert((clang::CastKind)ZigClangCK_IntToOCLSampler == clang::CK_IntToOCLSampler, "");
265265
266266// Detect additions to the enum
267void zig2clang_TypeClass(clang::Type::TypeClass ty) {
267void ZigClang_detect_enum_TypeClass(clang::Type::TypeClass ty) {
268268 switch (ty) {
269269 case clang::Type::Builtin:
270270 case clang::Type::Complex:
......@@ -366,7 +366,7 @@ static_assert((clang::Type::TypeClass)ZigClangType_Pipe == clang::Type::Pipe, ""
366366static_assert((clang::Type::TypeClass)ZigClangType_Atomic == clang::Type::Atomic, "");
367367
368368// Detect additions to the enum
369void zig2clang_StmtClass(clang::Stmt::StmtClass x) {
369void ZigClang_detect_enum_StmtClass(clang::Stmt::StmtClass x) {
370370 switch (x) {
371371 case clang::Stmt::NoStmtClass:
372372 case clang::Stmt::NullStmtClass:
......@@ -767,6 +767,37 @@ static_assert((clang::Stmt::StmtClass)ZigClangStmt_OMPTargetTeamsDistributeParal
767767static_assert((clang::Stmt::StmtClass)ZigClangStmt_OMPTargetTeamsDistributeParallelForSimdDirectiveClass == clang::Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass, "");
768768static_assert((clang::Stmt::StmtClass)ZigClangStmt_OMPTargetTeamsDistributeSimdDirectiveClass == clang::Stmt::OMPTargetTeamsDistributeSimdDirectiveClass, "");
769769
770void ZigClang_detect_enum_APValueKind(clang::APValue::ValueKind x) {
771 switch (x) {
772 case clang::APValue::Uninitialized:
773 case clang::APValue::Int:
774 case clang::APValue::Float:
775 case clang::APValue::ComplexInt:
776 case clang::APValue::ComplexFloat:
777 case clang::APValue::LValue:
778 case clang::APValue::Vector:
779 case clang::APValue::Array:
780 case clang::APValue::Struct:
781 case clang::APValue::Union:
782 case clang::APValue::MemberPointer:
783 case clang::APValue::AddrLabelDiff:
784 break;
785 }
786}
787
788static_assert((clang::APValue::ValueKind)ZigClangAPValueUninitialized == clang::APValue::Uninitialized, "");
789static_assert((clang::APValue::ValueKind)ZigClangAPValueInt == clang::APValue::Int, "");
790static_assert((clang::APValue::ValueKind)ZigClangAPValueFloat == clang::APValue::Float, "");
791static_assert((clang::APValue::ValueKind)ZigClangAPValueComplexInt == clang::APValue::ComplexInt, "");
792static_assert((clang::APValue::ValueKind)ZigClangAPValueComplexFloat == clang::APValue::ComplexFloat, "");
793static_assert((clang::APValue::ValueKind)ZigClangAPValueLValue == clang::APValue::LValue, "");
794static_assert((clang::APValue::ValueKind)ZigClangAPValueVector == clang::APValue::Vector, "");
795static_assert((clang::APValue::ValueKind)ZigClangAPValueArray == clang::APValue::Array, "");
796static_assert((clang::APValue::ValueKind)ZigClangAPValueStruct == clang::APValue::Struct, "");
797static_assert((clang::APValue::ValueKind)ZigClangAPValueUnion == clang::APValue::Union, "");
798static_assert((clang::APValue::ValueKind)ZigClangAPValueMemberPointer == clang::APValue::MemberPointer, "");
799static_assert((clang::APValue::ValueKind)ZigClangAPValueAddrLabelDiff == clang::APValue::AddrLabelDiff, "");
800
770801
771802static_assert(sizeof(ZigClangSourceLocation) == sizeof(clang::SourceLocation), "");
772803static ZigClangSourceLocation bitcast(clang::SourceLocation src) {
......@@ -792,6 +823,18 @@ static clang::QualType bitcast(ZigClangQualType src) {
792823 return dest;
793824}
794825
826static_assert(sizeof(ZigClangAPValueLValueBase) == sizeof(clang::APValue::LValueBase), "");
827static ZigClangAPValueLValueBase bitcast(clang::APValue::LValueBase src) {
828 ZigClangAPValueLValueBase dest;
829 memcpy(&dest, static_cast<void *>(&src), sizeof(ZigClangAPValueLValueBase));
830 return dest;
831}
832static clang::APValue::LValueBase bitcast(ZigClangAPValueLValueBase src) {
833 clang::APValue::LValueBase dest;
834 memcpy(&dest, static_cast<void *>(&src), sizeof(ZigClangAPValueLValueBase));
835 return dest;
836}
837
795838ZigClangSourceLocation ZigClangSourceManager_getSpellingLoc(const ZigClangSourceManager *self,
796839 ZigClangSourceLocation Loc)
797840{
......@@ -1026,3 +1069,81 @@ ZigClangSourceLocation ZigClangExpr_getBeginLoc(const ZigClangExpr *self) {
10261069 auto casted = reinterpret_cast<const clang::Expr *>(self);
10271070 return bitcast(casted->getBeginLoc());
10281071}
1072
1073ZigClangAPValueKind ZigClangAPValue_getKind(const ZigClangAPValue *self) {
1074 auto casted = reinterpret_cast<const clang::APValue *>(self);
1075 return (ZigClangAPValueKind)casted->getKind();
1076}
1077
1078const ZigClangAPSInt *ZigClangAPValue_getInt(const ZigClangAPValue *self) {
1079 auto casted = reinterpret_cast<const clang::APValue *>(self);
1080 const llvm::APSInt *result = &casted->getInt();
1081 return reinterpret_cast<const ZigClangAPSInt *>(result);
1082}
1083
1084unsigned ZigClangAPValue_getArrayInitializedElts(const ZigClangAPValue *self) {
1085 auto casted = reinterpret_cast<const clang::APValue *>(self);
1086 return casted->getArrayInitializedElts();
1087}
1088
1089const ZigClangAPValue *ZigClangAPValue_getArrayInitializedElt(const ZigClangAPValue *self, unsigned i) {
1090 auto casted = reinterpret_cast<const clang::APValue *>(self);
1091 const clang::APValue *result = &casted->getArrayInitializedElt(i);
1092 return reinterpret_cast<const ZigClangAPValue *>(result);
1093}
1094
1095const ZigClangAPValue *ZigClangAPValue_getArrayFiller(const ZigClangAPValue *self) {
1096 auto casted = reinterpret_cast<const clang::APValue *>(self);
1097 const clang::APValue *result = &casted->getArrayFiller();
1098 return reinterpret_cast<const ZigClangAPValue *>(result);
1099}
1100
1101unsigned ZigClangAPValue_getArraySize(const ZigClangAPValue *self) {
1102 auto casted = reinterpret_cast<const clang::APValue *>(self);
1103 return casted->getArraySize();
1104}
1105
1106const ZigClangAPSInt *ZigClangAPSInt_negate(const ZigClangAPSInt *self) {
1107 auto casted = reinterpret_cast<const llvm::APSInt *>(self);
1108 llvm::APSInt *result = new llvm::APSInt();
1109 *result = *casted;
1110 *result = -*result;
1111 return reinterpret_cast<const ZigClangAPSInt *>(result);
1112}
1113
1114void ZigClangAPSInt_free(const ZigClangAPSInt *self) {
1115 auto casted = reinterpret_cast<const llvm::APSInt *>(self);
1116 delete casted;
1117}
1118
1119bool ZigClangAPSInt_isSigned(const ZigClangAPSInt *self) {
1120 auto casted = reinterpret_cast<const llvm::APSInt *>(self);
1121 return casted->isSigned();
1122}
1123
1124bool ZigClangAPSInt_isNegative(const ZigClangAPSInt *self) {
1125 auto casted = reinterpret_cast<const llvm::APSInt *>(self);
1126 return casted->isNegative();
1127}
1128
1129const uint64_t *ZigClangAPSInt_getRawData(const ZigClangAPSInt *self) {
1130 auto casted = reinterpret_cast<const llvm::APSInt *>(self);
1131 return casted->getRawData();
1132}
1133
1134unsigned ZigClangAPSInt_getNumWords(const ZigClangAPSInt *self) {
1135 auto casted = reinterpret_cast<const llvm::APSInt *>(self);
1136 return casted->getNumWords();
1137}
1138
1139const ZigClangExpr *ZigClangAPValueLValueBase_dyn_cast_Expr(ZigClangAPValueLValueBase self) {
1140 clang::APValue::LValueBase casted = bitcast(self);
1141 const clang::Expr *expr = casted.dyn_cast<const clang::Expr *>();
1142 return reinterpret_cast<const ZigClangExpr *>(expr);
1143}
1144
1145ZigClangAPValueLValueBase ZigClangAPValue_getLValueBase(const ZigClangAPValue *self) {
1146 auto casted = reinterpret_cast<const clang::APValue *>(self);
1147 clang::APValue::LValueBase lval_base = casted->getLValueBase();
1148 return bitcast(lval_base);
1149}
src/zig_clang.h+41-31
......@@ -8,6 +8,8 @@
88#ifndef ZIG_ZIG_CLANG_H
99#define ZIG_ZIG_CLANG_H
1010
11#include <inttypes.h>
12
1113#ifdef __cplusplus
1214#define ZIG_EXTERN_C extern "C"
1315#else
......@@ -26,7 +28,14 @@ struct ZigClangQualType {
2628 void *ptr;
2729};
2830
31struct ZigClangAPValueLValueBase {
32 void *Ptr;
33 unsigned CallIndex;
34 unsigned Version;
35};
36
2937struct ZigClangAPValue;
38struct ZigClangAPSInt;
3039struct ZigClangASTContext;
3140struct ZigClangASTUnit;
3241struct ZigClangArraySubscriptExpr;
......@@ -400,24 +409,6 @@ enum ZigClangStmtClass {
400409 ZigClangStmt_WhileStmtClass,
401410};
402411
403//struct ZigClangCC_AAPCS;
404//struct ZigClangCC_AAPCS_VFP;
405//struct ZigClangCC_C;
406//struct ZigClangCC_IntelOclBicc;
407//struct ZigClangCC_OpenCLKernel;
408//struct ZigClangCC_PreserveAll;
409//struct ZigClangCC_PreserveMost;
410//struct ZigClangCC_SpirFunction;
411//struct ZigClangCC_Swift;
412//struct ZigClangCC_Win64;
413//struct ZigClangCC_X86FastCall;
414//struct ZigClangCC_X86Pascal;
415//struct ZigClangCC_X86RegCall;
416//struct ZigClangCC_X86StdCall;
417//struct ZigClangCC_X86ThisCall;
418//struct ZigClangCC_X86VectorCall;
419//struct ZigClangCC_X86_64SysV;
420
421412enum ZigClangCK {
422413 ZigClangCK_Dependent,
423414 ZigClangCK_BitCast,
......@@ -480,19 +471,20 @@ enum ZigClangCK {
480471 ZigClangCK_IntToOCLSampler,
481472};
482473
483//struct ZigClangETK_Class;
484//struct ZigClangETK_Enum;
485//struct ZigClangETK_Interface;
486//struct ZigClangETK_None;
487//struct ZigClangETK_Struct;
488//struct ZigClangETK_Typename;
489//struct ZigClangETK_Union;
490
491//struct ZigClangSC_None;
492//struct ZigClangSC_PrivateExtern;
493//struct ZigClangSC_Static;
494
495//struct ZigClangTU_Complete;
474enum ZigClangAPValueKind {
475 ZigClangAPValueUninitialized,
476 ZigClangAPValueInt,
477 ZigClangAPValueFloat,
478 ZigClangAPValueComplexInt,
479 ZigClangAPValueComplexFloat,
480 ZigClangAPValueLValue,
481 ZigClangAPValueVector,
482 ZigClangAPValueArray,
483 ZigClangAPValueStruct,
484 ZigClangAPValueUnion,
485 ZigClangAPValueMemberPointer,
486 ZigClangAPValueAddrLabelDiff,
487};
496488
497489ZIG_EXTERN_C ZigClangSourceLocation ZigClangSourceManager_getSpellingLoc(const ZigClangSourceManager *,
498490 ZigClangSourceLocation Loc);
......@@ -558,4 +550,22 @@ ZIG_EXTERN_C bool ZigClangStmt_classof_Expr(const ZigClangStmt *self);
558550ZIG_EXTERN_C ZigClangStmtClass ZigClangExpr_getStmtClass(const ZigClangExpr *self);
559551ZIG_EXTERN_C ZigClangQualType ZigClangExpr_getType(const ZigClangExpr *self);
560552ZIG_EXTERN_C ZigClangSourceLocation ZigClangExpr_getBeginLoc(const ZigClangExpr *self);
553
554ZIG_EXTERN_C ZigClangAPValueKind ZigClangAPValue_getKind(const ZigClangAPValue *self);
555ZIG_EXTERN_C const ZigClangAPSInt *ZigClangAPValue_getInt(const ZigClangAPValue *self);
556ZIG_EXTERN_C unsigned ZigClangAPValue_getArrayInitializedElts(const ZigClangAPValue *self);
557ZIG_EXTERN_C const ZigClangAPValue *ZigClangAPValue_getArrayInitializedElt(const ZigClangAPValue *self, unsigned i);
558ZIG_EXTERN_C const ZigClangAPValue *ZigClangAPValue_getArrayFiller(const ZigClangAPValue *self);
559ZIG_EXTERN_C unsigned ZigClangAPValue_getArraySize(const ZigClangAPValue *self);
560ZIG_EXTERN_C ZigClangAPValueLValueBase ZigClangAPValue_getLValueBase(const ZigClangAPValue *self);
561
562ZIG_EXTERN_C bool ZigClangAPSInt_isSigned(const ZigClangAPSInt *self);
563ZIG_EXTERN_C bool ZigClangAPSInt_isNegative(const ZigClangAPSInt *self);
564ZIG_EXTERN_C const ZigClangAPSInt *ZigClangAPSInt_negate(const ZigClangAPSInt *self);
565ZIG_EXTERN_C void ZigClangAPSInt_free(const ZigClangAPSInt *self);
566ZIG_EXTERN_C const uint64_t *ZigClangAPSInt_getRawData(const ZigClangAPSInt *self);
567ZIG_EXTERN_C unsigned ZigClangAPSInt_getNumWords(const ZigClangAPSInt *self);
568
569ZIG_EXTERN_C const ZigClangExpr *ZigClangAPValueLValueBase_dyn_cast_Expr(ZigClangAPValueLValueBase self);
570
561571#endif