| ... | @@ -122,9 +122,9 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const clang::Stmt *st | ... | @@ -122,9 +122,9 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const clang::Stmt *st |
| 122 | TransScope **out_node_scope); | 122 | TransScope **out_node_scope); |
| 123 | static TransScope *trans_stmt(Context *c, TransScope *scope, const clang::Stmt *stmt, AstNode **out_node); | 123 | static TransScope *trans_stmt(Context *c, TransScope *scope, const clang::Stmt *stmt, AstNode **out_node); |
| 124 | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::Expr *expr, TransLRValue lrval); | 124 | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::Expr *expr, TransLRValue lrval); |
| 125 | static AstNode *trans_qual_type(Context *c, clang::QualType qt, ZigClangSourceLocation source_loc); | 125 | static AstNode *trans_qual_type(Context *c, ZigClangQualType qt, ZigClangSourceLocation source_loc); |
| 126 | static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::Expr *expr, TransLRValue lrval); | 126 | static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::Expr *expr, TransLRValue lrval); |
| 127 | static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, clang::QualType qt, ZigClangSourceLocation source_loc); | 127 | static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQualType qt, ZigClangSourceLocation source_loc); |
| 128 | | 128 | |
| 129 | static ZigClangSourceLocation bitcast(clang::SourceLocation src) { | 129 | static ZigClangSourceLocation bitcast(clang::SourceLocation src) { |
| 130 | ZigClangSourceLocation dest; | 130 | ZigClangSourceLocation dest; |
| ... | @@ -136,11 +136,11 @@ static ZigClangQualType bitcast(clang::QualType src) { | ... | @@ -136,11 +136,11 @@ static ZigClangQualType bitcast(clang::QualType src) { |
| 136 | memcpy(&dest, static_cast<void *>(&src), sizeof(ZigClangQualType)); | 136 | memcpy(&dest, static_cast<void *>(&src), sizeof(ZigClangQualType)); |
| 137 | return dest; | 137 | return dest; |
| 138 | } | 138 | } |
| 139 | static clang::QualType bitcast(ZigClangQualType src) { | 139 | //static clang::QualType bitcast(ZigClangQualType src) { |
| 140 | clang::QualType dest; | 140 | // clang::QualType dest; |
| 141 | memcpy(&dest, static_cast<void *>(&src), sizeof(ZigClangQualType)); | 141 | // memcpy(&dest, static_cast<void *>(&src), sizeof(ZigClangQualType)); |
| 142 | return dest; | 142 | // return dest; |
| 143 | } | 143 | //} |
| 144 | | 144 | |
| 145 | ATTRIBUTE_PRINTF(3, 4) | 145 | ATTRIBUTE_PRINTF(3, 4) |
| 146 | static void emit_warning(Context *c, ZigClangSourceLocation sl, const char *format, ...) { | 146 | static void emit_warning(Context *c, ZigClangSourceLocation sl, const char *format, ...) { |
| ... | @@ -502,88 +502,77 @@ static AstNode *trans_create_node_apint(Context *c, const llvm::APSInt &aps_int) | ... | @@ -502,88 +502,77 @@ static AstNode *trans_create_node_apint(Context *c, const llvm::APSInt &aps_int) |
| 502 | | 502 | |
| 503 | } | 503 | } |
| 504 | | 504 | |
| 505 | static const clang::Type *qual_type_canon(clang::QualType qt) { | 505 | static const ZigClangType *qual_type_canon(ZigClangQualType qt) { |
| 506 | return qt.getCanonicalType().getTypePtr(); | 506 | ZigClangQualType canon = ZigClangQualType_getCanonicalType(qt); |
| | 507 | return ZigClangQualType_getTypePtr(canon); |
| 507 | } | 508 | } |
| 508 | | 509 | |
| 509 | static clang::QualType get_expr_qual_type(Context *c, const clang::Expr *expr) { | 510 | static ZigClangQualType get_expr_qual_type(Context *c, const clang::Expr *expr) { |
| 510 | // String literals in C are `char *` but they should really be `const char *`. | 511 | // String literals in C are `char *` but they should really be `const char *`. |
| 511 | if (expr->getStmtClass() == clang::Stmt::ImplicitCastExprClass) { | 512 | if (expr->getStmtClass() == clang::Stmt::ImplicitCastExprClass) { |
| 512 | const clang::ImplicitCastExpr *cast_expr = static_cast<const clang::ImplicitCastExpr *>(expr); | 513 | const clang::ImplicitCastExpr *cast_expr = static_cast<const clang::ImplicitCastExpr *>(expr); |
| 513 | if (cast_expr->getCastKind() == clang::CK_ArrayToPointerDecay) { | 514 | if (cast_expr->getCastKind() == clang::CK_ArrayToPointerDecay) { |
| 514 | const clang::Expr *sub_expr = cast_expr->getSubExpr(); | 515 | const clang::Expr *sub_expr = cast_expr->getSubExpr(); |
| 515 | if (sub_expr->getStmtClass() == clang::Stmt::StringLiteralClass) { | 516 | if (sub_expr->getStmtClass() == clang::Stmt::StringLiteralClass) { |
| 516 | clang::QualType array_qt = sub_expr->getType(); | 517 | ZigClangQualType array_qt = bitcast(sub_expr->getType()); |
| 517 | const clang::ArrayType *array_type = static_cast<const clang::ArrayType *>(array_qt.getTypePtr()); | 518 | const clang::ArrayType *array_type = reinterpret_cast<const clang::ArrayType *>( |
| 518 | clang::QualType pointee_qt = array_type->getElementType(); | 519 | ZigClangQualType_getTypePtr(array_qt)); |
| 519 | pointee_qt.addConst(); | 520 | ZigClangQualType pointee_qt = bitcast(array_type->getElementType()); |
| 520 | return bitcast(ZigClangASTContext_getPointerType(c->ctx, bitcast(pointee_qt))); | 521 | ZigClangQualType_addConst(&pointee_qt); |
| | 522 | return ZigClangASTContext_getPointerType(c->ctx, pointee_qt); |
| 521 | } | 523 | } |
| 522 | } | 524 | } |
| 523 | } | 525 | } |
| 524 | return expr->getType(); | 526 | return bitcast(expr->getType()); |
| 525 | } | 527 | } |
| 526 | | 528 | |
| 527 | static clang::QualType get_expr_qual_type_before_implicit_cast(Context *c, const clang::Expr *expr) { | 529 | static ZigClangQualType get_expr_qual_type_before_implicit_cast(Context *c, const clang::Expr *expr) { |
| 528 | if (expr->getStmtClass() == clang::Stmt::ImplicitCastExprClass) { | 530 | if (expr->getStmtClass() == clang::Stmt::ImplicitCastExprClass) { |
| 529 | const clang::ImplicitCastExpr *cast_expr = static_cast<const clang::ImplicitCastExpr *>(expr); | 531 | const clang::ImplicitCastExpr *cast_expr = static_cast<const clang::ImplicitCastExpr *>(expr); |
| 530 | return get_expr_qual_type(c, cast_expr->getSubExpr()); | 532 | return get_expr_qual_type(c, cast_expr->getSubExpr()); |
| 531 | } | 533 | } |
| 532 | return expr->getType(); | 534 | return bitcast(expr->getType()); |
| 533 | } | 535 | } |
| 534 | | 536 | |
| 535 | static AstNode *get_expr_type(Context *c, const clang::Expr *expr) { | 537 | static AstNode *get_expr_type(Context *c, const clang::Expr *expr) { |
| 536 | return trans_qual_type(c, get_expr_qual_type(c, expr), bitcast(expr->getBeginLoc())); | 538 | return trans_qual_type(c, get_expr_qual_type(c, expr), bitcast(expr->getBeginLoc())); |
| 537 | } | 539 | } |
| 538 | | 540 | |
| 539 | static bool qual_types_equal(clang::QualType t1, clang::QualType t2) { | | |
| 540 | if (t1.isConstQualified() != t2.isConstQualified()) { | | |
| 541 | return false; | | |
| 542 | } | | |
| 543 | if (t1.isVolatileQualified() != t2.isVolatileQualified()) { | | |
| 544 | return false; | | |
| 545 | } | | |
| 546 | if (t1.isRestrictQualified() != t2.isRestrictQualified()) { | | |
| 547 | return false; | | |
| 548 | } | | |
| 549 | return t1.getTypePtr() == t2.getTypePtr(); | | |
| 550 | } | | |
| 551 | | | |
| 552 | static bool is_c_void_type(AstNode *node) { | 541 | static bool is_c_void_type(AstNode *node) { |
| 553 | return (node->type == NodeTypeSymbol && buf_eql_str(node->data.symbol_expr.symbol, "c_void")); | 542 | return (node->type == NodeTypeSymbol && buf_eql_str(node->data.symbol_expr.symbol, "c_void")); |
| 554 | } | 543 | } |
| 555 | | 544 | |
| 556 | static bool expr_types_equal(Context *c, const clang::Expr *expr1, const clang::Expr *expr2) { | 545 | static bool expr_types_equal(Context *c, const clang::Expr *expr1, const clang::Expr *expr2) { |
| 557 | clang::QualType t1 = get_expr_qual_type(c, expr1); | 546 | ZigClangQualType t1 = get_expr_qual_type(c, expr1); |
| 558 | clang::QualType t2 = get_expr_qual_type(c, expr2); | 547 | ZigClangQualType t2 = get_expr_qual_type(c, expr2); |
| 559 | | 548 | |
| 560 | return qual_types_equal(t1, t2); | 549 | return ZigClangQualType_eq(t1, t2); |
| 561 | } | 550 | } |
| 562 | | 551 | |
| 563 | static bool qual_type_is_ptr(clang::QualType qt) { | 552 | static bool qual_type_is_ptr(ZigClangQualType qt) { |
| 564 | const clang::Type *ty = qual_type_canon(qt); | 553 | const ZigClangType *ty = qual_type_canon(qt); |
| 565 | return ty->getTypeClass() == clang::Type::Pointer; | 554 | return ZigClangType_getTypeClass(ty) == ZigClangType_Pointer; |
| 566 | } | 555 | } |
| 567 | | 556 | |
| 568 | static const clang::FunctionProtoType *qual_type_get_fn_proto(clang::QualType qt, bool *is_ptr) { | 557 | static const clang::FunctionProtoType *qual_type_get_fn_proto(ZigClangQualType qt, bool *is_ptr) { |
| 569 | const clang::Type *ty = qual_type_canon(qt); | 558 | const ZigClangType *ty = qual_type_canon(qt); |
| 570 | *is_ptr = false; | 559 | *is_ptr = false; |
| 571 | | 560 | |
| 572 | if (ty->getTypeClass() == clang::Type::Pointer) { | 561 | if (ZigClangType_getTypeClass(ty) == ZigClangType_Pointer) { |
| 573 | *is_ptr = true; | 562 | *is_ptr = true; |
| 574 | const clang::PointerType *pointer_ty = static_cast<const clang::PointerType*>(ty); | 563 | const clang::PointerType *pointer_ty = reinterpret_cast<const clang::PointerType*>(ty); |
| 575 | clang::QualType child_qt = pointer_ty->getPointeeType(); | 564 | ZigClangQualType child_qt = bitcast(pointer_ty->getPointeeType()); |
| 576 | ty = child_qt.getTypePtr(); | 565 | ty = ZigClangQualType_getTypePtr(child_qt); |
| 577 | } | 566 | } |
| 578 | | 567 | |
| 579 | if (ty->getTypeClass() == clang::Type::FunctionProto) { | 568 | if (ZigClangType_getTypeClass(ty) == ZigClangType_FunctionProto) { |
| 580 | return static_cast<const clang::FunctionProtoType*>(ty); | 569 | return reinterpret_cast<const clang::FunctionProtoType*>(ty); |
| 581 | } | 570 | } |
| 582 | | 571 | |
| 583 | return nullptr; | 572 | return nullptr; |
| 584 | } | 573 | } |
| 585 | | 574 | |
| 586 | static bool qual_type_is_fn_ptr(clang::QualType qt) { | 575 | static bool qual_type_is_fn_ptr(ZigClangQualType qt) { |
| 587 | bool is_ptr; | 576 | bool is_ptr; |
| 588 | if (qual_type_get_fn_proto(qt, &is_ptr)) { | 577 | if (qual_type_get_fn_proto(qt, &is_ptr)) { |
| 589 | return is_ptr; | 578 | return is_ptr; |
| ... | @@ -592,12 +581,12 @@ static bool qual_type_is_fn_ptr(clang::QualType qt) { | ... | @@ -592,12 +581,12 @@ static bool qual_type_is_fn_ptr(clang::QualType qt) { |
| 592 | return false; | 581 | return false; |
| 593 | } | 582 | } |
| 594 | | 583 | |
| 595 | static uint32_t qual_type_int_bit_width(Context *c, const clang::QualType qt, ZigClangSourceLocation source_loc) { | 584 | static uint32_t qual_type_int_bit_width(Context *c, const ZigClangQualType qt, ZigClangSourceLocation source_loc) { |
| 596 | const clang::Type *ty = qt.getTypePtr(); | 585 | const ZigClangType *ty = ZigClangQualType_getTypePtr(qt); |
| 597 | switch (ty->getTypeClass()) { | 586 | switch (ZigClangType_getTypeClass(ty)) { |
| 598 | case clang::Type::Builtin: | 587 | case ZigClangType_Builtin: |
| 599 | { | 588 | { |
| 600 | const clang::BuiltinType *builtin_ty = static_cast<const clang::BuiltinType*>(ty); | 589 | const clang::BuiltinType *builtin_ty = reinterpret_cast<const clang::BuiltinType*>(ty); |
| 601 | switch (builtin_ty->getKind()) { | 590 | switch (builtin_ty->getKind()) { |
| 602 | case clang::BuiltinType::Char_U: | 591 | case clang::BuiltinType::Char_U: |
| 603 | case clang::BuiltinType::UChar: | 592 | case clang::BuiltinType::UChar: |
| ... | @@ -612,7 +601,7 @@ static uint32_t qual_type_int_bit_width(Context *c, const clang::QualType qt, Zi | ... | @@ -612,7 +601,7 @@ static uint32_t qual_type_int_bit_width(Context *c, const clang::QualType qt, Zi |
| 612 | } | 601 | } |
| 613 | zig_unreachable(); | 602 | zig_unreachable(); |
| 614 | } | 603 | } |
| 615 | case clang::Type::Typedef: | 604 | case ZigClangType_Typedef: |
| 616 | { | 605 | { |
| 617 | const ZigClangTypedefType *typedef_ty = reinterpret_cast<const ZigClangTypedefType*>(ty); | 606 | const ZigClangTypedefType *typedef_ty = reinterpret_cast<const ZigClangTypedefType*>(ty); |
| 618 | const ZigClangTypedefNameDecl *typedef_decl = ZigClangTypedefType_getDecl(typedef_ty); | 607 | const ZigClangTypedefNameDecl *typedef_decl = ZigClangTypedefType_getDecl(typedef_ty); |
| ... | @@ -636,7 +625,7 @@ static uint32_t qual_type_int_bit_width(Context *c, const clang::QualType qt, Zi | ... | @@ -636,7 +625,7 @@ static uint32_t qual_type_int_bit_width(Context *c, const clang::QualType qt, Zi |
| 636 | } | 625 | } |
| 637 | | 626 | |
| 638 | | 627 | |
| 639 | static AstNode *qual_type_to_log2_int_ref(Context *c, const clang::QualType qt, | 628 | static AstNode *qual_type_to_log2_int_ref(Context *c, const ZigClangQualType qt, |
| 640 | ZigClangSourceLocation source_loc) | 629 | ZigClangSourceLocation source_loc) |
| 641 | { | 630 | { |
| 642 | uint32_t int_bit_width = qual_type_int_bit_width(c, qt, source_loc); | 631 | uint32_t int_bit_width = qual_type_int_bit_width(c, qt, source_loc); |
| ... | @@ -669,30 +658,31 @@ static AstNode *qual_type_to_log2_int_ref(Context *c, const clang::QualType qt, | ... | @@ -669,30 +658,31 @@ static AstNode *qual_type_to_log2_int_ref(Context *c, const clang::QualType qt, |
| 669 | return log2int_fn_call; | 658 | return log2int_fn_call; |
| 670 | } | 659 | } |
| 671 | | 660 | |
| 672 | static bool qual_type_child_is_fn_proto(const clang::QualType qt) { | 661 | static bool qual_type_child_is_fn_proto(ZigClangQualType qt) { |
| 673 | if (qt.getTypePtr()->getTypeClass() == clang::Type::Paren) { | 662 | const ZigClangType *ty = ZigClangQualType_getTypePtr(qt); |
| 674 | const clang::ParenType *paren_type = static_cast<const clang::ParenType *>(qt.getTypePtr()); | 663 | if (ZigClangType_getTypeClass(ty) == ZigClangType_Paren) { |
| | 664 | const clang::ParenType *paren_type = reinterpret_cast<const clang::ParenType *>(ty); |
| 675 | if (paren_type->getInnerType()->getTypeClass() == clang::Type::FunctionProto) { | 665 | if (paren_type->getInnerType()->getTypeClass() == clang::Type::FunctionProto) { |
| 676 | return true; | 666 | return true; |
| 677 | } | 667 | } |
| 678 | } else if (qt.getTypePtr()->getTypeClass() == clang::Type::Attributed) { | 668 | } else if (ZigClangType_getTypeClass(ty) == ZigClangType_Attributed) { |
| 679 | const clang::AttributedType *attr_type = static_cast<const clang::AttributedType *>(qt.getTypePtr()); | 669 | const clang::AttributedType *attr_type = reinterpret_cast<const clang::AttributedType *>(ty); |
| 680 | return qual_type_child_is_fn_proto(attr_type->getEquivalentType()); | 670 | return qual_type_child_is_fn_proto(bitcast(attr_type->getEquivalentType())); |
| 681 | } | 671 | } |
| 682 | return false; | 672 | return false; |
| 683 | } | 673 | } |
| 684 | | 674 | |
| 685 | static AstNode* trans_c_cast(Context *c, ZigClangSourceLocation source_location, clang::QualType dest_type, | 675 | static AstNode* trans_c_cast(Context *c, ZigClangSourceLocation source_location, ZigClangQualType dest_type, |
| 686 | clang::QualType src_type, AstNode *expr) | 676 | ZigClangQualType src_type, AstNode *expr) |
| 687 | { | 677 | { |
| 688 | // The only way void pointer casts are valid C code, is if | 678 | // The only way void pointer casts are valid C code, is if |
| 689 | // the value of the expression is ignored. We therefore just | 679 | // the value of the expression is ignored. We therefore just |
| 690 | // return the expr, and let the system that ignores values | 680 | // return the expr, and let the system that ignores values |
| 691 | // translate this correctly. | 681 | // translate this correctly. |
| 692 | if (qual_type_canon(dest_type)->isVoidType()) { | 682 | if (ZigClangType_isVoidType(qual_type_canon(dest_type))) { |
| 693 | return expr; | 683 | return expr; |
| 694 | } | 684 | } |
| 695 | if (qual_types_equal(dest_type, src_type)) { | 685 | if (ZigClangQualType_eq(dest_type, src_type)) { |
| 696 | return expr; | 686 | return expr; |
| 697 | } | 687 | } |
| 698 | if (qual_type_is_ptr(dest_type) && qual_type_is_ptr(src_type)) { | 688 | if (qual_type_is_ptr(dest_type) && qual_type_is_ptr(src_type)) { |
| ... | @@ -707,11 +697,11 @@ static AstNode* trans_c_cast(Context *c, ZigClangSourceLocation source_location, | ... | @@ -707,11 +697,11 @@ static AstNode* trans_c_cast(Context *c, ZigClangSourceLocation source_location, |
| 707 | return trans_create_node_fn_call_1(c, trans_qual_type(c, dest_type, source_location), expr); | 697 | return trans_create_node_fn_call_1(c, trans_qual_type(c, dest_type, source_location), expr); |
| 708 | } | 698 | } |
| 709 | | 699 | |
| 710 | static bool c_is_signed_integer(Context *c, clang::QualType qt) { | 700 | static bool c_is_signed_integer(Context *c, ZigClangQualType qt) { |
| 711 | const clang::Type *c_type = qual_type_canon(qt); | 701 | const ZigClangType *c_type = qual_type_canon(qt); |
| 712 | if (c_type->getTypeClass() != clang::Type::Builtin) | 702 | if (ZigClangType_getTypeClass(c_type) != ZigClangType_Builtin) |
| 713 | return false; | 703 | return false; |
| 714 | const clang::BuiltinType *builtin_ty = static_cast<const clang::BuiltinType*>(c_type); | 704 | const clang::BuiltinType *builtin_ty = reinterpret_cast<const clang::BuiltinType*>(c_type); |
| 715 | switch (builtin_ty->getKind()) { | 705 | switch (builtin_ty->getKind()) { |
| 716 | case clang::BuiltinType::SChar: | 706 | case clang::BuiltinType::SChar: |
| 717 | case clang::BuiltinType::Short: | 707 | case clang::BuiltinType::Short: |
| ... | @@ -726,11 +716,11 @@ static bool c_is_signed_integer(Context *c, clang::QualType qt) { | ... | @@ -726,11 +716,11 @@ static bool c_is_signed_integer(Context *c, clang::QualType qt) { |
| 726 | } | 716 | } |
| 727 | } | 717 | } |
| 728 | | 718 | |
| 729 | static bool c_is_unsigned_integer(Context *c, clang::QualType qt) { | 719 | static bool c_is_unsigned_integer(Context *c, ZigClangQualType qt) { |
| 730 | const clang::Type *c_type = qual_type_canon(qt); | 720 | const ZigClangType *c_type = qual_type_canon(qt); |
| 731 | if (c_type->getTypeClass() != clang::Type::Builtin) | 721 | if (ZigClangType_getTypeClass(c_type) != ZigClangType_Builtin) |
| 732 | return false; | 722 | return false; |
| 733 | const clang::BuiltinType *builtin_ty = static_cast<const clang::BuiltinType*>(c_type); | 723 | const clang::BuiltinType *builtin_ty = reinterpret_cast<const clang::BuiltinType*>(c_type); |
| 734 | switch (builtin_ty->getKind()) { | 724 | switch (builtin_ty->getKind()) { |
| 735 | case clang::BuiltinType::Char_U: | 725 | case clang::BuiltinType::Char_U: |
| 736 | case clang::BuiltinType::UChar: | 726 | case clang::BuiltinType::UChar: |
| ... | @@ -747,19 +737,19 @@ static bool c_is_unsigned_integer(Context *c, clang::QualType qt) { | ... | @@ -747,19 +737,19 @@ static bool c_is_unsigned_integer(Context *c, clang::QualType qt) { |
| 747 | } | 737 | } |
| 748 | } | 738 | } |
| 749 | | 739 | |
| 750 | static bool c_is_builtin_type(Context *c, clang::QualType qt, clang::BuiltinType::Kind kind) { | 740 | static bool c_is_builtin_type(Context *c, ZigClangQualType qt, clang::BuiltinType::Kind kind) { |
| 751 | const clang::Type *c_type = qual_type_canon(qt); | 741 | const ZigClangType *c_type = qual_type_canon(qt); |
| 752 | if (c_type->getTypeClass() != clang::Type::Builtin) | 742 | if (ZigClangType_getTypeClass(c_type) != ZigClangType_Builtin) |
| 753 | return false; | 743 | return false; |
| 754 | const clang::BuiltinType *builtin_ty = static_cast<const clang::BuiltinType*>(c_type); | 744 | const clang::BuiltinType *builtin_ty = reinterpret_cast<const clang::BuiltinType*>(c_type); |
| 755 | return builtin_ty->getKind() == kind; | 745 | return builtin_ty->getKind() == kind; |
| 756 | } | 746 | } |
| 757 | | 747 | |
| 758 | static bool c_is_float(Context *c, clang::QualType qt) { | 748 | static bool c_is_float(Context *c, ZigClangQualType qt) { |
| 759 | const clang::Type *c_type = qt.getTypePtr(); | 749 | const ZigClangType *c_type = ZigClangQualType_getTypePtr(qt); |
| 760 | if (c_type->getTypeClass() != clang::Type::Builtin) | 750 | if (ZigClangType_getTypeClass(c_type) != ZigClangType_Builtin) |
| 761 | return false; | 751 | return false; |
| 762 | const clang::BuiltinType *builtin_ty = static_cast<const clang::BuiltinType*>(c_type); | 752 | const clang::BuiltinType *builtin_ty = reinterpret_cast<const clang::BuiltinType*>(c_type); |
| 763 | switch (builtin_ty->getKind()) { | 753 | switch (builtin_ty->getKind()) { |
| 764 | case clang::BuiltinType::Half: | 754 | case clang::BuiltinType::Half: |
| 765 | case clang::BuiltinType::Float: | 755 | case clang::BuiltinType::Float: |
| ... | @@ -772,7 +762,7 @@ static bool c_is_float(Context *c, clang::QualType qt) { | ... | @@ -772,7 +762,7 @@ static bool c_is_float(Context *c, clang::QualType qt) { |
| 772 | } | 762 | } |
| 773 | } | 763 | } |
| 774 | | 764 | |
| 775 | static bool qual_type_has_wrapping_overflow(Context *c, clang::QualType qt) { | 765 | static bool qual_type_has_wrapping_overflow(Context *c, ZigClangQualType qt) { |
| 776 | if (c_is_signed_integer(c, qt) || c_is_float(c, qt)) { | 766 | if (c_is_signed_integer(c, qt) || c_is_float(c, qt)) { |
| 777 | // float and signed integer overflow is undefined behavior. | 767 | // float and signed integer overflow is undefined behavior. |
| 778 | return false; | 768 | return false; |
| ... | @@ -782,37 +772,37 @@ static bool qual_type_has_wrapping_overflow(Context *c, clang::QualType qt) { | ... | @@ -782,37 +772,37 @@ static bool qual_type_has_wrapping_overflow(Context *c, clang::QualType qt) { |
| 782 | } | 772 | } |
| 783 | } | 773 | } |
| 784 | | 774 | |
| 785 | static bool type_is_opaque(Context *c, const clang::Type *ty, ZigClangSourceLocation source_loc) { | 775 | static bool type_is_opaque(Context *c, const ZigClangType *ty, ZigClangSourceLocation source_loc) { |
| 786 | switch (ty->getTypeClass()) { | 776 | switch (ZigClangType_getTypeClass(ty)) { |
| 787 | case clang::Type::Builtin: { | 777 | case ZigClangType_Builtin: { |
| 788 | const clang::BuiltinType *builtin_ty = static_cast<const clang::BuiltinType*>(ty); | 778 | const clang::BuiltinType *builtin_ty = reinterpret_cast<const clang::BuiltinType*>(ty); |
| 789 | return builtin_ty->getKind() == clang::BuiltinType::Void; | 779 | return builtin_ty->getKind() == clang::BuiltinType::Void; |
| 790 | } | 780 | } |
| 791 | case clang::Type::Record: { | 781 | case ZigClangType_Record: { |
| 792 | const clang::RecordType *record_ty = static_cast<const clang::RecordType*>(ty); | 782 | const clang::RecordType *record_ty = reinterpret_cast<const clang::RecordType*>(ty); |
| 793 | return record_ty->getDecl()->getDefinition() == nullptr; | 783 | return record_ty->getDecl()->getDefinition() == nullptr; |
| 794 | } | 784 | } |
| 795 | case clang::Type::Elaborated: { | 785 | case ZigClangType_Elaborated: { |
| 796 | const clang::ElaboratedType *elaborated_ty = static_cast<const clang::ElaboratedType*>(ty); | 786 | const clang::ElaboratedType *elaborated_ty = reinterpret_cast<const clang::ElaboratedType*>(ty); |
| 797 | return type_is_opaque(c, elaborated_ty->getNamedType().getTypePtr(), source_loc); | 787 | ZigClangQualType qt = bitcast(elaborated_ty->getNamedType()); |
| | 788 | return type_is_opaque(c, ZigClangQualType_getTypePtr(qt), source_loc); |
| 798 | } | 789 | } |
| 799 | case clang::Type::Typedef: { | 790 | case ZigClangType_Typedef: { |
| 800 | const ZigClangTypedefType *typedef_ty = reinterpret_cast<const ZigClangTypedefType*>(ty); | 791 | const ZigClangTypedefType *typedef_ty = reinterpret_cast<const ZigClangTypedefType*>(ty); |
| 801 | const ZigClangTypedefNameDecl *typedef_decl = ZigClangTypedefType_getDecl(typedef_ty); | 792 | const ZigClangTypedefNameDecl *typedef_decl = ZigClangTypedefType_getDecl(typedef_ty); |
| 802 | ZigClangQualType underlying_type = ZigClangTypedefNameDecl_getUnderlyingType(typedef_decl); | 793 | ZigClangQualType underlying_type = ZigClangTypedefNameDecl_getUnderlyingType(typedef_decl); |
| 803 | clang::QualType qt = bitcast(underlying_type); | 794 | return type_is_opaque(c, ZigClangQualType_getTypePtr(underlying_type), source_loc); |
| 804 | return type_is_opaque(c, qt.getTypePtr(), source_loc); | | |
| 805 | } | 795 | } |
| 806 | default: | 796 | default: |
| 807 | return false; | 797 | return false; |
| 808 | } | 798 | } |
| 809 | } | 799 | } |
| 810 | | 800 | |
| 811 | static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLocation source_loc) { | 801 | static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLocation source_loc) { |
| 812 | switch (ty->getTypeClass()) { | 802 | switch (ZigClangType_getTypeClass(ty)) { |
| 813 | case clang::Type::Builtin: | 803 | case ZigClangType_Builtin: |
| 814 | { | 804 | { |
| 815 | const clang::BuiltinType *builtin_ty = static_cast<const clang::BuiltinType*>(ty); | 805 | const clang::BuiltinType *builtin_ty = reinterpret_cast<const clang::BuiltinType*>(ty); |
| 816 | switch (builtin_ty->getKind()) { | 806 | switch (builtin_ty->getKind()) { |
| 817 | case clang::BuiltinType::Void: | 807 | case clang::BuiltinType::Void: |
| 818 | return trans_create_node_symbol_str(c, "c_void"); | 808 | return trans_create_node_symbol_str(c, "c_void"); |
| ... | @@ -955,10 +945,10 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -955,10 +945,10 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 955 | } | 945 | } |
| 956 | break; | 946 | break; |
| 957 | } | 947 | } |
| 958 | case clang::Type::Pointer: | 948 | case ZigClangType_Pointer: |
| 959 | { | 949 | { |
| 960 | const clang::PointerType *pointer_ty = static_cast<const clang::PointerType*>(ty); | 950 | const clang::PointerType *pointer_ty = reinterpret_cast<const clang::PointerType*>(ty); |
| 961 | clang::QualType child_qt = pointer_ty->getPointeeType(); | 951 | ZigClangQualType child_qt = bitcast(pointer_ty->getPointeeType()); |
| 962 | AstNode *child_node = trans_qual_type(c, child_qt, source_loc); | 952 | AstNode *child_node = trans_qual_type(c, child_qt, source_loc); |
| 963 | if (child_node == nullptr) { | 953 | if (child_node == nullptr) { |
| 964 | emit_warning(c, source_loc, "pointer to unsupported type"); | 954 | emit_warning(c, source_loc, "pointer to unsupported type"); |
| ... | @@ -969,29 +959,33 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -969,29 +959,33 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 969 | return trans_create_node_prefix_op(c, PrefixOpOptional, child_node); | 959 | return trans_create_node_prefix_op(c, PrefixOpOptional, child_node); |
| 970 | } | 960 | } |
| 971 | | 961 | |
| 972 | if (type_is_opaque(c, child_qt.getTypePtr(), source_loc)) { | 962 | if (type_is_opaque(c, ZigClangQualType_getTypePtr(child_qt), source_loc)) { |
| 973 | AstNode *pointer_node = trans_create_node_ptr_type(c, child_qt.isConstQualified(), | 963 | AstNode *pointer_node = trans_create_node_ptr_type(c, |
| 974 | child_qt.isVolatileQualified(), child_node, PtrLenSingle); | 964 | ZigClangQualType_isConstQualified(child_qt), |
| | 965 | ZigClangQualType_isVolatileQualified(child_qt), |
| | 966 | child_node, PtrLenSingle); |
| 975 | return trans_create_node_prefix_op(c, PrefixOpOptional, pointer_node); | 967 | return trans_create_node_prefix_op(c, PrefixOpOptional, pointer_node); |
| 976 | } else { | 968 | } else { |
| 977 | return trans_create_node_ptr_type(c, child_qt.isConstQualified(), | 969 | return trans_create_node_ptr_type(c, |
| 978 | child_qt.isVolatileQualified(), child_node, PtrLenC); | 970 | ZigClangQualType_isConstQualified(child_qt), |
| | 971 | ZigClangQualType_isVolatileQualified(child_qt), |
| | 972 | child_node, PtrLenC); |
| 979 | } | 973 | } |
| 980 | } | 974 | } |
| 981 | case clang::Type::Typedef: | 975 | case ZigClangType_Typedef: |
| 982 | { | 976 | { |
| 983 | const ZigClangTypedefType *typedef_ty = reinterpret_cast<const ZigClangTypedefType*>(ty); | 977 | const ZigClangTypedefType *typedef_ty = reinterpret_cast<const ZigClangTypedefType*>(ty); |
| 984 | const ZigClangTypedefNameDecl *typedef_decl = ZigClangTypedefType_getDecl(typedef_ty); | 978 | const ZigClangTypedefNameDecl *typedef_decl = ZigClangTypedefType_getDecl(typedef_ty); |
| 985 | return resolve_typedef_decl(c, typedef_decl); | 979 | return resolve_typedef_decl(c, typedef_decl); |
| 986 | } | 980 | } |
| 987 | case clang::Type::Elaborated: | 981 | case ZigClangType_Elaborated: |
| 988 | { | 982 | { |
| 989 | const clang::ElaboratedType *elaborated_ty = static_cast<const clang::ElaboratedType*>(ty); | 983 | const clang::ElaboratedType *elaborated_ty = reinterpret_cast<const clang::ElaboratedType*>(ty); |
| 990 | switch (elaborated_ty->getKeyword()) { | 984 | switch (elaborated_ty->getKeyword()) { |
| 991 | case clang::ETK_Struct: | 985 | case clang::ETK_Struct: |
| 992 | case clang::ETK_Enum: | 986 | case clang::ETK_Enum: |
| 993 | case clang::ETK_Union: | 987 | case clang::ETK_Union: |
| 994 | return trans_qual_type(c, elaborated_ty->getNamedType(), source_loc); | 988 | return trans_qual_type(c, bitcast(elaborated_ty->getNamedType()), source_loc); |
| 995 | case clang::ETK_Interface: | 989 | case clang::ETK_Interface: |
| 996 | case clang::ETK_Class: | 990 | case clang::ETK_Class: |
| 997 | case clang::ETK_Typename: | 991 | case clang::ETK_Typename: |
| ... | @@ -1000,10 +994,10 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -1000,10 +994,10 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 1000 | return nullptr; | 994 | return nullptr; |
| 1001 | } | 995 | } |
| 1002 | } | 996 | } |
| 1003 | case clang::Type::FunctionProto: | 997 | case ZigClangType_FunctionProto: |
| 1004 | case clang::Type::FunctionNoProto: | 998 | case ZigClangType_FunctionNoProto: |
| 1005 | { | 999 | { |
| 1006 | const clang::FunctionType *fn_ty = static_cast<const clang::FunctionType*>(ty); | 1000 | const clang::FunctionType *fn_ty = reinterpret_cast<const clang::FunctionType*>(ty); |
| 1007 | | 1001 | |
| 1008 | AstNode *proto_node = trans_create_node(c, NodeTypeFnProto); | 1002 | AstNode *proto_node = trans_create_node(c, NodeTypeFnProto); |
| 1009 | switch (fn_ty->getCallConv()) { | 1003 | switch (fn_ty->getCallConv()) { |
| ... | @@ -1067,14 +1061,14 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -1067,14 +1061,14 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 1067 | if (fn_ty->getNoReturnAttr()) { | 1061 | if (fn_ty->getNoReturnAttr()) { |
| 1068 | proto_node->data.fn_proto.return_type = trans_create_node_symbol_str(c, "noreturn"); | 1062 | proto_node->data.fn_proto.return_type = trans_create_node_symbol_str(c, "noreturn"); |
| 1069 | } else { | 1063 | } else { |
| 1070 | proto_node->data.fn_proto.return_type = trans_qual_type(c, fn_ty->getReturnType(), | 1064 | proto_node->data.fn_proto.return_type = trans_qual_type(c, bitcast(fn_ty->getReturnType()), |
| 1071 | source_loc); | 1065 | source_loc); |
| 1072 | if (proto_node->data.fn_proto.return_type == nullptr) { | 1066 | if (proto_node->data.fn_proto.return_type == nullptr) { |
| 1073 | emit_warning(c, source_loc, "unsupported function proto return type"); | 1067 | emit_warning(c, source_loc, "unsupported function proto return type"); |
| 1074 | return nullptr; | 1068 | return nullptr; |
| 1075 | } | 1069 | } |
| 1076 | // convert c_void to actual void (only for return type) | 1070 | // convert c_void to actual void (only for return type) |
| 1077 | // we do want to look at the AstNode instead of clang::QualType, because | 1071 | // we do want to look at the AstNode instead of ZigClangQualType, because |
| 1078 | // if they do something like: | 1072 | // if they do something like: |
| 1079 | // typedef Foo void; | 1073 | // typedef Foo void; |
| 1080 | // void foo(void) -> Foo; | 1074 | // void foo(void) -> Foo; |
| ... | @@ -1090,17 +1084,17 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -1090,17 +1084,17 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 1090 | proto_node->data.fn_proto.name = buf_create_from_str(fn_name); | 1084 | proto_node->data.fn_proto.name = buf_create_from_str(fn_name); |
| 1091 | } | 1085 | } |
| 1092 | | 1086 | |
| 1093 | if (ty->getTypeClass() == clang::Type::FunctionNoProto) { | 1087 | if (ZigClangType_getTypeClass(ty) == ZigClangType_FunctionNoProto) { |
| 1094 | return proto_node; | 1088 | return proto_node; |
| 1095 | } | 1089 | } |
| 1096 | | 1090 | |
| 1097 | const clang::FunctionProtoType *fn_proto_ty = static_cast<const clang::FunctionProtoType*>(ty); | 1091 | const clang::FunctionProtoType *fn_proto_ty = reinterpret_cast<const clang::FunctionProtoType*>(ty); |
| 1098 | | 1092 | |
| 1099 | proto_node->data.fn_proto.is_var_args = fn_proto_ty->isVariadic(); | 1093 | proto_node->data.fn_proto.is_var_args = fn_proto_ty->isVariadic(); |
| 1100 | size_t param_count = fn_proto_ty->getNumParams(); | 1094 | size_t param_count = fn_proto_ty->getNumParams(); |
| 1101 | | 1095 | |
| 1102 | for (size_t i = 0; i < param_count; i += 1) { | 1096 | for (size_t i = 0; i < param_count; i += 1) { |
| 1103 | clang::QualType qt = fn_proto_ty->getParamType(i); | 1097 | ZigClangQualType qt = bitcast(fn_proto_ty->getParamType(i)); |
| 1104 | AstNode *param_type_node = trans_qual_type(c, qt, source_loc); | 1098 | AstNode *param_type_node = trans_qual_type(c, qt, source_loc); |
| 1105 | | 1099 | |
| 1106 | if (param_type_node == nullptr) { | 1100 | if (param_type_node == nullptr) { |
| ... | @@ -1114,7 +1108,7 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -1114,7 +1108,7 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 1114 | if (param_name != nullptr) { | 1108 | if (param_name != nullptr) { |
| 1115 | param_node->data.param_decl.name = buf_create_from_str(param_name); | 1109 | param_node->data.param_decl.name = buf_create_from_str(param_name); |
| 1116 | } | 1110 | } |
| 1117 | param_node->data.param_decl.is_noalias = qt.isRestrictQualified(); | 1111 | param_node->data.param_decl.is_noalias = ZigClangQualType_isRestrictQualified(qt); |
| 1118 | param_node->data.param_decl.type = param_type_node; | 1112 | param_node->data.param_decl.type = param_type_node; |
| 1119 | proto_node->data.fn_proto.params.append(param_node); | 1113 | proto_node->data.fn_proto.params.append(param_node); |
| 1120 | } | 1114 | } |
| ... | @@ -1123,20 +1117,20 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -1123,20 +1117,20 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 1123 | | 1117 | |
| 1124 | return proto_node; | 1118 | return proto_node; |
| 1125 | } | 1119 | } |
| 1126 | case clang::Type::Record: | 1120 | case ZigClangType_Record: |
| 1127 | { | 1121 | { |
| 1128 | const ZigClangRecordType *record_ty = reinterpret_cast<const ZigClangRecordType*>(ty); | 1122 | const ZigClangRecordType *record_ty = reinterpret_cast<const ZigClangRecordType*>(ty); |
| 1129 | return resolve_record_decl(c, ZigClangRecordType_getDecl(record_ty)); | 1123 | return resolve_record_decl(c, ZigClangRecordType_getDecl(record_ty)); |
| 1130 | } | 1124 | } |
| 1131 | case clang::Type::Enum: | 1125 | case ZigClangType_Enum: |
| 1132 | { | 1126 | { |
| 1133 | const ZigClangEnumType *enum_ty = reinterpret_cast<const ZigClangEnumType*>(ty); | 1127 | const ZigClangEnumType *enum_ty = reinterpret_cast<const ZigClangEnumType*>(ty); |
| 1134 | return resolve_enum_decl(c, ZigClangEnumType_getDecl(enum_ty)); | 1128 | return resolve_enum_decl(c, ZigClangEnumType_getDecl(enum_ty)); |
| 1135 | } | 1129 | } |
| 1136 | case clang::Type::ConstantArray: | 1130 | case ZigClangType_ConstantArray: |
| 1137 | { | 1131 | { |
| 1138 | const clang::ConstantArrayType *const_arr_ty = static_cast<const clang::ConstantArrayType *>(ty); | 1132 | const clang::ConstantArrayType *const_arr_ty = reinterpret_cast<const clang::ConstantArrayType *>(ty); |
| 1139 | AstNode *child_type_node = trans_qual_type(c, const_arr_ty->getElementType(), source_loc); | 1133 | AstNode *child_type_node = trans_qual_type(c, bitcast(const_arr_ty->getElementType()), source_loc); |
| 1140 | if (child_type_node == nullptr) { | 1134 | if (child_type_node == nullptr) { |
| 1141 | emit_warning(c, source_loc, "unresolved array element type"); | 1135 | emit_warning(c, source_loc, "unresolved array element type"); |
| 1142 | return nullptr; | 1136 | return nullptr; |
| ... | @@ -1145,76 +1139,78 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca | ... | @@ -1145,76 +1139,78 @@ static AstNode *trans_type(Context *c, const clang::Type *ty, ZigClangSourceLoca |
| 1145 | AstNode *size_node = trans_create_node_unsigned(c, size); | 1139 | AstNode *size_node = trans_create_node_unsigned(c, size); |
| 1146 | return trans_create_node_array_type(c, size_node, child_type_node); | 1140 | return trans_create_node_array_type(c, size_node, child_type_node); |
| 1147 | } | 1141 | } |
| 1148 | case clang::Type::Paren: | 1142 | case ZigClangType_Paren: |
| 1149 | { | 1143 | { |
| 1150 | const clang::ParenType *paren_ty = static_cast<const clang::ParenType *>(ty); | 1144 | const clang::ParenType *paren_ty = reinterpret_cast<const clang::ParenType *>(ty); |
| 1151 | return trans_qual_type(c, paren_ty->getInnerType(), source_loc); | 1145 | return trans_qual_type(c, bitcast(paren_ty->getInnerType()), source_loc); |
| 1152 | } | 1146 | } |
| 1153 | case clang::Type::Decayed: | 1147 | case ZigClangType_Decayed: |
| 1154 | { | 1148 | { |
| 1155 | const clang::DecayedType *decayed_ty = static_cast<const clang::DecayedType *>(ty); | 1149 | const clang::DecayedType *decayed_ty = reinterpret_cast<const clang::DecayedType *>(ty); |
| 1156 | return trans_qual_type(c, decayed_ty->getDecayedType(), source_loc); | 1150 | return trans_qual_type(c, bitcast(decayed_ty->getDecayedType()), source_loc); |
| 1157 | } | 1151 | } |
| 1158 | case clang::Type::Attributed: | 1152 | case ZigClangType_Attributed: |
| 1159 | { | 1153 | { |
| 1160 | const clang::AttributedType *attributed_ty = static_cast<const clang::AttributedType *>(ty); | 1154 | const clang::AttributedType *attributed_ty = reinterpret_cast<const clang::AttributedType *>(ty); |
| 1161 | return trans_qual_type(c, attributed_ty->getEquivalentType(), source_loc); | 1155 | return trans_qual_type(c, bitcast(attributed_ty->getEquivalentType()), source_loc); |
| 1162 | } | 1156 | } |
| 1163 | case clang::Type::IncompleteArray: | 1157 | case ZigClangType_IncompleteArray: |
| 1164 | { | 1158 | { |
| 1165 | const clang::IncompleteArrayType *incomplete_array_ty = static_cast<const clang::IncompleteArrayType *>(ty); | 1159 | const clang::IncompleteArrayType *incomplete_array_ty = reinterpret_cast<const clang::IncompleteArrayType *>(ty); |
| 1166 | clang::QualType child_qt = incomplete_array_ty->getElementType(); | 1160 | ZigClangQualType child_qt = bitcast(incomplete_array_ty->getElementType()); |
| 1167 | AstNode *child_type_node = trans_qual_type(c, child_qt, source_loc); | 1161 | AstNode *child_type_node = trans_qual_type(c, child_qt, source_loc); |
| 1168 | if (child_type_node == nullptr) { | 1162 | if (child_type_node == nullptr) { |
| 1169 | emit_warning(c, source_loc, "unresolved array element type"); | 1163 | emit_warning(c, source_loc, "unresolved array element type"); |
| 1170 | return nullptr; | 1164 | return nullptr; |
| 1171 | } | 1165 | } |
| 1172 | AstNode *pointer_node = trans_create_node_ptr_type(c, child_qt.isConstQualified(), | 1166 | AstNode *pointer_node = trans_create_node_ptr_type(c, |
| 1173 | child_qt.isVolatileQualified(), child_type_node, PtrLenC); | 1167 | ZigClangQualType_isConstQualified(child_qt), |
| | 1168 | ZigClangQualType_isVolatileQualified(child_qt), |
| | 1169 | child_type_node, PtrLenC); |
| 1174 | return pointer_node; | 1170 | return pointer_node; |
| 1175 | } | 1171 | } |
| 1176 | case clang::Type::BlockPointer: | 1172 | case ZigClangType_BlockPointer: |
| 1177 | case clang::Type::LValueReference: | 1173 | case ZigClangType_LValueReference: |
| 1178 | case clang::Type::RValueReference: | 1174 | case ZigClangType_RValueReference: |
| 1179 | case clang::Type::MemberPointer: | 1175 | case ZigClangType_MemberPointer: |
| 1180 | case clang::Type::VariableArray: | 1176 | case ZigClangType_VariableArray: |
| 1181 | case clang::Type::DependentSizedArray: | 1177 | case ZigClangType_DependentSizedArray: |
| 1182 | case clang::Type::DependentSizedExtVector: | 1178 | case ZigClangType_DependentSizedExtVector: |
| 1183 | case clang::Type::Vector: | 1179 | case ZigClangType_Vector: |
| 1184 | case clang::Type::ExtVector: | 1180 | case ZigClangType_ExtVector: |
| 1185 | case clang::Type::UnresolvedUsing: | 1181 | case ZigClangType_UnresolvedUsing: |
| 1186 | case clang::Type::Adjusted: | 1182 | case ZigClangType_Adjusted: |
| 1187 | case clang::Type::TypeOfExpr: | 1183 | case ZigClangType_TypeOfExpr: |
| 1188 | case clang::Type::TypeOf: | 1184 | case ZigClangType_TypeOf: |
| 1189 | case clang::Type::Decltype: | 1185 | case ZigClangType_Decltype: |
| 1190 | case clang::Type::UnaryTransform: | 1186 | case ZigClangType_UnaryTransform: |
| 1191 | case clang::Type::TemplateTypeParm: | 1187 | case ZigClangType_TemplateTypeParm: |
| 1192 | case clang::Type::SubstTemplateTypeParm: | 1188 | case ZigClangType_SubstTemplateTypeParm: |
| 1193 | case clang::Type::SubstTemplateTypeParmPack: | 1189 | case ZigClangType_SubstTemplateTypeParmPack: |
| 1194 | case clang::Type::TemplateSpecialization: | 1190 | case ZigClangType_TemplateSpecialization: |
| 1195 | case clang::Type::Auto: | 1191 | case ZigClangType_Auto: |
| 1196 | case clang::Type::InjectedClassName: | 1192 | case ZigClangType_InjectedClassName: |
| 1197 | case clang::Type::DependentName: | 1193 | case ZigClangType_DependentName: |
| 1198 | case clang::Type::DependentTemplateSpecialization: | 1194 | case ZigClangType_DependentTemplateSpecialization: |
| 1199 | case clang::Type::PackExpansion: | 1195 | case ZigClangType_PackExpansion: |
| 1200 | case clang::Type::ObjCObject: | 1196 | case ZigClangType_ObjCObject: |
| 1201 | case clang::Type::ObjCInterface: | 1197 | case ZigClangType_ObjCInterface: |
| 1202 | case clang::Type::Complex: | 1198 | case ZigClangType_Complex: |
| 1203 | case clang::Type::ObjCObjectPointer: | 1199 | case ZigClangType_ObjCObjectPointer: |
| 1204 | case clang::Type::Atomic: | 1200 | case ZigClangType_Atomic: |
| 1205 | case clang::Type::Pipe: | 1201 | case ZigClangType_Pipe: |
| 1206 | case clang::Type::ObjCTypeParam: | 1202 | case ZigClangType_ObjCTypeParam: |
| 1207 | case clang::Type::DeducedTemplateSpecialization: | 1203 | case ZigClangType_DeducedTemplateSpecialization: |
| 1208 | case clang::Type::DependentAddressSpace: | 1204 | case ZigClangType_DependentAddressSpace: |
| 1209 | case clang::Type::DependentVector: | 1205 | case ZigClangType_DependentVector: |
| 1210 | emit_warning(c, source_loc, "unsupported type: '%s'", ty->getTypeClassName()); | 1206 | emit_warning(c, source_loc, "unsupported type: '%s'", ZigClangType_getTypeClassName(ty)); |
| 1211 | return nullptr; | 1207 | return nullptr; |
| 1212 | } | 1208 | } |
| 1213 | zig_unreachable(); | 1209 | zig_unreachable(); |
| 1214 | } | 1210 | } |
| 1215 | | 1211 | |
| 1216 | static AstNode *trans_qual_type(Context *c, clang::QualType qt, ZigClangSourceLocation source_loc) { | 1212 | static AstNode *trans_qual_type(Context *c, ZigClangQualType qt, ZigClangSourceLocation source_loc) { |
| 1217 | return trans_type(c, qt.getTypePtr(), source_loc); | 1213 | return trans_type(c, ZigClangQualType_getTypePtr(qt), source_loc); |
| 1218 | } | 1214 | } |
| 1219 | | 1215 | |
| 1220 | static int trans_compound_stmt_inline(Context *c, TransScope *scope, const clang::CompoundStmt *stmt, | 1216 | static int trans_compound_stmt_inline(Context *c, TransScope *scope, const clang::CompoundStmt *stmt, |
| ... | @@ -1300,7 +1296,7 @@ static AstNode *trans_constant_expr(Context *c, ResultUsed result_used, const cl | ... | @@ -1300,7 +1296,7 @@ static AstNode *trans_constant_expr(Context *c, ResultUsed result_used, const cl |
| 1300 | emit_warning(c, bitcast(expr->getBeginLoc()), "invalid constant expression"); | 1296 | emit_warning(c, bitcast(expr->getBeginLoc()), "invalid constant expression"); |
| 1301 | return nullptr; | 1297 | return nullptr; |
| 1302 | } | 1298 | } |
| 1303 | AstNode *node = trans_ap_value(c, &result.Val, expr->getType(), bitcast(expr->getBeginLoc())); | 1299 | AstNode *node = trans_ap_value(c, &result.Val, bitcast(expr->getType()), bitcast(expr->getBeginLoc())); |
| 1304 | return maybe_suppress_result(c, result_used, node); | 1300 | return maybe_suppress_result(c, result_used, node); |
| 1305 | } | 1301 | } |
| 1306 | | 1302 | |
| ... | @@ -1410,7 +1406,7 @@ static AstNode *trans_create_assign(Context *c, ResultUsed result_used, TransSco | ... | @@ -1410,7 +1406,7 @@ static AstNode *trans_create_assign(Context *c, ResultUsed result_used, TransSco |
| 1410 | } | 1406 | } |
| 1411 | } | 1407 | } |
| 1412 | | 1408 | |
| 1413 | static AstNode *trans_create_shift_op(Context *c, TransScope *scope, clang::QualType result_type, | 1409 | static AstNode *trans_create_shift_op(Context *c, TransScope *scope, ZigClangQualType result_type, |
| 1414 | clang::Expr *lhs_expr, BinOpType bin_op, clang::Expr *rhs_expr) | 1410 | clang::Expr *lhs_expr, BinOpType bin_op, clang::Expr *rhs_expr) |
| 1415 | { | 1411 | { |
| 1416 | ZigClangSourceLocation rhs_location = bitcast(rhs_expr->getBeginLoc()); | 1412 | ZigClangSourceLocation rhs_location = bitcast(rhs_expr->getBeginLoc()); |
| ... | @@ -1440,12 +1436,12 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS | ... | @@ -1440,12 +1436,12 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS |
| 1440 | return nullptr; | 1436 | return nullptr; |
| 1441 | case clang::BO_Mul: { | 1437 | case clang::BO_Mul: { |
| 1442 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), | 1438 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), |
| 1443 | qual_type_has_wrapping_overflow(c, stmt->getType()) ? BinOpTypeMultWrap : BinOpTypeMult, | 1439 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeMultWrap : BinOpTypeMult, |
| 1444 | stmt->getRHS()); | 1440 | stmt->getRHS()); |
| 1445 | return maybe_suppress_result(c, result_used, node); | 1441 | return maybe_suppress_result(c, result_used, node); |
| 1446 | } | 1442 | } |
| 1447 | case clang::BO_Div: | 1443 | case clang::BO_Div: |
| 1448 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) { | 1444 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) { |
| 1449 | // unsigned/float division uses the operator | 1445 | // unsigned/float division uses the operator |
| 1450 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeDiv, stmt->getRHS()); | 1446 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeDiv, stmt->getRHS()); |
| 1451 | return maybe_suppress_result(c, result_used, node); | 1447 | return maybe_suppress_result(c, result_used, node); |
| ... | @@ -1461,7 +1457,7 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS | ... | @@ -1461,7 +1457,7 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS |
| 1461 | return maybe_suppress_result(c, result_used, fn_call); | 1457 | return maybe_suppress_result(c, result_used, fn_call); |
| 1462 | } | 1458 | } |
| 1463 | case clang::BO_Rem: | 1459 | case clang::BO_Rem: |
| 1464 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) { | 1460 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) { |
| 1465 | // unsigned/float division uses the operator | 1461 | // unsigned/float division uses the operator |
| 1466 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeMod, stmt->getRHS()); | 1462 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeMod, stmt->getRHS()); |
| 1467 | return maybe_suppress_result(c, result_used, node); | 1463 | return maybe_suppress_result(c, result_used, node); |
| ... | @@ -1478,22 +1474,22 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS | ... | @@ -1478,22 +1474,22 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS |
| 1478 | } | 1474 | } |
| 1479 | case clang::BO_Add: { | 1475 | case clang::BO_Add: { |
| 1480 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), | 1476 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), |
| 1481 | qual_type_has_wrapping_overflow(c, stmt->getType()) ? BinOpTypeAddWrap : BinOpTypeAdd, | 1477 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeAddWrap : BinOpTypeAdd, |
| 1482 | stmt->getRHS()); | 1478 | stmt->getRHS()); |
| 1483 | return maybe_suppress_result(c, result_used, node); | 1479 | return maybe_suppress_result(c, result_used, node); |
| 1484 | } | 1480 | } |
| 1485 | case clang::BO_Sub: { | 1481 | case clang::BO_Sub: { |
| 1486 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), | 1482 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), |
| 1487 | qual_type_has_wrapping_overflow(c, stmt->getType()) ? BinOpTypeSubWrap : BinOpTypeSub, | 1483 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeSubWrap : BinOpTypeSub, |
| 1488 | stmt->getRHS()); | 1484 | stmt->getRHS()); |
| 1489 | return maybe_suppress_result(c, result_used, node); | 1485 | return maybe_suppress_result(c, result_used, node); |
| 1490 | } | 1486 | } |
| 1491 | case clang::BO_Shl: { | 1487 | case clang::BO_Shl: { |
| 1492 | AstNode *node = trans_create_shift_op(c, scope, stmt->getType(), stmt->getLHS(), BinOpTypeBitShiftLeft, stmt->getRHS()); | 1488 | AstNode *node = trans_create_shift_op(c, scope, bitcast(stmt->getType()), stmt->getLHS(), BinOpTypeBitShiftLeft, stmt->getRHS()); |
| 1493 | return maybe_suppress_result(c, result_used, node); | 1489 | return maybe_suppress_result(c, result_used, node); |
| 1494 | } | 1490 | } |
| 1495 | case clang::BO_Shr: { | 1491 | case clang::BO_Shr: { |
| 1496 | AstNode *node = trans_create_shift_op(c, scope, stmt->getType(), stmt->getLHS(), BinOpTypeBitShiftRight, stmt->getRHS()); | 1492 | AstNode *node = trans_create_shift_op(c, scope, bitcast(stmt->getType()), stmt->getLHS(), BinOpTypeBitShiftRight, stmt->getRHS()); |
| 1497 | return maybe_suppress_result(c, result_used, node); | 1493 | return maybe_suppress_result(c, result_used, node); |
| 1498 | } | 1494 | } |
| 1499 | case clang::BO_LT: { | 1495 | case clang::BO_LT: { |
| ... | @@ -1581,7 +1577,7 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result | ... | @@ -1581,7 +1577,7 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result |
| 1581 | const clang::CompoundAssignOperator *stmt, BinOpType assign_op, BinOpType bin_op) | 1577 | const clang::CompoundAssignOperator *stmt, BinOpType assign_op, BinOpType bin_op) |
| 1582 | { | 1578 | { |
| 1583 | ZigClangSourceLocation rhs_location = bitcast(stmt->getRHS()->getBeginLoc()); | 1579 | ZigClangSourceLocation rhs_location = bitcast(stmt->getRHS()->getBeginLoc()); |
| 1584 | AstNode *rhs_type = qual_type_to_log2_int_ref(c, stmt->getComputationLHSType(), rhs_location); | 1580 | AstNode *rhs_type = qual_type_to_log2_int_ref(c, bitcast(stmt->getComputationLHSType()), rhs_location); |
| 1585 | | 1581 | |
| 1586 | bool use_intermediate_casts = stmt->getComputationLHSType().getTypePtr() != stmt->getComputationResultType().getTypePtr(); | 1582 | bool use_intermediate_casts = stmt->getComputationLHSType().getTypePtr() != stmt->getComputationResultType().getTypePtr(); |
| 1587 | if (!use_intermediate_casts && result_used == ResultUsedNo) { | 1583 | if (!use_intermediate_casts && result_used == ResultUsedNo) { |
| ... | @@ -1626,14 +1622,14 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result | ... | @@ -1626,14 +1622,14 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result |
| 1626 | | 1622 | |
| 1627 | // operation_type(*_ref) | 1623 | // operation_type(*_ref) |
| 1628 | AstNode *operation_type_cast = trans_c_cast(c, rhs_location, | 1624 | AstNode *operation_type_cast = trans_c_cast(c, rhs_location, |
| 1629 | stmt->getComputationLHSType(), | 1625 | bitcast(stmt->getComputationLHSType()), |
| 1630 | stmt->getLHS()->getType(), | 1626 | bitcast(stmt->getLHS()->getType()), |
| 1631 | trans_create_node_ptr_deref(c, trans_create_node_symbol(c, tmp_var_name))); | 1627 | trans_create_node_ptr_deref(c, trans_create_node_symbol(c, tmp_var_name))); |
| 1632 | | 1628 | |
| 1633 | // result_type(... >> u5(rhs)) | 1629 | // result_type(... >> u5(rhs)) |
| 1634 | AstNode *result_type_cast = trans_c_cast(c, rhs_location, | 1630 | AstNode *result_type_cast = trans_c_cast(c, rhs_location, |
| 1635 | stmt->getComputationResultType(), | 1631 | bitcast(stmt->getComputationResultType()), |
| 1636 | stmt->getComputationLHSType(), | 1632 | bitcast(stmt->getComputationLHSType()), |
| 1637 | trans_create_node_bin_op(c, | 1633 | trans_create_node_bin_op(c, |
| 1638 | operation_type_cast, | 1634 | operation_type_cast, |
| 1639 | bin_op, | 1635 | bin_op, |
| ... | @@ -1724,7 +1720,7 @@ static AstNode *trans_compound_assign_operator(Context *c, ResultUsed result_use | ... | @@ -1724,7 +1720,7 @@ static AstNode *trans_compound_assign_operator(Context *c, ResultUsed result_use |
| 1724 | { | 1720 | { |
| 1725 | switch (stmt->getOpcode()) { | 1721 | switch (stmt->getOpcode()) { |
| 1726 | case clang::BO_MulAssign: | 1722 | case clang::BO_MulAssign: |
| 1727 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) | 1723 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) |
| 1728 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignTimesWrap, BinOpTypeMultWrap); | 1724 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignTimesWrap, BinOpTypeMultWrap); |
| 1729 | else | 1725 | else |
| 1730 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignTimes, BinOpTypeMult); | 1726 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignTimes, BinOpTypeMult); |
| ... | @@ -1738,12 +1734,12 @@ static AstNode *trans_compound_assign_operator(Context *c, ResultUsed result_use | ... | @@ -1738,12 +1734,12 @@ static AstNode *trans_compound_assign_operator(Context *c, ResultUsed result_use |
| 1738 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C compound assign operators: BO_Cmp"); | 1734 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C compound assign operators: BO_Cmp"); |
| 1739 | return nullptr; | 1735 | return nullptr; |
| 1740 | case clang::BO_AddAssign: | 1736 | case clang::BO_AddAssign: |
| 1741 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) | 1737 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) |
| 1742 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap, BinOpTypeAddWrap); | 1738 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap, BinOpTypeAddWrap); |
| 1743 | else | 1739 | else |
| 1744 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignPlus, BinOpTypeAdd); | 1740 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignPlus, BinOpTypeAdd); |
| 1745 | case clang::BO_SubAssign: | 1741 | case clang::BO_SubAssign: |
| 1746 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) | 1742 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) |
| 1747 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap, BinOpTypeSubWrap); | 1743 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap, BinOpTypeSubWrap); |
| 1748 | else | 1744 | else |
| 1749 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignMinus, BinOpTypeSub); | 1745 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignMinus, BinOpTypeSub); |
| ... | @@ -1794,8 +1790,8 @@ static AstNode *trans_implicit_cast_expr(Context *c, ResultUsed result_used, Tra | ... | @@ -1794,8 +1790,8 @@ static AstNode *trans_implicit_cast_expr(Context *c, ResultUsed result_used, Tra |
| 1794 | AstNode *target_node = trans_expr(c, ResultUsedYes, scope, stmt->getSubExpr(), TransRValue); | 1790 | AstNode *target_node = trans_expr(c, ResultUsedYes, scope, stmt->getSubExpr(), TransRValue); |
| 1795 | if (target_node == nullptr) | 1791 | if (target_node == nullptr) |
| 1796 | return nullptr; | 1792 | return nullptr; |
| 1797 | AstNode *node = trans_c_cast(c, bitcast(stmt->getExprLoc()), stmt->getType(), | 1793 | AstNode *node = trans_c_cast(c, bitcast(stmt->getExprLoc()), bitcast(stmt->getType()), |
| 1798 | stmt->getSubExpr()->getType(), target_node); | 1794 | bitcast(stmt->getSubExpr()->getType()), target_node); |
| 1799 | return maybe_suppress_result(c, result_used, node); | 1795 | return maybe_suppress_result(c, result_used, node); |
| 1800 | } | 1796 | } |
| 1801 | case clang::CK_FunctionToPointerDecay: | 1797 | case clang::CK_FunctionToPointerDecay: |
| ... | @@ -2106,22 +2102,22 @@ static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, Tra | ... | @@ -2106,22 +2102,22 @@ static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, Tra |
| 2106 | static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransScope *scope, const clang::UnaryOperator *stmt) { | 2102 | static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransScope *scope, const clang::UnaryOperator *stmt) { |
| 2107 | switch (stmt->getOpcode()) { | 2103 | switch (stmt->getOpcode()) { |
| 2108 | case clang::UO_PostInc: | 2104 | case clang::UO_PostInc: |
| 2109 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) | 2105 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) |
| 2110 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap); | 2106 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap); |
| 2111 | else | 2107 | else |
| 2112 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignPlus); | 2108 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignPlus); |
| 2113 | case clang::UO_PostDec: | 2109 | case clang::UO_PostDec: |
| 2114 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) | 2110 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) |
| 2115 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap); | 2111 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap); |
| 2116 | else | 2112 | else |
| 2117 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); | 2113 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); |
| 2118 | case clang::UO_PreInc: | 2114 | case clang::UO_PreInc: |
| 2119 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) | 2115 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) |
| 2120 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap); | 2116 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap); |
| 2121 | else | 2117 | else |
| 2122 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignPlus); | 2118 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignPlus); |
| 2123 | case clang::UO_PreDec: | 2119 | case clang::UO_PreDec: |
| 2124 | if (qual_type_has_wrapping_overflow(c, stmt->getType())) | 2120 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) |
| 2125 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap); | 2121 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap); |
| 2126 | else | 2122 | else |
| 2127 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); | 2123 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); |
| ... | @@ -2137,7 +2133,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2137,7 +2133,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2137 | AstNode *value_node = trans_expr(c, result_used, scope, stmt->getSubExpr(), TransRValue); | 2133 | AstNode *value_node = trans_expr(c, result_used, scope, stmt->getSubExpr(), TransRValue); |
| 2138 | if (value_node == nullptr) | 2134 | if (value_node == nullptr) |
| 2139 | return nullptr; | 2135 | return nullptr; |
| 2140 | bool is_fn_ptr = qual_type_is_fn_ptr(stmt->getSubExpr()->getType()); | 2136 | bool is_fn_ptr = qual_type_is_fn_ptr(bitcast(stmt->getSubExpr()->getType())); |
| 2141 | if (is_fn_ptr) | 2137 | if (is_fn_ptr) |
| 2142 | return value_node; | 2138 | return value_node; |
| 2143 | AstNode *unwrapped = trans_create_node_unwrap_null(c, value_node); | 2139 | AstNode *unwrapped = trans_create_node_unwrap_null(c, value_node); |
| ... | @@ -2149,7 +2145,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2149,7 +2145,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2149 | case clang::UO_Minus: | 2145 | case clang::UO_Minus: |
| 2150 | { | 2146 | { |
| 2151 | clang::Expr *op_expr = stmt->getSubExpr(); | 2147 | clang::Expr *op_expr = stmt->getSubExpr(); |
| 2152 | if (!qual_type_has_wrapping_overflow(c, op_expr->getType())) { | 2148 | if (!qual_type_has_wrapping_overflow(c, bitcast(op_expr->getType()))) { |
| 2153 | AstNode *node = trans_create_node(c, NodeTypePrefixOpExpr); | 2149 | AstNode *node = trans_create_node(c, NodeTypePrefixOpExpr); |
| 2154 | node->data.prefix_op_expr.prefix_op = PrefixOpNegation; | 2150 | node->data.prefix_op_expr.prefix_op = PrefixOpNegation; |
| 2155 | | 2151 | |
| ... | @@ -2158,7 +2154,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2158,7 +2154,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2158 | return nullptr; | 2154 | return nullptr; |
| 2159 | | 2155 | |
| 2160 | return node; | 2156 | return node; |
| 2161 | } else if (c_is_unsigned_integer(c, op_expr->getType())) { | 2157 | } else if (c_is_unsigned_integer(c, bitcast(op_expr->getType()))) { |
| 2162 | // we gotta emit 0 -% x | 2158 | // we gotta emit 0 -% x |
| 2163 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); | 2159 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); |
| 2164 | node->data.bin_op_expr.op1 = trans_create_node_unsigned(c, 0); | 2160 | node->data.bin_op_expr.op1 = trans_create_node_unsigned(c, 0); |
| ... | @@ -2221,7 +2217,7 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D | ... | @@ -2221,7 +2217,7 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D |
| 2221 | switch (decl->getKind()) { | 2217 | switch (decl->getKind()) { |
| 2222 | case clang::Decl::Var: { | 2218 | case clang::Decl::Var: { |
| 2223 | clang::VarDecl *var_decl = (clang::VarDecl *)decl; | 2219 | clang::VarDecl *var_decl = (clang::VarDecl *)decl; |
| 2224 | clang::QualType qual_type = var_decl->getTypeSourceInfo()->getType(); | 2220 | ZigClangQualType qual_type = bitcast(var_decl->getTypeSourceInfo()->getType()); |
| 2225 | AstNode *init_node = nullptr; | 2221 | AstNode *init_node = nullptr; |
| 2226 | if (var_decl->hasInit()) { | 2222 | if (var_decl->hasInit()) { |
| 2227 | init_node = trans_expr(c, ResultUsedYes, scope, var_decl->getInit(), TransRValue); | 2223 | init_node = trans_expr(c, ResultUsedYes, scope, var_decl->getInit(), TransRValue); |
| ... | @@ -2240,7 +2236,8 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D | ... | @@ -2240,7 +2236,8 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D |
| 2240 | TransScopeVar *var_scope = trans_scope_var_create(c, scope, c_symbol_name); | 2236 | TransScopeVar *var_scope = trans_scope_var_create(c, scope, c_symbol_name); |
| 2241 | scope = &var_scope->base; | 2237 | scope = &var_scope->base; |
| 2242 | | 2238 | |
| 2243 | AstNode *node = trans_create_node_var_decl_local(c, qual_type.isConstQualified(), | 2239 | AstNode *node = trans_create_node_var_decl_local(c, |
| | 2240 | ZigClangQualType_isConstQualified(qual_type), |
| 2244 | var_scope->zig_name, type_node, init_node); | 2241 | var_scope->zig_name, type_node, init_node); |
| 2245 | | 2242 | |
| 2246 | scope_block->node->data.block.statements.append(node); | 2243 | scope_block->node->data.block.statements.append(node); |
| ... | @@ -2526,12 +2523,12 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2526,12 +2523,12 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2526 | } | 2523 | } |
| 2527 | | 2524 | |
| 2528 | | 2525 | |
| 2529 | const clang::Type *ty = get_expr_qual_type_before_implicit_cast(c, expr).getTypePtr(); | 2526 | const ZigClangType *ty = ZigClangQualType_getTypePtr(get_expr_qual_type_before_implicit_cast(c, expr)); |
| 2530 | auto classs = ty->getTypeClass(); | 2527 | auto classs = ZigClangType_getTypeClass(ty); |
| 2531 | switch (classs) { | 2528 | switch (classs) { |
| 2532 | case clang::Type::Builtin: | 2529 | case ZigClangType_Builtin: |
| 2533 | { | 2530 | { |
| 2534 | const clang::BuiltinType *builtin_ty = static_cast<const clang::BuiltinType*>(ty); | 2531 | const clang::BuiltinType *builtin_ty = reinterpret_cast<const clang::BuiltinType*>(ty); |
| 2535 | switch (builtin_ty->getKind()) { | 2532 | switch (builtin_ty->getKind()) { |
| 2536 | case clang::BuiltinType::Bool: | 2533 | case clang::BuiltinType::Bool: |
| 2537 | case clang::BuiltinType::Char_U: | 2534 | case clang::BuiltinType::Char_U: |
| ... | @@ -2657,11 +2654,11 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2657,11 +2654,11 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2657 | } | 2654 | } |
| 2658 | break; | 2655 | break; |
| 2659 | } | 2656 | } |
| 2660 | case clang::Type::Pointer: | 2657 | case ZigClangType_Pointer: |
| 2661 | return trans_create_node_bin_op(c, res, BinOpTypeCmpNotEq, | 2658 | return trans_create_node_bin_op(c, res, BinOpTypeCmpNotEq, |
| 2662 | trans_create_node_unsigned(c, 0)); | 2659 | trans_create_node_unsigned(c, 0)); |
| 2663 | | 2660 | |
| 2664 | case clang::Type::Typedef: | 2661 | case ZigClangType_Typedef: |
| 2665 | { | 2662 | { |
| 2666 | const ZigClangTypedefType *typedef_ty = reinterpret_cast<const ZigClangTypedefType*>(ty); | 2663 | const ZigClangTypedefType *typedef_ty = reinterpret_cast<const ZigClangTypedefType*>(ty); |
| 2667 | const ZigClangTypedefNameDecl *typedef_decl = ZigClangTypedefType_getDecl(typedef_ty); | 2664 | const ZigClangTypedefNameDecl *typedef_decl = ZigClangTypedefType_getDecl(typedef_ty); |
| ... | @@ -2673,19 +2670,20 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2673,19 +2670,20 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2673 | return res; | 2670 | return res; |
| 2674 | } | 2671 | } |
| 2675 | | 2672 | |
| 2676 | case clang::Type::Enum: | 2673 | case ZigClangType_Enum: |
| 2677 | { | 2674 | { |
| 2678 | const ZigClangEnumType *enum_ty = reinterpret_cast<const ZigClangEnumType *>(ty); | 2675 | const ZigClangEnumType *enum_ty = reinterpret_cast<const ZigClangEnumType *>(ty); |
| 2679 | AstNode *enum_type = resolve_enum_decl(c, ZigClangEnumType_getDecl(enum_ty)); | 2676 | AstNode *enum_type = resolve_enum_decl(c, ZigClangEnumType_getDecl(enum_ty)); |
| 2680 | return to_enum_zero_cmp(c, res, enum_type); | 2677 | return to_enum_zero_cmp(c, res, enum_type); |
| 2681 | } | 2678 | } |
| 2682 | | 2679 | |
| 2683 | case clang::Type::Elaborated: | 2680 | case ZigClangType_Elaborated: |
| 2684 | { | 2681 | { |
| 2685 | const clang::ElaboratedType *elaborated_ty = static_cast<const clang::ElaboratedType*>(ty); | 2682 | const clang::ElaboratedType *elaborated_ty = reinterpret_cast<const clang::ElaboratedType*>(ty); |
| 2686 | switch (elaborated_ty->getKeyword()) { | 2683 | switch (elaborated_ty->getKeyword()) { |
| 2687 | case clang::ETK_Enum: { | 2684 | case clang::ETK_Enum: { |
| 2688 | AstNode *enum_type = trans_qual_type(c, elaborated_ty->getNamedType(), bitcast(expr->getBeginLoc())); | 2685 | AstNode *enum_type = trans_qual_type(c, bitcast(elaborated_ty->getNamedType()), |
| | 2686 | bitcast(expr->getBeginLoc())); |
| 2689 | return to_enum_zero_cmp(c, res, enum_type); | 2687 | return to_enum_zero_cmp(c, res, enum_type); |
| 2690 | } | 2688 | } |
| 2691 | case clang::ETK_Struct: | 2689 | case clang::ETK_Struct: |
| ... | @@ -2698,48 +2696,48 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2698,48 +2696,48 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2698 | } | 2696 | } |
| 2699 | } | 2697 | } |
| 2700 | | 2698 | |
| 2701 | case clang::Type::FunctionProto: | 2699 | case ZigClangType_FunctionProto: |
| 2702 | case clang::Type::Record: | 2700 | case ZigClangType_Record: |
| 2703 | case clang::Type::ConstantArray: | 2701 | case ZigClangType_ConstantArray: |
| 2704 | case clang::Type::Paren: | 2702 | case ZigClangType_Paren: |
| 2705 | case clang::Type::Decayed: | 2703 | case ZigClangType_Decayed: |
| 2706 | case clang::Type::Attributed: | 2704 | case ZigClangType_Attributed: |
| 2707 | case clang::Type::IncompleteArray: | 2705 | case ZigClangType_IncompleteArray: |
| 2708 | case clang::Type::BlockPointer: | 2706 | case ZigClangType_BlockPointer: |
| 2709 | case clang::Type::LValueReference: | 2707 | case ZigClangType_LValueReference: |
| 2710 | case clang::Type::RValueReference: | 2708 | case ZigClangType_RValueReference: |
| 2711 | case clang::Type::MemberPointer: | 2709 | case ZigClangType_MemberPointer: |
| 2712 | case clang::Type::VariableArray: | 2710 | case ZigClangType_VariableArray: |
| 2713 | case clang::Type::DependentSizedArray: | 2711 | case ZigClangType_DependentSizedArray: |
| 2714 | case clang::Type::DependentSizedExtVector: | 2712 | case ZigClangType_DependentSizedExtVector: |
| 2715 | case clang::Type::Vector: | 2713 | case ZigClangType_Vector: |
| 2716 | case clang::Type::ExtVector: | 2714 | case ZigClangType_ExtVector: |
| 2717 | case clang::Type::FunctionNoProto: | 2715 | case ZigClangType_FunctionNoProto: |
| 2718 | case clang::Type::UnresolvedUsing: | 2716 | case ZigClangType_UnresolvedUsing: |
| 2719 | case clang::Type::Adjusted: | 2717 | case ZigClangType_Adjusted: |
| 2720 | case clang::Type::TypeOfExpr: | 2718 | case ZigClangType_TypeOfExpr: |
| 2721 | case clang::Type::TypeOf: | 2719 | case ZigClangType_TypeOf: |
| 2722 | case clang::Type::Decltype: | 2720 | case ZigClangType_Decltype: |
| 2723 | case clang::Type::UnaryTransform: | 2721 | case ZigClangType_UnaryTransform: |
| 2724 | case clang::Type::TemplateTypeParm: | 2722 | case ZigClangType_TemplateTypeParm: |
| 2725 | case clang::Type::SubstTemplateTypeParm: | 2723 | case ZigClangType_SubstTemplateTypeParm: |
| 2726 | case clang::Type::SubstTemplateTypeParmPack: | 2724 | case ZigClangType_SubstTemplateTypeParmPack: |
| 2727 | case clang::Type::TemplateSpecialization: | 2725 | case ZigClangType_TemplateSpecialization: |
| 2728 | case clang::Type::Auto: | 2726 | case ZigClangType_Auto: |
| 2729 | case clang::Type::InjectedClassName: | 2727 | case ZigClangType_InjectedClassName: |
| 2730 | case clang::Type::DependentName: | 2728 | case ZigClangType_DependentName: |
| 2731 | case clang::Type::DependentTemplateSpecialization: | 2729 | case ZigClangType_DependentTemplateSpecialization: |
| 2732 | case clang::Type::PackExpansion: | 2730 | case ZigClangType_PackExpansion: |
| 2733 | case clang::Type::ObjCObject: | 2731 | case ZigClangType_ObjCObject: |
| 2734 | case clang::Type::ObjCInterface: | 2732 | case ZigClangType_ObjCInterface: |
| 2735 | case clang::Type::Complex: | 2733 | case ZigClangType_Complex: |
| 2736 | case clang::Type::ObjCObjectPointer: | 2734 | case ZigClangType_ObjCObjectPointer: |
| 2737 | case clang::Type::Atomic: | 2735 | case ZigClangType_Atomic: |
| 2738 | case clang::Type::Pipe: | 2736 | case ZigClangType_Pipe: |
| 2739 | case clang::Type::ObjCTypeParam: | 2737 | case ZigClangType_ObjCTypeParam: |
| 2740 | case clang::Type::DeducedTemplateSpecialization: | 2738 | case ZigClangType_DeducedTemplateSpecialization: |
| 2741 | case clang::Type::DependentAddressSpace: | 2739 | case ZigClangType_DependentAddressSpace: |
| 2742 | case clang::Type::DependentVector: | 2740 | case ZigClangType_DependentVector: |
| 2743 | return res; | 2741 | return res; |
| 2744 | } | 2742 | } |
| 2745 | zig_unreachable(); | 2743 | zig_unreachable(); |
| ... | @@ -2790,7 +2788,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2790,7 +2788,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * |
| 2790 | return nullptr; | 2788 | return nullptr; |
| 2791 | | 2789 | |
| 2792 | bool is_ptr = false; | 2790 | bool is_ptr = false; |
| 2793 | const clang::FunctionProtoType *fn_ty = qual_type_get_fn_proto(stmt->getCallee()->getType(), &is_ptr); | 2791 | const clang::FunctionProtoType *fn_ty = qual_type_get_fn_proto(bitcast(stmt->getCallee()->getType()), &is_ptr); |
| 2794 | AstNode *callee_node = nullptr; | 2792 | AstNode *callee_node = nullptr; |
| 2795 | if (is_ptr && fn_ty) { | 2793 | if (is_ptr && fn_ty) { |
| 2796 | if (stmt->getCallee()->getStmtClass() == clang::Stmt::ImplicitCastExprClass) { | 2794 | if (stmt->getCallee()->getStmtClass() == clang::Stmt::ImplicitCastExprClass) { |
| ... | @@ -2824,7 +2822,9 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2824,7 +2822,9 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * |
| 2824 | node->data.fn_call_expr.params.append(arg_node); | 2822 | node->data.fn_call_expr.params.append(arg_node); |
| 2825 | } | 2823 | } |
| 2826 | | 2824 | |
| 2827 | if (result_used == ResultUsedNo && fn_ty && !qual_type_canon(fn_ty->getReturnType())->isVoidType()) { | 2825 | if (result_used == ResultUsedNo && fn_ty && |
| | 2826 | !ZigClangType_isVoidType(qual_type_canon(bitcast(fn_ty->getReturnType())))) |
| | 2827 | { |
| 2828 | node = trans_create_node_bin_op(c, trans_create_node_symbol_str(c, "_"), BinOpTypeAssign, node); | 2828 | node = trans_create_node_bin_op(c, trans_create_node_symbol_str(c, "_"), BinOpTypeAssign, node); |
| 2829 | } | 2829 | } |
| 2830 | | 2830 | |
| ... | @@ -2871,7 +2871,8 @@ static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, Tran | ... | @@ -2871,7 +2871,8 @@ static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, Tran |
| 2871 | if (sub_expr_node == nullptr) | 2871 | if (sub_expr_node == nullptr) |
| 2872 | return nullptr; | 2872 | return nullptr; |
| 2873 | | 2873 | |
| 2874 | AstNode *cast = trans_c_cast(c, bitcast(stmt->getBeginLoc()), stmt->getType(), stmt->getSubExpr()->getType(), sub_expr_node); | 2874 | AstNode *cast = trans_c_cast(c, bitcast(stmt->getBeginLoc()), bitcast(stmt->getType()), |
| | 2875 | bitcast(stmt->getSubExpr()->getType()), sub_expr_node); |
| 2875 | if (cast == nullptr) | 2876 | if (cast == nullptr) |
| 2876 | return nullptr; | 2877 | return nullptr; |
| 2877 | | 2878 | |
| ... | @@ -2881,7 +2882,7 @@ static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, Tran | ... | @@ -2881,7 +2882,7 @@ static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, Tran |
| 2881 | static AstNode *trans_unary_expr_or_type_trait_expr(Context *c, ResultUsed result_used, | 2882 | static AstNode *trans_unary_expr_or_type_trait_expr(Context *c, ResultUsed result_used, |
| 2882 | TransScope *scope, const clang::UnaryExprOrTypeTraitExpr *stmt) | 2883 | TransScope *scope, const clang::UnaryExprOrTypeTraitExpr *stmt) |
| 2883 | { | 2884 | { |
| 2884 | AstNode *type_node = trans_qual_type(c, stmt->getTypeOfArgument(), bitcast(stmt->getBeginLoc())); | 2885 | AstNode *type_node = trans_qual_type(c, bitcast(stmt->getTypeOfArgument()), bitcast(stmt->getBeginLoc())); |
| 2885 | if (type_node == nullptr) | 2886 | if (type_node == nullptr) |
| 2886 | return nullptr; | 2887 | return nullptr; |
| 2887 | | 2888 | |
| ... | @@ -3858,7 +3859,7 @@ static void visit_fn_decl(Context *c, const clang::FunctionDecl *fn_decl) { | ... | @@ -3858,7 +3859,7 @@ static void visit_fn_decl(Context *c, const clang::FunctionDecl *fn_decl) { |
| 3858 | return; | 3859 | return; |
| 3859 | } | 3860 | } |
| 3860 | | 3861 | |
| 3861 | AstNode *proto_node = trans_qual_type(c, fn_decl->getType(), bitcast(fn_decl->getLocation())); | 3862 | AstNode *proto_node = trans_qual_type(c, bitcast(fn_decl->getType()), bitcast(fn_decl->getLocation())); |
| 3862 | if (proto_node == nullptr) { | 3863 | if (proto_node == nullptr) { |
| 3863 | emit_warning(c, bitcast(fn_decl->getLocation()), "unable to resolve prototype of function '%s'", buf_ptr(fn_name)); | 3864 | emit_warning(c, bitcast(fn_decl->getLocation()), "unable to resolve prototype of function '%s'", buf_ptr(fn_name)); |
| 3864 | return; | 3865 | return; |
| ... | @@ -4003,7 +4004,7 @@ static AstNode *resolve_typedef_decl(Context *c, const ZigClangTypedefNameDecl * | ... | @@ -4003,7 +4004,7 @@ static AstNode *resolve_typedef_decl(Context *c, const ZigClangTypedefNameDecl * |
| 4003 | AstNode *symbol_node = trans_create_node_symbol(c, type_name); | 4004 | AstNode *symbol_node = trans_create_node_symbol(c, type_name); |
| 4004 | c->decl_table.put(ZigClangTypedefNameDecl_getCanonicalDecl(typedef_decl), symbol_node); | 4005 | c->decl_table.put(ZigClangTypedefNameDecl_getCanonicalDecl(typedef_decl), symbol_node); |
| 4005 | | 4006 | |
| 4006 | AstNode *type_node = trans_qual_type(c, bitcast(child_qt), ZigClangTypedefNameDecl_getLocation(typedef_decl)); | 4007 | AstNode *type_node = trans_qual_type(c, child_qt, ZigClangTypedefNameDecl_getLocation(typedef_decl)); |
| 4007 | if (type_node == nullptr) { | 4008 | if (type_node == nullptr) { |
| 4008 | emit_warning(c, ZigClangTypedefNameDecl_getLocation(typedef_decl), | 4009 | emit_warning(c, ZigClangTypedefNameDecl_getLocation(typedef_decl), |
| 4009 | "typedef %s - unresolved child type", buf_ptr(type_name)); | 4010 | "typedef %s - unresolved child type", buf_ptr(type_name)); |
| ... | @@ -4059,8 +4060,7 @@ static AstNode *resolve_enum_decl(Context *c, const ZigClangEnumDecl *enum_decl) | ... | @@ -4059,8 +4060,7 @@ static AstNode *resolve_enum_decl(Context *c, const ZigClangEnumDecl *enum_decl) |
| 4059 | pure_enum = false; | 4060 | pure_enum = false; |
| 4060 | } | 4061 | } |
| 4061 | } | 4062 | } |
| 4062 | AstNode *tag_int_type = trans_qual_type(c, | 4063 | AstNode *tag_int_type = trans_qual_type(c, ZigClangEnumDecl_getIntegerType(enum_decl), |
| 4063 | bitcast(ZigClangEnumDecl_getIntegerType(enum_decl)), | | |
| 4064 | ZigClangEnumDecl_getLocation(enum_decl)); | 4064 | ZigClangEnumDecl_getLocation(enum_decl)); |
| 4065 | assert(tag_int_type); | 4065 | assert(tag_int_type); |
| 4066 | | 4066 | |
| ... | @@ -4070,8 +4070,8 @@ static AstNode *resolve_enum_decl(Context *c, const ZigClangEnumDecl *enum_decl) | ... | @@ -4070,8 +4070,8 @@ static AstNode *resolve_enum_decl(Context *c, const ZigClangEnumDecl *enum_decl) |
| 4070 | // TODO only emit this tag type if the enum tag type is not the default. | 4070 | // TODO only emit this tag type if the enum tag type is not the default. |
| 4071 | // I don't know what the default is, need to figure out how clang is deciding. | 4071 | // I don't know what the default is, need to figure out how clang is deciding. |
| 4072 | // it appears to at least be different across gcc/msvc | 4072 | // it appears to at least be different across gcc/msvc |
| 4073 | if (!c_is_builtin_type(c, bitcast(ZigClangEnumDecl_getIntegerType(enum_decl)), clang::BuiltinType::UInt) && | 4073 | if (!c_is_builtin_type(c, ZigClangEnumDecl_getIntegerType(enum_decl), clang::BuiltinType::UInt) && |
| 4074 | !c_is_builtin_type(c, bitcast(ZigClangEnumDecl_getIntegerType(enum_decl)), clang::BuiltinType::Int)) | 4074 | !c_is_builtin_type(c, ZigClangEnumDecl_getIntegerType(enum_decl), clang::BuiltinType::Int)) |
| 4075 | { | 4075 | { |
| 4076 | enum_node->data.container_decl.init_arg_expr = tag_int_type; | 4076 | enum_node->data.container_decl.init_arg_expr = tag_int_type; |
| 4077 | } | 4077 | } |
| ... | @@ -4209,7 +4209,7 @@ static AstNode *resolve_record_decl(Context *c, const ZigClangRecordDecl *record | ... | @@ -4209,7 +4209,7 @@ static AstNode *resolve_record_decl(Context *c, const ZigClangRecordDecl *record |
| 4209 | | 4209 | |
| 4210 | AstNode *field_node = trans_create_node(c, NodeTypeStructField); | 4210 | AstNode *field_node = trans_create_node(c, NodeTypeStructField); |
| 4211 | field_node->data.struct_field.name = buf_create_from_str(ZigClangDecl_getName_bytes_begin((const ZigClangDecl *)field_decl)); | 4211 | field_node->data.struct_field.name = buf_create_from_str(ZigClangDecl_getName_bytes_begin((const ZigClangDecl *)field_decl)); |
| 4212 | field_node->data.struct_field.type = trans_qual_type(c, field_decl->getType(), | 4212 | field_node->data.struct_field.type = trans_qual_type(c, bitcast(field_decl->getType()), |
| 4213 | bitcast(field_decl->getLocation())); | 4213 | bitcast(field_decl->getLocation())); |
| 4214 | | 4214 | |
| 4215 | if (field_node->data.struct_field.type == nullptr) { | 4215 | if (field_node->data.struct_field.type == nullptr) { |
| ... | @@ -4233,7 +4233,7 @@ static AstNode *resolve_record_decl(Context *c, const ZigClangRecordDecl *record | ... | @@ -4233,7 +4233,7 @@ static AstNode *resolve_record_decl(Context *c, const ZigClangRecordDecl *record |
| 4233 | } | 4233 | } |
| 4234 | } | 4234 | } |
| 4235 | | 4235 | |
| 4236 | static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, clang::QualType qt, ZigClangSourceLocation source_loc) { | 4236 | static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQualType qt, ZigClangSourceLocation source_loc) { |
| 4237 | switch (ap_value->getKind()) { | 4237 | switch (ap_value->getKind()) { |
| 4238 | case clang::APValue::Int: | 4238 | case clang::APValue::Int: |
| 4239 | return trans_create_node_apint(c, ap_value->getInt()); | 4239 | return trans_create_node_apint(c, ap_value->getInt()); |
| ... | @@ -4253,7 +4253,8 @@ static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, clang::Qual | ... | @@ -4253,7 +4253,8 @@ static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, clang::Qual |
| 4253 | init_node->data.container_init_expr.type = arr_type_node; | 4253 | init_node->data.container_init_expr.type = arr_type_node; |
| 4254 | init_node->data.container_init_expr.kind = ContainerInitKindArray; | 4254 | init_node->data.container_init_expr.kind = ContainerInitKindArray; |
| 4255 | | 4255 | |
| 4256 | clang::QualType child_qt = qt.getTypePtr()->getAsArrayTypeUnsafe()->getElementType(); | 4256 | const clang::Type *qt_type = reinterpret_cast<const clang::Type *>(ZigClangQualType_getTypePtr(qt)); |
| | 4257 | ZigClangQualType child_qt = bitcast(qt_type->getAsArrayTypeUnsafe()->getElementType()); |
| 4257 | | 4258 | |
| 4258 | for (size_t i = 0; i < init_count; i += 1) { | 4259 | for (size_t i = 0; i < init_count; i += 1) { |
| 4259 | clang::APValue &elem_ap_val = ap_value->getArrayInitializedElt(i); | 4260 | clang::APValue &elem_ap_val = ap_value->getArrayInitializedElt(i); |
| ... | @@ -4347,7 +4348,7 @@ static void visit_var_decl(Context *c, const clang::VarDecl *var_decl) { | ... | @@ -4347,7 +4348,7 @@ static void visit_var_decl(Context *c, const clang::VarDecl *var_decl) { |
| 4347 | return; | 4348 | return; |
| 4348 | } | 4349 | } |
| 4349 | | 4350 | |
| 4350 | clang::QualType qt = var_decl->getType(); | 4351 | ZigClangQualType qt = bitcast(var_decl->getType()); |
| 4351 | AstNode *var_type = trans_qual_type(c, qt, bitcast(var_decl->getLocation())); | 4352 | AstNode *var_type = trans_qual_type(c, qt, bitcast(var_decl->getLocation())); |
| 4352 | if (var_type == nullptr) { | 4353 | if (var_type == nullptr) { |
| 4353 | emit_warning(c, bitcast(var_decl->getLocation()), "ignoring variable '%s' - unresolved type", buf_ptr(name)); | 4354 | emit_warning(c, bitcast(var_decl->getLocation()), "ignoring variable '%s' - unresolved type", buf_ptr(name)); |
| ... | @@ -4356,7 +4357,7 @@ static void visit_var_decl(Context *c, const clang::VarDecl *var_decl) { | ... | @@ -4356,7 +4357,7 @@ static void visit_var_decl(Context *c, const clang::VarDecl *var_decl) { |
| 4356 | | 4357 | |
| 4357 | bool is_extern = var_decl->hasExternalStorage(); | 4358 | bool is_extern = var_decl->hasExternalStorage(); |
| 4358 | bool is_static = var_decl->isFileVarDecl(); | 4359 | bool is_static = var_decl->isFileVarDecl(); |
| 4359 | bool is_const = qt.isConstQualified(); | 4360 | bool is_const = ZigClangQualType_isConstQualified(qt); |
| 4360 | | 4361 | |
| 4361 | if (is_static && !is_extern) { | 4362 | if (is_static && !is_extern) { |
| 4362 | AstNode *init_node; | 4363 | AstNode *init_node; |