| ... | @@ -137,9 +137,9 @@ static const ZigClangAPValue *bitcast(const clang::APValue *src) { | ... | @@ -137,9 +137,9 @@ static const ZigClangAPValue *bitcast(const clang::APValue *src) { |
| 137 | return reinterpret_cast<const ZigClangAPValue *>(src); | 137 | return reinterpret_cast<const ZigClangAPValue *>(src); |
| 138 | } | 138 | } |
| 139 | | 139 | |
| 140 | static const ZigClangStmt *bitcast(const clang::Stmt *src) { | 140 | //static const ZigClangStmt *bitcast(const clang::Stmt *src) { |
| 141 | return reinterpret_cast<const ZigClangStmt *>(src); | 141 | // return reinterpret_cast<const ZigClangStmt *>(src); |
| 142 | } | 142 | //} |
| 143 | | 143 | |
| 144 | static const ZigClangExpr *bitcast(const clang::Expr *src) { | 144 | static const ZigClangExpr *bitcast(const clang::Expr *src) { |
| 145 | return reinterpret_cast<const ZigClangExpr *>(src); | 145 | return reinterpret_cast<const ZigClangExpr *>(src); |
| ... | @@ -578,7 +578,7 @@ static bool qual_type_is_ptr(ZigClangQualType qt) { | ... | @@ -578,7 +578,7 @@ static bool qual_type_is_ptr(ZigClangQualType qt) { |
| 578 | return ZigClangType_getTypeClass(ty) == ZigClangType_Pointer; | 578 | return ZigClangType_getTypeClass(ty) == ZigClangType_Pointer; |
| 579 | } | 579 | } |
| 580 | | 580 | |
| 581 | static const clang::FunctionProtoType *qual_type_get_fn_proto(ZigClangQualType qt, bool *is_ptr) { | 581 | static const ZigClangFunctionProtoType *qual_type_get_fn_proto(ZigClangQualType qt, bool *is_ptr) { |
| 582 | const ZigClangType *ty = qual_type_canon(qt); | 582 | const ZigClangType *ty = qual_type_canon(qt); |
| 583 | *is_ptr = false; | 583 | *is_ptr = false; |
| 584 | | 584 | |
| ... | @@ -589,7 +589,7 @@ static const clang::FunctionProtoType *qual_type_get_fn_proto(ZigClangQualType q | ... | @@ -589,7 +589,7 @@ static const clang::FunctionProtoType *qual_type_get_fn_proto(ZigClangQualType q |
| 589 | } | 589 | } |
| 590 | | 590 | |
| 591 | if (ZigClangType_getTypeClass(ty) == ZigClangType_FunctionProto) { | 591 | if (ZigClangType_getTypeClass(ty) == ZigClangType_FunctionProto) { |
| 592 | return reinterpret_cast<const clang::FunctionProtoType*>(ty); | 592 | return reinterpret_cast<const ZigClangFunctionProtoType*>(ty); |
| 593 | } | 593 | } |
| 594 | | 594 | |
| 595 | return nullptr; | 595 | return nullptr; |
| ... | @@ -684,13 +684,14 @@ static AstNode *qual_type_to_log2_int_ref(Context *c, const ZigClangQualType qt, | ... | @@ -684,13 +684,14 @@ static AstNode *qual_type_to_log2_int_ref(Context *c, const ZigClangQualType qt, |
| 684 | static bool qual_type_child_is_fn_proto(ZigClangQualType qt) { | 684 | static bool qual_type_child_is_fn_proto(ZigClangQualType qt) { |
| 685 | const ZigClangType *ty = ZigClangQualType_getTypePtr(qt); | 685 | const ZigClangType *ty = ZigClangQualType_getTypePtr(qt); |
| 686 | if (ZigClangType_getTypeClass(ty) == ZigClangType_Paren) { | 686 | if (ZigClangType_getTypeClass(ty) == ZigClangType_Paren) { |
| 687 | const clang::ParenType *paren_type = reinterpret_cast<const clang::ParenType *>(ty); | 687 | const ZigClangParenType *paren_type = reinterpret_cast<const ZigClangParenType *>(ty); |
| 688 | if (paren_type->getInnerType()->getTypeClass() == clang::Type::FunctionProto) { | 688 | ZigClangQualType inner_type = ZigClangParenType_getInnerType(paren_type); |
| | 689 | if (ZigClangQualType_getTypeClass(inner_type) == ZigClangType_FunctionProto) { |
| 689 | return true; | 690 | return true; |
| 690 | } | 691 | } |
| 691 | } else if (ZigClangType_getTypeClass(ty) == ZigClangType_Attributed) { | 692 | } else if (ZigClangType_getTypeClass(ty) == ZigClangType_Attributed) { |
| 692 | const clang::AttributedType *attr_type = reinterpret_cast<const clang::AttributedType *>(ty); | 693 | const ZigClangAttributedType *attr_type = reinterpret_cast<const ZigClangAttributedType *>(ty); |
| 693 | return qual_type_child_is_fn_proto(bitcast(attr_type->getEquivalentType())); | 694 | return qual_type_child_is_fn_proto(ZigClangAttributedType_getEquivalentType(attr_type)); |
| 694 | } | 695 | } |
| 695 | return false; | 696 | return false; |
| 696 | } | 697 | } |
| ... | @@ -839,8 +840,8 @@ static bool type_is_function(Context *c, const ZigClangType *ty, ZigClangSourceL | ... | @@ -839,8 +840,8 @@ static bool type_is_function(Context *c, const ZigClangType *ty, ZigClangSourceL |
| 839 | case ZigClangType_FunctionNoProto: | 840 | case ZigClangType_FunctionNoProto: |
| 840 | return true; | 841 | return true; |
| 841 | case ZigClangType_Elaborated: { | 842 | case ZigClangType_Elaborated: { |
| 842 | const clang::ElaboratedType *elaborated_ty = reinterpret_cast<const clang::ElaboratedType*>(ty); | 843 | const ZigClangElaboratedType *elaborated_ty = reinterpret_cast<const ZigClangElaboratedType*>(ty); |
| 843 | ZigClangQualType qt = bitcast(elaborated_ty->getNamedType()); | 844 | ZigClangQualType qt = ZigClangElaboratedType_getNamedType(elaborated_ty); |
| 844 | return type_is_function(c, ZigClangQualType_getTypePtr(qt), source_loc); | 845 | return type_is_function(c, ZigClangQualType_getTypePtr(qt), source_loc); |
| 845 | } | 846 | } |
| 846 | case ZigClangType_Typedef: { | 847 | case ZigClangType_Typedef: { |
| ... | @@ -880,8 +881,8 @@ static bool type_is_opaque(Context *c, const ZigClangType *ty, ZigClangSourceLoc | ... | @@ -880,8 +881,8 @@ static bool type_is_opaque(Context *c, const ZigClangType *ty, ZigClangSourceLoc |
| 880 | return false; | 881 | return false; |
| 881 | } | 882 | } |
| 882 | case ZigClangType_Elaborated: { | 883 | case ZigClangType_Elaborated: { |
| 883 | const clang::ElaboratedType *elaborated_ty = reinterpret_cast<const clang::ElaboratedType*>(ty); | 884 | const ZigClangElaboratedType *elaborated_ty = reinterpret_cast<const ZigClangElaboratedType*>(ty); |
| 884 | ZigClangQualType qt = bitcast(elaborated_ty->getNamedType()); | 885 | ZigClangQualType qt = ZigClangElaboratedType_getNamedType(elaborated_ty); |
| 885 | return type_is_opaque(c, ZigClangQualType_getTypePtr(qt), source_loc); | 886 | return type_is_opaque(c, ZigClangQualType_getTypePtr(qt), source_loc); |
| 886 | } | 887 | } |
| 887 | case ZigClangType_Typedef: { | 888 | case ZigClangType_Typedef: { |
| ... | @@ -1078,16 +1079,16 @@ static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLoc | ... | @@ -1078,16 +1079,16 @@ static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLoc |
| 1078 | } | 1079 | } |
| 1079 | case ZigClangType_Elaborated: | 1080 | case ZigClangType_Elaborated: |
| 1080 | { | 1081 | { |
| 1081 | const clang::ElaboratedType *elaborated_ty = reinterpret_cast<const clang::ElaboratedType*>(ty); | 1082 | const ZigClangElaboratedType *elaborated_ty = reinterpret_cast<const ZigClangElaboratedType*>(ty); |
| 1082 | switch (elaborated_ty->getKeyword()) { | 1083 | switch (ZigClangElaboratedType_getKeyword(elaborated_ty)) { |
| 1083 | case clang::ETK_Struct: | 1084 | case ZigClangETK_Struct: |
| 1084 | case clang::ETK_Enum: | 1085 | case ZigClangETK_Enum: |
| 1085 | case clang::ETK_Union: | 1086 | case ZigClangETK_Union: |
| 1086 | return trans_qual_type(c, bitcast(elaborated_ty->getNamedType()), source_loc); | 1087 | return trans_qual_type(c, ZigClangElaboratedType_getNamedType(elaborated_ty), source_loc); |
| 1087 | case clang::ETK_Interface: | 1088 | case ZigClangETK_Interface: |
| 1088 | case clang::ETK_Class: | 1089 | case ZigClangETK_Class: |
| 1089 | case clang::ETK_Typename: | 1090 | case ZigClangETK_Typename: |
| 1090 | case clang::ETK_None: | 1091 | case ZigClangETK_None: |
| 1091 | emit_warning(c, source_loc, "unsupported elaborated type"); | 1092 | emit_warning(c, source_loc, "unsupported elaborated type"); |
| 1092 | return nullptr; | 1093 | return nullptr; |
| 1093 | } | 1094 | } |
| ... | @@ -1227,35 +1228,37 @@ static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLoc | ... | @@ -1227,35 +1228,37 @@ static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLoc |
| 1227 | } | 1228 | } |
| 1228 | case ZigClangType_ConstantArray: | 1229 | case ZigClangType_ConstantArray: |
| 1229 | { | 1230 | { |
| 1230 | const clang::ConstantArrayType *const_arr_ty = reinterpret_cast<const clang::ConstantArrayType *>(ty); | 1231 | const ZigClangConstantArrayType *const_arr_ty = reinterpret_cast<const ZigClangConstantArrayType *>(ty); |
| 1231 | AstNode *child_type_node = trans_qual_type(c, bitcast(const_arr_ty->getElementType()), source_loc); | 1232 | AstNode *child_type_node = trans_qual_type(c, |
| | 1233 | ZigClangConstantArrayType_getElementType(const_arr_ty), source_loc); |
| 1232 | if (child_type_node == nullptr) { | 1234 | if (child_type_node == nullptr) { |
| 1233 | emit_warning(c, source_loc, "unresolved array element type"); | 1235 | emit_warning(c, source_loc, "unresolved array element type"); |
| 1234 | return nullptr; | 1236 | return nullptr; |
| 1235 | } | 1237 | } |
| 1236 | uint64_t size = const_arr_ty->getSize().getLimitedValue(); | 1238 | const ZigClangAPInt *size_ap_int = ZigClangConstantArrayType_getSize(const_arr_ty); |
| | 1239 | uint64_t size = ZigClangAPInt_getLimitedValue(size_ap_int, UINT64_MAX); |
| 1237 | AstNode *size_node = trans_create_node_unsigned(c, size); | 1240 | AstNode *size_node = trans_create_node_unsigned(c, size); |
| 1238 | return trans_create_node_array_type(c, size_node, child_type_node); | 1241 | return trans_create_node_array_type(c, size_node, child_type_node); |
| 1239 | } | 1242 | } |
| 1240 | case ZigClangType_Paren: | 1243 | case ZigClangType_Paren: |
| 1241 | { | 1244 | { |
| 1242 | const clang::ParenType *paren_ty = reinterpret_cast<const clang::ParenType *>(ty); | 1245 | const ZigClangParenType *paren_ty = reinterpret_cast<const ZigClangParenType *>(ty); |
| 1243 | return trans_qual_type(c, bitcast(paren_ty->getInnerType()), source_loc); | 1246 | return trans_qual_type(c, ZigClangParenType_getInnerType(paren_ty), source_loc); |
| 1244 | } | 1247 | } |
| 1245 | case ZigClangType_Decayed: | 1248 | case ZigClangType_Decayed: |
| 1246 | { | 1249 | { |
| 1247 | const clang::DecayedType *decayed_ty = reinterpret_cast<const clang::DecayedType *>(ty); | 1250 | const ZigClangDecayedType *decayed_ty = reinterpret_cast<const ZigClangDecayedType *>(ty); |
| 1248 | return trans_qual_type(c, bitcast(decayed_ty->getDecayedType()), source_loc); | 1251 | return trans_qual_type(c, ZigClangDecayedType_getDecayedType(decayed_ty), source_loc); |
| 1249 | } | 1252 | } |
| 1250 | case ZigClangType_Attributed: | 1253 | case ZigClangType_Attributed: |
| 1251 | { | 1254 | { |
| 1252 | const clang::AttributedType *attributed_ty = reinterpret_cast<const clang::AttributedType *>(ty); | 1255 | const ZigClangAttributedType *attributed_ty = reinterpret_cast<const ZigClangAttributedType *>(ty); |
| 1253 | return trans_qual_type(c, bitcast(attributed_ty->getEquivalentType()), source_loc); | 1256 | return trans_qual_type(c, ZigClangAttributedType_getEquivalentType(attributed_ty), source_loc); |
| 1254 | } | 1257 | } |
| 1255 | case ZigClangType_IncompleteArray: | 1258 | case ZigClangType_IncompleteArray: |
| 1256 | { | 1259 | { |
| 1257 | const clang::IncompleteArrayType *incomplete_array_ty = reinterpret_cast<const clang::IncompleteArrayType *>(ty); | 1260 | const ZigClangIncompleteArrayType *incomplete_array_ty = reinterpret_cast<const ZigClangIncompleteArrayType *>(ty); |
| 1258 | ZigClangQualType child_qt = bitcast(incomplete_array_ty->getElementType()); | 1261 | ZigClangQualType child_qt = ZigClangIncompleteArrayType_getElementType(incomplete_array_ty); |
| 1259 | AstNode *child_type_node = trans_qual_type(c, child_qt, source_loc); | 1262 | AstNode *child_type_node = trans_qual_type(c, child_qt, source_loc); |
| 1260 | if (child_type_node == nullptr) { | 1263 | if (child_type_node == nullptr) { |
| 1261 | emit_warning(c, source_loc, "unresolved array element type"); | 1264 | emit_warning(c, source_loc, "unresolved array element type"); |
| ... | @@ -1342,9 +1345,9 @@ static AstNode *trans_compound_stmt(Context *c, TransScope *scope, const ZigClan | ... | @@ -1342,9 +1345,9 @@ static AstNode *trans_compound_stmt(Context *c, TransScope *scope, const ZigClan |
| 1342 | } | 1345 | } |
| 1343 | | 1346 | |
| 1344 | static AstNode *trans_stmt_expr(Context *c, ResultUsed result_used, TransScope *scope, | 1347 | static AstNode *trans_stmt_expr(Context *c, ResultUsed result_used, TransScope *scope, |
| 1345 | const clang::StmtExpr *stmt, TransScope **out_node_scope) | 1348 | const ZigClangStmtExpr *stmt, TransScope **out_node_scope) |
| 1346 | { | 1349 | { |
| 1347 | AstNode *block = trans_compound_stmt(c, scope, (const ZigClangCompoundStmt *)stmt->getSubStmt(), out_node_scope); | 1350 | AstNode *block = trans_compound_stmt(c, scope, ZigClangStmtExpr_getSubStmt(stmt), out_node_scope); |
| 1348 | if (block == nullptr) | 1351 | if (block == nullptr) |
| 1349 | return block; | 1352 | return block; |
| 1350 | assert(block->type == NodeTypeBlock); | 1353 | assert(block->type == NodeTypeBlock); |
| ... | @@ -1366,8 +1369,8 @@ static AstNode *trans_stmt_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -1366,8 +1369,8 @@ static AstNode *trans_stmt_expr(Context *c, ResultUsed result_used, TransScope * |
| 1366 | return maybe_suppress_result(c, result_used, block); | 1369 | return maybe_suppress_result(c, result_used, block); |
| 1367 | } | 1370 | } |
| 1368 | | 1371 | |
| 1369 | static AstNode *trans_return_stmt(Context *c, TransScope *scope, const clang::ReturnStmt *stmt) { | 1372 | static AstNode *trans_return_stmt(Context *c, TransScope *scope, const ZigClangReturnStmt *stmt) { |
| 1370 | const ZigClangExpr *value_expr = bitcast(stmt->getRetValue()); | 1373 | const ZigClangExpr *value_expr = ZigClangReturnStmt_getRetValue(stmt); |
| 1371 | if (value_expr == nullptr) { | 1374 | if (value_expr == nullptr) { |
| 1372 | return trans_create_node(c, NodeTypeReturnExpr); | 1375 | return trans_create_node(c, NodeTypeReturnExpr); |
| 1373 | } else { | 1376 | } else { |
| ... | @@ -1379,76 +1382,79 @@ static AstNode *trans_return_stmt(Context *c, TransScope *scope, const clang::Re | ... | @@ -1379,76 +1382,79 @@ static AstNode *trans_return_stmt(Context *c, TransScope *scope, const clang::Re |
| 1379 | } | 1382 | } |
| 1380 | } | 1383 | } |
| 1381 | | 1384 | |
| 1382 | static AstNode *trans_integer_literal(Context *c, ResultUsed result_used, const clang::IntegerLiteral *stmt) { | 1385 | static AstNode *trans_integer_literal(Context *c, ResultUsed result_used, const ZigClangIntegerLiteral *stmt) { |
| 1383 | clang::Expr::EvalResult result; | 1386 | ZigClangExprEvalResult result; |
| 1384 | if (!stmt->EvaluateAsInt(result, *reinterpret_cast<clang::ASTContext *>(c->ctx))) { | 1387 | if (!ZigClangIntegerLiteral_EvaluateAsInt(stmt, &result, c->ctx)) { |
| 1385 | emit_warning(c, bitcast(stmt->getBeginLoc()), "invalid integer literal"); | 1388 | emit_warning(c, ZigClangExpr_getBeginLoc((ZigClangExpr*)stmt), "invalid integer literal"); |
| 1386 | return nullptr; | 1389 | return nullptr; |
| 1387 | } | 1390 | } |
| 1388 | AstNode *node = trans_create_node_apint(c, bitcast(&result.Val.getInt())); | 1391 | AstNode *node = trans_create_node_apint(c, ZigClangAPValue_getInt(&result.Val)); |
| 1389 | return maybe_suppress_result(c, result_used, node); | 1392 | return maybe_suppress_result(c, result_used, node); |
| 1390 | } | 1393 | } |
| 1391 | | 1394 | |
| 1392 | static AstNode *trans_floating_literal(Context *c, ResultUsed result_used, const clang::FloatingLiteral *stmt) { | 1395 | static AstNode *trans_floating_literal(Context *c, ResultUsed result_used, const ZigClangFloatingLiteral *stmt) { |
| 1393 | llvm::APFloat result{0.0f}; | 1396 | llvm::APFloat result{0.0f}; |
| 1394 | if (!stmt->EvaluateAsFloat(result, *reinterpret_cast<clang::ASTContext *>(c->ctx))) { | 1397 | if (!reinterpret_cast<const clang::FloatingLiteral *>(stmt)->EvaluateAsFloat(result, *reinterpret_cast<clang::ASTContext *>(c->ctx))) { |
| 1395 | emit_warning(c, bitcast(stmt->getBeginLoc()), "invalid floating literal"); | 1398 | emit_warning(c, ZigClangExpr_getBeginLoc((ZigClangExpr*)stmt), "invalid floating literal"); |
| 1396 | return nullptr; | 1399 | return nullptr; |
| 1397 | } | 1400 | } |
| 1398 | AstNode *node = trans_create_node_apfloat(c, result); | 1401 | AstNode *node = trans_create_node_apfloat(c, result); |
| 1399 | return maybe_suppress_result(c, result_used, node); | 1402 | return maybe_suppress_result(c, result_used, node); |
| 1400 | } | 1403 | } |
| 1401 | | 1404 | |
| 1402 | static AstNode *trans_character_literal(Context *c, ResultUsed result_used, const clang::CharacterLiteral *stmt) { | 1405 | static AstNode *trans_character_literal(Context *c, ResultUsed result_used, const ZigClangCharacterLiteral *stmt) { |
| 1403 | switch (stmt->getKind()) { | 1406 | switch (ZigClangCharacterLiteral_getKind(stmt)) { |
| 1404 | case clang::CharacterLiteral::CharacterKind::Ascii: | 1407 | case ZigClangCharacterLiteral_CharacterKind_Ascii: |
| 1405 | { | 1408 | { |
| 1406 | unsigned val = stmt->getValue(); | 1409 | unsigned val = ZigClangCharacterLiteral_getValue(stmt); |
| 1407 | // C has a somewhat obscure feature called multi-character character | 1410 | // C has a somewhat obscure feature called multi-character character |
| 1408 | // constant | 1411 | // constant |
| 1409 | if (val > 255) | 1412 | if (val > 255) |
| 1410 | return trans_create_node_unsigned(c, val); | 1413 | return trans_create_node_unsigned(c, val); |
| 1411 | } | 1414 | } |
| 1412 | // fallthrough | 1415 | // fallthrough |
| 1413 | case clang::CharacterLiteral::CharacterKind::UTF8: | 1416 | case ZigClangCharacterLiteral_CharacterKind_UTF8: |
| 1414 | { | 1417 | { |
| 1415 | AstNode *node = trans_create_node(c, NodeTypeCharLiteral); | 1418 | AstNode *node = trans_create_node(c, NodeTypeCharLiteral); |
| 1416 | node->data.char_literal.value = stmt->getValue(); | 1419 | node->data.char_literal.value = ZigClangCharacterLiteral_getValue(stmt); |
| 1417 | return maybe_suppress_result(c, result_used, node); | 1420 | return maybe_suppress_result(c, result_used, node); |
| 1418 | } | 1421 | } |
| 1419 | case clang::CharacterLiteral::CharacterKind::UTF16: | 1422 | case ZigClangCharacterLiteral_CharacterKind_UTF16: |
| 1420 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO support UTF16 character literals"); | 1423 | emit_warning(c, ZigClangCharacterLiteral_getBeginLoc(stmt), "TODO support UTF16 character literals"); |
| 1421 | return nullptr; | 1424 | return nullptr; |
| 1422 | case clang::CharacterLiteral::CharacterKind::UTF32: | 1425 | case ZigClangCharacterLiteral_CharacterKind_UTF32: |
| 1423 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO support UTF32 character literals"); | 1426 | emit_warning(c, ZigClangCharacterLiteral_getBeginLoc(stmt), "TODO support UTF32 character literals"); |
| 1424 | return nullptr; | 1427 | return nullptr; |
| 1425 | case clang::CharacterLiteral::CharacterKind::Wide: | 1428 | case ZigClangCharacterLiteral_CharacterKind_Wide: |
| 1426 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO support wide character literals"); | 1429 | emit_warning(c, ZigClangCharacterLiteral_getBeginLoc(stmt), "TODO support wide character literals"); |
| 1427 | return nullptr; | 1430 | return nullptr; |
| 1428 | } | 1431 | } |
| 1429 | zig_unreachable(); | 1432 | zig_unreachable(); |
| 1430 | } | 1433 | } |
| 1431 | | 1434 | |
| 1432 | static AstNode *trans_constant_expr(Context *c, ResultUsed result_used, const clang::ConstantExpr *expr) { | 1435 | static AstNode *trans_constant_expr(Context *c, ResultUsed result_used, const ZigClangConstantExpr *expr) { |
| | 1436 | const ZigClangExpr *as_expr = reinterpret_cast<const ZigClangExpr *>(expr); |
| 1433 | clang::Expr::EvalResult result; | 1437 | clang::Expr::EvalResult result; |
| 1434 | if (!expr->EvaluateAsConstantExpr(result, clang::Expr::EvaluateForCodeGen, | 1438 | if (!reinterpret_cast<const clang::ConstantExpr *>(expr)->EvaluateAsConstantExpr(result, |
| | 1439 | clang::Expr::EvaluateForCodeGen, |
| 1435 | *reinterpret_cast<clang::ASTContext *>(c->ctx))) | 1440 | *reinterpret_cast<clang::ASTContext *>(c->ctx))) |
| 1436 | { | 1441 | { |
| 1437 | emit_warning(c, bitcast(expr->getBeginLoc()), "invalid constant expression"); | 1442 | emit_warning(c, ZigClangExpr_getBeginLoc(as_expr), "invalid constant expression"); |
| 1438 | return nullptr; | 1443 | return nullptr; |
| 1439 | } | 1444 | } |
| 1440 | AstNode *node = trans_ap_value(c, bitcast(&result.Val), bitcast(expr->getType()), bitcast(expr->getBeginLoc())); | 1445 | AstNode *node = trans_ap_value(c, bitcast(&result.Val), ZigClangExpr_getType(as_expr), |
| | 1446 | ZigClangExpr_getBeginLoc(as_expr)); |
| 1441 | return maybe_suppress_result(c, result_used, node); | 1447 | return maybe_suppress_result(c, result_used, node); |
| 1442 | } | 1448 | } |
| 1443 | | 1449 | |
| 1444 | static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, TransScope *scope, | 1450 | static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, TransScope *scope, |
| 1445 | const clang::ConditionalOperator *stmt) | 1451 | const ZigClangConditionalOperator *stmt) |
| 1446 | { | 1452 | { |
| 1447 | AstNode *node = trans_create_node(c, NodeTypeIfBoolExpr); | 1453 | AstNode *node = trans_create_node(c, NodeTypeIfBoolExpr); |
| 1448 | | 1454 | |
| 1449 | const ZigClangExpr *cond_expr = bitcast(stmt->getCond()); | 1455 | const ZigClangExpr *cond_expr = ZigClangConditionalOperator_getCond(stmt); |
| 1450 | const ZigClangExpr *true_expr = bitcast(stmt->getTrueExpr()); | 1456 | const ZigClangExpr *true_expr = ZigClangConditionalOperator_getTrueExpr(stmt); |
| 1451 | const ZigClangExpr *false_expr = bitcast(stmt->getFalseExpr()); | 1457 | const ZigClangExpr *false_expr = ZigClangConditionalOperator_getFalseExpr(stmt); |
| 1452 | | 1458 | |
| 1453 | node->data.if_bool_expr.condition = trans_expr(c, ResultUsedYes, scope, cond_expr, TransRValue); | 1459 | node->data.if_bool_expr.condition = trans_expr(c, ResultUsedYes, scope, cond_expr, TransRValue); |
| 1454 | if (node->data.if_bool_expr.condition == nullptr) | 1460 | if (node->data.if_bool_expr.condition == nullptr) |
| ... | @@ -1570,133 +1576,135 @@ static AstNode *trans_create_shift_op(Context *c, TransScope *scope, ZigClangQua | ... | @@ -1570,133 +1576,135 @@ static AstNode *trans_create_shift_op(Context *c, TransScope *scope, ZigClangQua |
| 1570 | return trans_create_node_bin_op(c, lhs, bin_op, coerced_rhs); | 1576 | return trans_create_node_bin_op(c, lhs, bin_op, coerced_rhs); |
| 1571 | } | 1577 | } |
| 1572 | | 1578 | |
| 1573 | static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransScope *scope, const clang::BinaryOperator *stmt) { | 1579 | static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransScope *scope, |
| 1574 | switch (stmt->getOpcode()) { | 1580 | const ZigClangBinaryOperator *stmt) |
| 1575 | case clang::BO_PtrMemD: | 1581 | { |
| 1576 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C binary operators: BO_PtrMemD"); | 1582 | switch (ZigClangBinaryOperator_getOpcode(stmt)) { |
| | 1583 | case ZigClangBO_PtrMemD: |
| | 1584 | emit_warning(c, ZigClangBinaryOperator_getBeginLoc(stmt), "TODO handle more C binary operators: BO_PtrMemD"); |
| 1577 | return nullptr; | 1585 | return nullptr; |
| 1578 | case clang::BO_PtrMemI: | 1586 | case ZigClangBO_PtrMemI: |
| 1579 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C binary operators: BO_PtrMemI"); | 1587 | emit_warning(c, ZigClangBinaryOperator_getBeginLoc(stmt), "TODO handle more C binary operators: BO_PtrMemI"); |
| 1580 | return nullptr; | 1588 | return nullptr; |
| 1581 | case clang::BO_Cmp: | 1589 | case ZigClangBO_Cmp: |
| 1582 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C binary operators: BO_Cmp"); | 1590 | emit_warning(c, ZigClangBinaryOperator_getBeginLoc(stmt), "TODO handle more C binary operators: BO_Cmp"); |
| 1583 | return nullptr; | 1591 | return nullptr; |
| 1584 | case clang::BO_Mul: { | 1592 | case ZigClangBO_Mul: { |
| 1585 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), | 1593 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), |
| 1586 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeMultWrap : BinOpTypeMult, | 1594 | qual_type_has_wrapping_overflow(c, ZigClangBinaryOperator_getType(stmt)) ? BinOpTypeMultWrap : BinOpTypeMult, |
| 1587 | bitcast(stmt->getRHS())); | 1595 | ZigClangBinaryOperator_getRHS(stmt)); |
| 1588 | return maybe_suppress_result(c, result_used, node); | 1596 | return maybe_suppress_result(c, result_used, node); |
| 1589 | } | 1597 | } |
| 1590 | case clang::BO_Div: | 1598 | case ZigClangBO_Div: |
| 1591 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) { | 1599 | if (qual_type_has_wrapping_overflow(c, ZigClangBinaryOperator_getType(stmt))) { |
| 1592 | // unsigned/float division uses the operator | 1600 | // unsigned/float division uses the operator |
| 1593 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeDiv, bitcast(stmt->getRHS())); | 1601 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeDiv, ZigClangBinaryOperator_getRHS(stmt)); |
| 1594 | return maybe_suppress_result(c, result_used, node); | 1602 | return maybe_suppress_result(c, result_used, node); |
| 1595 | } else { | 1603 | } else { |
| 1596 | // signed integer division uses @divTrunc | 1604 | // signed integer division uses @divTrunc |
| 1597 | AstNode *fn_call = trans_create_node_builtin_fn_call_str(c, "divTrunc"); | 1605 | AstNode *fn_call = trans_create_node_builtin_fn_call_str(c, "divTrunc"); |
| 1598 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getLHS()), TransLValue); | 1606 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, ZigClangBinaryOperator_getLHS(stmt), TransLValue); |
| 1599 | if (lhs == nullptr) return nullptr; | 1607 | if (lhs == nullptr) return nullptr; |
| 1600 | fn_call->data.fn_call_expr.params.append(lhs); | 1608 | fn_call->data.fn_call_expr.params.append(lhs); |
| 1601 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getRHS()), TransLValue); | 1609 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, ZigClangBinaryOperator_getRHS(stmt), TransLValue); |
| 1602 | if (rhs == nullptr) return nullptr; | 1610 | if (rhs == nullptr) return nullptr; |
| 1603 | fn_call->data.fn_call_expr.params.append(rhs); | 1611 | fn_call->data.fn_call_expr.params.append(rhs); |
| 1604 | return maybe_suppress_result(c, result_used, fn_call); | 1612 | return maybe_suppress_result(c, result_used, fn_call); |
| 1605 | } | 1613 | } |
| 1606 | case clang::BO_Rem: | 1614 | case ZigClangBO_Rem: |
| 1607 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) { | 1615 | if (qual_type_has_wrapping_overflow(c, ZigClangBinaryOperator_getType(stmt))) { |
| 1608 | // unsigned/float division uses the operator | 1616 | // unsigned/float division uses the operator |
| 1609 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeMod, bitcast(stmt->getRHS())); | 1617 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeMod, ZigClangBinaryOperator_getRHS(stmt)); |
| 1610 | return maybe_suppress_result(c, result_used, node); | 1618 | return maybe_suppress_result(c, result_used, node); |
| 1611 | } else { | 1619 | } else { |
| 1612 | // signed integer division uses @rem | 1620 | // signed integer division uses @rem |
| 1613 | AstNode *fn_call = trans_create_node_builtin_fn_call_str(c, "rem"); | 1621 | AstNode *fn_call = trans_create_node_builtin_fn_call_str(c, "rem"); |
| 1614 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getLHS()), TransLValue); | 1622 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, ZigClangBinaryOperator_getLHS(stmt), TransLValue); |
| 1615 | if (lhs == nullptr) return nullptr; | 1623 | if (lhs == nullptr) return nullptr; |
| 1616 | fn_call->data.fn_call_expr.params.append(lhs); | 1624 | fn_call->data.fn_call_expr.params.append(lhs); |
| 1617 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getRHS()), TransLValue); | 1625 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, ZigClangBinaryOperator_getRHS(stmt), TransLValue); |
| 1618 | if (rhs == nullptr) return nullptr; | 1626 | if (rhs == nullptr) return nullptr; |
| 1619 | fn_call->data.fn_call_expr.params.append(rhs); | 1627 | fn_call->data.fn_call_expr.params.append(rhs); |
| 1620 | return maybe_suppress_result(c, result_used, fn_call); | 1628 | return maybe_suppress_result(c, result_used, fn_call); |
| 1621 | } | 1629 | } |
| 1622 | case clang::BO_Add: { | 1630 | case ZigClangBO_Add: { |
| 1623 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), | 1631 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), |
| 1624 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeAddWrap : BinOpTypeAdd, | 1632 | qual_type_has_wrapping_overflow(c, ZigClangBinaryOperator_getType(stmt)) ? BinOpTypeAddWrap : BinOpTypeAdd, |
| 1625 | bitcast(stmt->getRHS())); | 1633 | ZigClangBinaryOperator_getRHS(stmt)); |
| 1626 | return maybe_suppress_result(c, result_used, node); | 1634 | return maybe_suppress_result(c, result_used, node); |
| 1627 | } | 1635 | } |
| 1628 | case clang::BO_Sub: { | 1636 | case ZigClangBO_Sub: { |
| 1629 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), | 1637 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), |
| 1630 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeSubWrap : BinOpTypeSub, | 1638 | qual_type_has_wrapping_overflow(c, ZigClangBinaryOperator_getType(stmt)) ? BinOpTypeSubWrap : BinOpTypeSub, |
| 1631 | bitcast(stmt->getRHS())); | 1639 | ZigClangBinaryOperator_getRHS(stmt)); |
| 1632 | return maybe_suppress_result(c, result_used, node); | 1640 | return maybe_suppress_result(c, result_used, node); |
| 1633 | } | 1641 | } |
| 1634 | case clang::BO_Shl: { | 1642 | case ZigClangBO_Shl: { |
| 1635 | AstNode *node = trans_create_shift_op(c, scope, bitcast(stmt->getType()), bitcast(stmt->getLHS()), BinOpTypeBitShiftLeft, bitcast(stmt->getRHS())); | 1643 | AstNode *node = trans_create_shift_op(c, scope, ZigClangBinaryOperator_getType(stmt), ZigClangBinaryOperator_getLHS(stmt), BinOpTypeBitShiftLeft, ZigClangBinaryOperator_getRHS(stmt)); |
| 1636 | return maybe_suppress_result(c, result_used, node); | 1644 | return maybe_suppress_result(c, result_used, node); |
| 1637 | } | 1645 | } |
| 1638 | case clang::BO_Shr: { | 1646 | case ZigClangBO_Shr: { |
| 1639 | AstNode *node = trans_create_shift_op(c, scope, bitcast(stmt->getType()), bitcast(stmt->getLHS()), BinOpTypeBitShiftRight, bitcast(stmt->getRHS())); | 1647 | AstNode *node = trans_create_shift_op(c, scope, ZigClangBinaryOperator_getType(stmt), ZigClangBinaryOperator_getLHS(stmt), BinOpTypeBitShiftRight, ZigClangBinaryOperator_getRHS(stmt)); |
| 1640 | return maybe_suppress_result(c, result_used, node); | 1648 | return maybe_suppress_result(c, result_used, node); |
| 1641 | } | 1649 | } |
| 1642 | case clang::BO_LT: { | 1650 | case ZigClangBO_LT: { |
| 1643 | AstNode *node =trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpLessThan, bitcast(stmt->getRHS())); | 1651 | AstNode *node =trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeCmpLessThan, ZigClangBinaryOperator_getRHS(stmt)); |
| 1644 | return maybe_suppress_result(c, result_used, node); | 1652 | return maybe_suppress_result(c, result_used, node); |
| 1645 | } | 1653 | } |
| 1646 | case clang::BO_GT: { | 1654 | case ZigClangBO_GT: { |
| 1647 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpGreaterThan, bitcast(stmt->getRHS())); | 1655 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeCmpGreaterThan, ZigClangBinaryOperator_getRHS(stmt)); |
| 1648 | return maybe_suppress_result(c, result_used, node); | 1656 | return maybe_suppress_result(c, result_used, node); |
| 1649 | } | 1657 | } |
| 1650 | case clang::BO_LE: { | 1658 | case ZigClangBO_LE: { |
| 1651 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpLessOrEq, bitcast(stmt->getRHS())); | 1659 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeCmpLessOrEq, ZigClangBinaryOperator_getRHS(stmt)); |
| 1652 | return maybe_suppress_result(c, result_used, node); | 1660 | return maybe_suppress_result(c, result_used, node); |
| 1653 | } | 1661 | } |
| 1654 | case clang::BO_GE: { | 1662 | case ZigClangBO_GE: { |
| 1655 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpGreaterOrEq, bitcast(stmt->getRHS())); | 1663 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeCmpGreaterOrEq, ZigClangBinaryOperator_getRHS(stmt)); |
| 1656 | return maybe_suppress_result(c, result_used, node); | 1664 | return maybe_suppress_result(c, result_used, node); |
| 1657 | } | 1665 | } |
| 1658 | case clang::BO_EQ: { | 1666 | case ZigClangBO_EQ: { |
| 1659 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpEq, bitcast(stmt->getRHS())); | 1667 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeCmpEq, ZigClangBinaryOperator_getRHS(stmt)); |
| 1660 | return maybe_suppress_result(c, result_used, node); | 1668 | return maybe_suppress_result(c, result_used, node); |
| 1661 | } | 1669 | } |
| 1662 | case clang::BO_NE: { | 1670 | case ZigClangBO_NE: { |
| 1663 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpNotEq, bitcast(stmt->getRHS())); | 1671 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeCmpNotEq, ZigClangBinaryOperator_getRHS(stmt)); |
| 1664 | return maybe_suppress_result(c, result_used, node); | 1672 | return maybe_suppress_result(c, result_used, node); |
| 1665 | } | 1673 | } |
| 1666 | case clang::BO_And: { | 1674 | case ZigClangBO_And: { |
| 1667 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBinAnd, bitcast(stmt->getRHS())); | 1675 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeBinAnd, ZigClangBinaryOperator_getRHS(stmt)); |
| 1668 | return maybe_suppress_result(c, result_used, node); | 1676 | return maybe_suppress_result(c, result_used, node); |
| 1669 | } | 1677 | } |
| 1670 | case clang::BO_Xor: { | 1678 | case ZigClangBO_Xor: { |
| 1671 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBinXor, bitcast(stmt->getRHS())); | 1679 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeBinXor, ZigClangBinaryOperator_getRHS(stmt)); |
| 1672 | return maybe_suppress_result(c, result_used, node); | 1680 | return maybe_suppress_result(c, result_used, node); |
| 1673 | } | 1681 | } |
| 1674 | case clang::BO_Or: { | 1682 | case ZigClangBO_Or: { |
| 1675 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBinOr, bitcast(stmt->getRHS())); | 1683 | AstNode *node = trans_create_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeBinOr, ZigClangBinaryOperator_getRHS(stmt)); |
| 1676 | return maybe_suppress_result(c, result_used, node); | 1684 | return maybe_suppress_result(c, result_used, node); |
| 1677 | } | 1685 | } |
| 1678 | case clang::BO_LAnd: { | 1686 | case ZigClangBO_LAnd: { |
| 1679 | AstNode *node = trans_create_bool_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBoolAnd, bitcast(stmt->getRHS())); | 1687 | AstNode *node = trans_create_bool_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeBoolAnd, ZigClangBinaryOperator_getRHS(stmt)); |
| 1680 | return maybe_suppress_result(c, result_used, node); | 1688 | return maybe_suppress_result(c, result_used, node); |
| 1681 | } | 1689 | } |
| 1682 | case clang::BO_LOr: { | 1690 | case ZigClangBO_LOr: { |
| 1683 | AstNode *node = trans_create_bool_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBoolOr, bitcast(stmt->getRHS())); | 1691 | AstNode *node = trans_create_bool_bin_op(c, scope, ZigClangBinaryOperator_getLHS(stmt), BinOpTypeBoolOr, ZigClangBinaryOperator_getRHS(stmt)); |
| 1684 | return maybe_suppress_result(c, result_used, node); | 1692 | return maybe_suppress_result(c, result_used, node); |
| 1685 | } | 1693 | } |
| 1686 | case clang::BO_Assign: | 1694 | case ZigClangBO_Assign: |
| 1687 | return trans_create_assign(c, result_used, scope, bitcast(stmt->getLHS()), bitcast(stmt->getRHS())); | 1695 | return trans_create_assign(c, result_used, scope, ZigClangBinaryOperator_getLHS(stmt), ZigClangBinaryOperator_getRHS(stmt)); |
| 1688 | case clang::BO_Comma: | 1696 | case ZigClangBO_Comma: |
| 1689 | { | 1697 | { |
| 1690 | TransScopeBlock *scope_block = trans_scope_block_create(c, scope); | 1698 | TransScopeBlock *scope_block = trans_scope_block_create(c, scope); |
| 1691 | Buf *label_name = buf_create_from_str("x"); | 1699 | Buf *label_name = buf_create_from_str("x"); |
| 1692 | scope_block->node->data.block.name = label_name; | 1700 | scope_block->node->data.block.name = label_name; |
| 1693 | | 1701 | |
| 1694 | AstNode *lhs = trans_expr(c, ResultUsedNo, &scope_block->base, bitcast(stmt->getLHS()), TransRValue); | 1702 | AstNode *lhs = trans_expr(c, ResultUsedNo, &scope_block->base, ZigClangBinaryOperator_getLHS(stmt), TransRValue); |
| 1695 | if (lhs == nullptr) | 1703 | if (lhs == nullptr) |
| 1696 | return nullptr; | 1704 | return nullptr; |
| 1697 | scope_block->node->data.block.statements.append(lhs); | 1705 | scope_block->node->data.block.statements.append(lhs); |
| 1698 | | 1706 | |
| 1699 | AstNode *rhs = trans_expr(c, ResultUsedYes, &scope_block->base, bitcast(stmt->getRHS()), TransRValue); | 1707 | AstNode *rhs = trans_expr(c, ResultUsedYes, &scope_block->base, ZigClangBinaryOperator_getRHS(stmt), TransRValue); |
| 1700 | if (rhs == nullptr) | 1708 | if (rhs == nullptr) |
| 1701 | return nullptr; | 1709 | return nullptr; |
| 1702 | | 1710 | |
| ... | @@ -1704,16 +1712,16 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS | ... | @@ -1704,16 +1712,16 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS |
| 1704 | scope_block->node->data.block.statements.append(rhs); | 1712 | scope_block->node->data.block.statements.append(rhs); |
| 1705 | return maybe_suppress_result(c, result_used, scope_block->node); | 1713 | return maybe_suppress_result(c, result_used, scope_block->node); |
| 1706 | } | 1714 | } |
| 1707 | case clang::BO_MulAssign: | 1715 | case ZigClangBO_MulAssign: |
| 1708 | case clang::BO_DivAssign: | 1716 | case ZigClangBO_DivAssign: |
| 1709 | case clang::BO_RemAssign: | 1717 | case ZigClangBO_RemAssign: |
| 1710 | case clang::BO_AddAssign: | 1718 | case ZigClangBO_AddAssign: |
| 1711 | case clang::BO_SubAssign: | 1719 | case ZigClangBO_SubAssign: |
| 1712 | case clang::BO_ShlAssign: | 1720 | case ZigClangBO_ShlAssign: |
| 1713 | case clang::BO_ShrAssign: | 1721 | case ZigClangBO_ShrAssign: |
| 1714 | case clang::BO_AndAssign: | 1722 | case ZigClangBO_AndAssign: |
| 1715 | case clang::BO_XorAssign: | 1723 | case ZigClangBO_XorAssign: |
| 1716 | case clang::BO_OrAssign: | 1724 | case ZigClangBO_OrAssign: |
| 1717 | zig_unreachable(); | 1725 | zig_unreachable(); |
| 1718 | } | 1726 | } |
| 1719 | | 1727 | |
| ... | @@ -1721,19 +1729,22 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS | ... | @@ -1721,19 +1729,22 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS |
| 1721 | } | 1729 | } |
| 1722 | | 1730 | |
| 1723 | static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result_used, TransScope *scope, | 1731 | static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result_used, TransScope *scope, |
| 1724 | const clang::CompoundAssignOperator *stmt, BinOpType assign_op, BinOpType bin_op) | 1732 | const ZigClangCompoundAssignOperator *stmt, BinOpType assign_op, BinOpType bin_op) |
| 1725 | { | 1733 | { |
| 1726 | ZigClangSourceLocation rhs_location = bitcast(stmt->getRHS()->getBeginLoc()); | 1734 | ZigClangSourceLocation rhs_location = ZigClangExpr_getBeginLoc(ZigClangCompoundAssignOperator_getRHS(stmt)); |
| 1727 | AstNode *rhs_type = qual_type_to_log2_int_ref(c, bitcast(stmt->getComputationLHSType()), rhs_location); | 1735 | ZigClangQualType computation_lhs_type = ZigClangCompoundAssignOperator_getComputationLHSType(stmt); |
| | 1736 | AstNode *rhs_type = qual_type_to_log2_int_ref(c, computation_lhs_type, rhs_location); |
| | 1737 | ZigClangQualType computation_result_type = ZigClangCompoundAssignOperator_getComputationResultType(stmt); |
| 1728 | | 1738 | |
| 1729 | bool use_intermediate_casts = stmt->getComputationLHSType().getTypePtr() != stmt->getComputationResultType().getTypePtr(); | 1739 | bool use_intermediate_casts = ZigClangQualType_getTypePtr(computation_lhs_type) != |
| | 1740 | ZigClangQualType_getTypePtr(computation_result_type); |
| 1730 | if (!use_intermediate_casts && result_used == ResultUsedNo) { | 1741 | if (!use_intermediate_casts && result_used == ResultUsedNo) { |
| 1731 | // simple common case, where the C and Zig are identical: | 1742 | // simple common case, where the C and Zig are identical: |
| 1732 | // lhs >>= rhs | 1743 | // lhs >>= rhs |
| 1733 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getLHS()), TransLValue); | 1744 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, ZigClangCompoundAssignOperator_getLHS(stmt), TransLValue); |
| 1734 | if (lhs == nullptr) return nullptr; | 1745 | if (lhs == nullptr) return nullptr; |
| 1735 | | 1746 | |
| 1736 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getRHS()), TransRValue); | 1747 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, ZigClangCompoundAssignOperator_getRHS(stmt), TransRValue); |
| 1737 | if (rhs == nullptr) return nullptr; | 1748 | if (rhs == nullptr) return nullptr; |
| 1738 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); | 1749 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); |
| 1739 | | 1750 | |
| ... | @@ -1753,7 +1764,8 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result | ... | @@ -1753,7 +1764,8 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result |
| 1753 | child_scope->node->data.block.name = label_name; | 1764 | child_scope->node->data.block.name = label_name; |
| 1754 | | 1765 | |
| 1755 | // const _ref = &lhs; | 1766 | // const _ref = &lhs; |
| 1756 | AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, bitcast(stmt->getLHS()), TransLValue); | 1767 | AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, |
| | 1768 | ZigClangCompoundAssignOperator_getLHS(stmt), TransLValue); |
| 1757 | if (lhs == nullptr) return nullptr; | 1769 | if (lhs == nullptr) return nullptr; |
| 1758 | AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs); | 1770 | AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs); |
| 1759 | // TODO: avoid name collisions with generated variable names | 1771 | // TODO: avoid name collisions with generated variable names |
| ... | @@ -1763,20 +1775,20 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result | ... | @@ -1763,20 +1775,20 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result |
| 1763 | | 1775 | |
| 1764 | // *_ref = result_type(operation_type(*_ref) >> u5(rhs)); | 1776 | // *_ref = result_type(operation_type(*_ref) >> u5(rhs)); |
| 1765 | | 1777 | |
| 1766 | AstNode *rhs = trans_expr(c, ResultUsedYes, &child_scope->base, bitcast(stmt->getRHS()), TransRValue); | 1778 | AstNode *rhs = trans_expr(c, ResultUsedYes, &child_scope->base, ZigClangCompoundAssignOperator_getRHS(stmt), TransRValue); |
| 1767 | if (rhs == nullptr) return nullptr; | 1779 | if (rhs == nullptr) return nullptr; |
| 1768 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); | 1780 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); |
| 1769 | | 1781 | |
| 1770 | // operation_type(*_ref) | 1782 | // operation_type(*_ref) |
| 1771 | AstNode *operation_type_cast = trans_c_cast(c, rhs_location, | 1783 | AstNode *operation_type_cast = trans_c_cast(c, rhs_location, |
| 1772 | bitcast(stmt->getComputationLHSType()), | 1784 | computation_lhs_type, |
| 1773 | bitcast(stmt->getLHS()->getType()), | 1785 | ZigClangExpr_getType(ZigClangCompoundAssignOperator_getLHS(stmt)), |
| 1774 | trans_create_node_ptr_deref(c, trans_create_node_symbol(c, tmp_var_name))); | 1786 | trans_create_node_ptr_deref(c, trans_create_node_symbol(c, tmp_var_name))); |
| 1775 | | 1787 | |
| 1776 | // result_type(... >> u5(rhs)) | 1788 | // result_type(... >> u5(rhs)) |
| 1777 | AstNode *result_type_cast = trans_c_cast(c, rhs_location, | 1789 | AstNode *result_type_cast = trans_c_cast(c, rhs_location, |
| 1778 | bitcast(stmt->getComputationResultType()), | 1790 | computation_result_type, |
| 1779 | bitcast(stmt->getComputationLHSType()), | 1791 | computation_lhs_type, |
| 1780 | trans_create_node_bin_op(c, | 1792 | trans_create_node_bin_op(c, |
| 1781 | operation_type_cast, | 1793 | operation_type_cast, |
| 1782 | bin_op, | 1794 | bin_op, |
| ... | @@ -1803,14 +1815,14 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result | ... | @@ -1803,14 +1815,14 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result |
| 1803 | } | 1815 | } |
| 1804 | | 1816 | |
| 1805 | static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, TransScope *scope, | 1817 | static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, TransScope *scope, |
| 1806 | const clang::CompoundAssignOperator *stmt, BinOpType assign_op, BinOpType bin_op) | 1818 | const ZigClangCompoundAssignOperator *stmt, BinOpType assign_op, BinOpType bin_op) |
| 1807 | { | 1819 | { |
| 1808 | if (result_used == ResultUsedNo) { | 1820 | if (result_used == ResultUsedNo) { |
| 1809 | // simple common case, where the C and Zig are identical: | 1821 | // simple common case, where the C and Zig are identical: |
| 1810 | // lhs += rhs | 1822 | // lhs += rhs |
| 1811 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getLHS()), TransLValue); | 1823 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, ZigClangCompoundAssignOperator_getLHS(stmt), TransLValue); |
| 1812 | if (lhs == nullptr) return nullptr; | 1824 | if (lhs == nullptr) return nullptr; |
| 1813 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getRHS()), TransRValue); | 1825 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, ZigClangCompoundAssignOperator_getRHS(stmt), TransRValue); |
| 1814 | if (rhs == nullptr) return nullptr; | 1826 | if (rhs == nullptr) return nullptr; |
| 1815 | return trans_create_node_bin_op(c, lhs, assign_op, rhs); | 1827 | return trans_create_node_bin_op(c, lhs, assign_op, rhs); |
| 1816 | } else { | 1828 | } else { |
| ... | @@ -1827,7 +1839,8 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, | ... | @@ -1827,7 +1839,8 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, |
| 1827 | child_scope->node->data.block.name = label_name; | 1839 | child_scope->node->data.block.name = label_name; |
| 1828 | | 1840 | |
| 1829 | // const _ref = &lhs; | 1841 | // const _ref = &lhs; |
| 1830 | AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, bitcast(stmt->getLHS()), TransLValue); | 1842 | AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, |
| | 1843 | ZigClangCompoundAssignOperator_getLHS(stmt), TransLValue); |
| 1831 | if (lhs == nullptr) return nullptr; | 1844 | if (lhs == nullptr) return nullptr; |
| 1832 | AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs); | 1845 | AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs); |
| 1833 | // TODO: avoid name collisions with generated variable names | 1846 | // TODO: avoid name collisions with generated variable names |
| ... | @@ -1837,7 +1850,8 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, | ... | @@ -1837,7 +1850,8 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, |
| 1837 | | 1850 | |
| 1838 | // *_ref = *_ref + rhs; | 1851 | // *_ref = *_ref + rhs; |
| 1839 | | 1852 | |
| 1840 | AstNode *rhs = trans_expr(c, ResultUsedYes, &child_scope->base, bitcast(stmt->getRHS()), TransRValue); | 1853 | AstNode *rhs = trans_expr(c, ResultUsedYes, &child_scope->base, |
| | 1854 | ZigClangCompoundAssignOperator_getRHS(stmt), TransRValue); |
| 1841 | if (rhs == nullptr) return nullptr; | 1855 | if (rhs == nullptr) return nullptr; |
| 1842 | | 1856 | |
| 1843 | AstNode *assign_statement = trans_create_node_bin_op(c, | 1857 | AstNode *assign_statement = trans_create_node_bin_op(c, |
| ... | @@ -1863,65 +1877,65 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, | ... | @@ -1863,65 +1877,65 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, |
| 1863 | | 1877 | |
| 1864 | | 1878 | |
| 1865 | static AstNode *trans_compound_assign_operator(Context *c, ResultUsed result_used, TransScope *scope, | 1879 | static AstNode *trans_compound_assign_operator(Context *c, ResultUsed result_used, TransScope *scope, |
| 1866 | const clang::CompoundAssignOperator *stmt) | 1880 | const ZigClangCompoundAssignOperator *stmt) |
| 1867 | { | 1881 | { |
| 1868 | switch (stmt->getOpcode()) { | 1882 | switch (ZigClangCompoundAssignOperator_getOpcode(stmt)) { |
| 1869 | case clang::BO_MulAssign: | 1883 | case ZigClangBO_MulAssign: |
| 1870 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) | 1884 | if (qual_type_has_wrapping_overflow(c, ZigClangCompoundAssignOperator_getType(stmt))) |
| 1871 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignTimesWrap, BinOpTypeMultWrap); | 1885 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignTimesWrap, BinOpTypeMultWrap); |
| 1872 | else | 1886 | else |
| 1873 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignTimes, BinOpTypeMult); | 1887 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignTimes, BinOpTypeMult); |
| 1874 | case clang::BO_DivAssign: | 1888 | case ZigClangBO_DivAssign: |
| 1875 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C compound assign operators: BO_DivAssign"); | 1889 | emit_warning(c, ZigClangCompoundAssignOperator_getBeginLoc(stmt), "TODO handle more C compound assign operators: BO_DivAssign"); |
| 1876 | return nullptr; | 1890 | return nullptr; |
| 1877 | case clang::BO_RemAssign: | 1891 | case ZigClangBO_RemAssign: |
| 1878 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C compound assign operators: BO_RemAssign"); | 1892 | emit_warning(c, ZigClangCompoundAssignOperator_getBeginLoc(stmt), "TODO handle more C compound assign operators: BO_RemAssign"); |
| 1879 | return nullptr; | 1893 | return nullptr; |
| 1880 | case clang::BO_Cmp: | 1894 | case ZigClangBO_Cmp: |
| 1881 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C compound assign operators: BO_Cmp"); | 1895 | emit_warning(c, ZigClangCompoundAssignOperator_getBeginLoc(stmt), "TODO handle more C compound assign operators: BO_Cmp"); |
| 1882 | return nullptr; | 1896 | return nullptr; |
| 1883 | case clang::BO_AddAssign: | 1897 | case ZigClangBO_AddAssign: |
| 1884 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) | 1898 | if (qual_type_has_wrapping_overflow(c, ZigClangCompoundAssignOperator_getType(stmt))) |
| 1885 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap, BinOpTypeAddWrap); | 1899 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap, BinOpTypeAddWrap); |
| 1886 | else | 1900 | else |
| 1887 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignPlus, BinOpTypeAdd); | 1901 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignPlus, BinOpTypeAdd); |
| 1888 | case clang::BO_SubAssign: | 1902 | case ZigClangBO_SubAssign: |
| 1889 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) | 1903 | if (qual_type_has_wrapping_overflow(c, ZigClangCompoundAssignOperator_getType(stmt))) |
| 1890 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap, BinOpTypeSubWrap); | 1904 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap, BinOpTypeSubWrap); |
| 1891 | else | 1905 | else |
| 1892 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignMinus, BinOpTypeSub); | 1906 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignMinus, BinOpTypeSub); |
| 1893 | case clang::BO_ShlAssign: | 1907 | case ZigClangBO_ShlAssign: |
| 1894 | return trans_create_compound_assign_shift(c, result_used, scope, stmt, BinOpTypeAssignBitShiftLeft, BinOpTypeBitShiftLeft); | 1908 | return trans_create_compound_assign_shift(c, result_used, scope, stmt, BinOpTypeAssignBitShiftLeft, BinOpTypeBitShiftLeft); |
| 1895 | case clang::BO_ShrAssign: | 1909 | case ZigClangBO_ShrAssign: |
| 1896 | return trans_create_compound_assign_shift(c, result_used, scope, stmt, BinOpTypeAssignBitShiftRight, BinOpTypeBitShiftRight); | 1910 | return trans_create_compound_assign_shift(c, result_used, scope, stmt, BinOpTypeAssignBitShiftRight, BinOpTypeBitShiftRight); |
| 1897 | case clang::BO_AndAssign: | 1911 | case ZigClangBO_AndAssign: |
| 1898 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignBitAnd, BinOpTypeBinAnd); | 1912 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignBitAnd, BinOpTypeBinAnd); |
| 1899 | case clang::BO_XorAssign: | 1913 | case ZigClangBO_XorAssign: |
| 1900 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignBitXor, BinOpTypeBinXor); | 1914 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignBitXor, BinOpTypeBinXor); |
| 1901 | case clang::BO_OrAssign: | 1915 | case ZigClangBO_OrAssign: |
| 1902 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignBitOr, BinOpTypeBinOr); | 1916 | return trans_create_compound_assign(c, result_used, scope, stmt, BinOpTypeAssignBitOr, BinOpTypeBinOr); |
| 1903 | case clang::BO_PtrMemD: | 1917 | case ZigClangBO_PtrMemD: |
| 1904 | case clang::BO_PtrMemI: | 1918 | case ZigClangBO_PtrMemI: |
| 1905 | case clang::BO_Assign: | 1919 | case ZigClangBO_Assign: |
| 1906 | case clang::BO_Mul: | 1920 | case ZigClangBO_Mul: |
| 1907 | case clang::BO_Div: | 1921 | case ZigClangBO_Div: |
| 1908 | case clang::BO_Rem: | 1922 | case ZigClangBO_Rem: |
| 1909 | case clang::BO_Add: | 1923 | case ZigClangBO_Add: |
| 1910 | case clang::BO_Sub: | 1924 | case ZigClangBO_Sub: |
| 1911 | case clang::BO_Shl: | 1925 | case ZigClangBO_Shl: |
| 1912 | case clang::BO_Shr: | 1926 | case ZigClangBO_Shr: |
| 1913 | case clang::BO_LT: | 1927 | case ZigClangBO_LT: |
| 1914 | case clang::BO_GT: | 1928 | case ZigClangBO_GT: |
| 1915 | case clang::BO_LE: | 1929 | case ZigClangBO_LE: |
| 1916 | case clang::BO_GE: | 1930 | case ZigClangBO_GE: |
| 1917 | case clang::BO_EQ: | 1931 | case ZigClangBO_EQ: |
| 1918 | case clang::BO_NE: | 1932 | case ZigClangBO_NE: |
| 1919 | case clang::BO_And: | 1933 | case ZigClangBO_And: |
| 1920 | case clang::BO_Xor: | 1934 | case ZigClangBO_Xor: |
| 1921 | case clang::BO_Or: | 1935 | case ZigClangBO_Or: |
| 1922 | case clang::BO_LAnd: | 1936 | case ZigClangBO_LAnd: |
| 1923 | case clang::BO_LOr: | 1937 | case ZigClangBO_LOr: |
| 1924 | case clang::BO_Comma: | 1938 | case ZigClangBO_Comma: |
| 1925 | zig_unreachable(); | 1939 | zig_unreachable(); |
| 1926 | } | 1940 | } |
| 1927 | | 1941 | |
| ... | @@ -2207,8 +2221,8 @@ static AstNode *trans_implicit_cast_expr(Context *c, ResultUsed result_used, Tra | ... | @@ -2207,8 +2221,8 @@ static AstNode *trans_implicit_cast_expr(Context *c, ResultUsed result_used, Tra |
| 2207 | zig_unreachable(); | 2221 | zig_unreachable(); |
| 2208 | } | 2222 | } |
| 2209 | | 2223 | |
| 2210 | static AstNode *trans_decl_ref_expr(Context *c, TransScope *scope, const clang::DeclRefExpr *stmt, TransLRValue lrval) { | 2224 | static AstNode *trans_decl_ref_expr(Context *c, TransScope *scope, const ZigClangDeclRefExpr *stmt, TransLRValue lrval) { |
| 2211 | const clang::ValueDecl *value_decl = stmt->getDecl(); | 2225 | const ZigClangValueDecl *value_decl = ZigClangDeclRefExpr_getDecl(stmt); |
| 2212 | Buf *c_symbol_name = buf_create_from_str(ZigClangDecl_getName_bytes_begin((const ZigClangDecl *)value_decl)); | 2226 | Buf *c_symbol_name = buf_create_from_str(ZigClangDecl_getName_bytes_begin((const ZigClangDecl *)value_decl)); |
| 2213 | Buf *zig_symbol_name = trans_lookup_zig_symbol(c, scope, c_symbol_name); | 2227 | Buf *zig_symbol_name = trans_lookup_zig_symbol(c, scope, c_symbol_name); |
| 2214 | if (lrval == TransLValue) { | 2228 | if (lrval == TransLValue) { |
| ... | @@ -2218,9 +2232,9 @@ static AstNode *trans_decl_ref_expr(Context *c, TransScope *scope, const clang:: | ... | @@ -2218,9 +2232,9 @@ static AstNode *trans_decl_ref_expr(Context *c, TransScope *scope, const clang:: |
| 2218 | } | 2232 | } |
| 2219 | | 2233 | |
| 2220 | static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, TransScope *scope, | 2234 | static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, TransScope *scope, |
| 2221 | const clang::UnaryOperator *stmt, BinOpType assign_op) | 2235 | const ZigClangUnaryOperator *stmt, BinOpType assign_op) |
| 2222 | { | 2236 | { |
| 2223 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); | 2237 | const ZigClangExpr *op_expr = ZigClangUnaryOperator_getSubExpr(stmt); |
| 2224 | | 2238 | |
| 2225 | if (result_used == ResultUsedNo) { | 2239 | if (result_used == ResultUsedNo) { |
| 2226 | // common case | 2240 | // common case |
| ... | @@ -2274,9 +2288,9 @@ static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, Tr | ... | @@ -2274,9 +2288,9 @@ static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, Tr |
| 2274 | } | 2288 | } |
| 2275 | | 2289 | |
| 2276 | static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, TransScope *scope, | 2290 | static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, TransScope *scope, |
| 2277 | const clang::UnaryOperator *stmt, BinOpType assign_op) | 2291 | const ZigClangUnaryOperator *stmt, BinOpType assign_op) |
| 2278 | { | 2292 | { |
| 2279 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); | 2293 | const ZigClangExpr *op_expr = ZigClangUnaryOperator_getSubExpr(stmt); |
| 2280 | | 2294 | |
| 2281 | if (result_used == ResultUsedNo) { | 2295 | if (result_used == ResultUsedNo) { |
| 2282 | // common case | 2296 | // common case |
| ... | @@ -2323,52 +2337,54 @@ static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, Tra | ... | @@ -2323,52 +2337,54 @@ static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, Tra |
| 2323 | return trans_create_node_grouped_expr(c, child_scope->node); | 2337 | return trans_create_node_grouped_expr(c, child_scope->node); |
| 2324 | } | 2338 | } |
| 2325 | | 2339 | |
| 2326 | static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransScope *scope, const clang::UnaryOperator *stmt) { | 2340 | static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransScope *scope, |
| 2327 | switch (stmt->getOpcode()) { | 2341 | const ZigClangUnaryOperator *stmt) |
| 2328 | case clang::UO_PostInc: | 2342 | { |
| 2329 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) | 2343 | switch (ZigClangUnaryOperator_getOpcode(stmt)) { |
| | 2344 | case ZigClangUO_PostInc: |
| | 2345 | if (qual_type_has_wrapping_overflow(c, ZigClangUnaryOperator_getType(stmt))) |
| 2330 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap); | 2346 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap); |
| 2331 | else | 2347 | else |
| 2332 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignPlus); | 2348 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignPlus); |
| 2333 | case clang::UO_PostDec: | 2349 | case ZigClangUO_PostDec: |
| 2334 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) | 2350 | if (qual_type_has_wrapping_overflow(c, ZigClangUnaryOperator_getType(stmt))) |
| 2335 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap); | 2351 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap); |
| 2336 | else | 2352 | else |
| 2337 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); | 2353 | return trans_create_post_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); |
| 2338 | case clang::UO_PreInc: | 2354 | case ZigClangUO_PreInc: |
| 2339 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) | 2355 | if (qual_type_has_wrapping_overflow(c, ZigClangUnaryOperator_getType(stmt))) |
| 2340 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap); | 2356 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignPlusWrap); |
| 2341 | else | 2357 | else |
| 2342 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignPlus); | 2358 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignPlus); |
| 2343 | case clang::UO_PreDec: | 2359 | case ZigClangUO_PreDec: |
| 2344 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) | 2360 | if (qual_type_has_wrapping_overflow(c, ZigClangUnaryOperator_getType(stmt))) |
| 2345 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap); | 2361 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinusWrap); |
| 2346 | else | 2362 | else |
| 2347 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); | 2363 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); |
| 2348 | case clang::UO_AddrOf: | 2364 | case ZigClangUO_AddrOf: |
| 2349 | { | 2365 | { |
| 2350 | AstNode *value_node = trans_expr(c, result_used, scope, bitcast(stmt->getSubExpr()), TransLValue); | 2366 | AstNode *value_node = trans_expr(c, result_used, scope, ZigClangUnaryOperator_getSubExpr(stmt), TransLValue); |
| 2351 | if (value_node == nullptr) | 2367 | if (value_node == nullptr) |
| 2352 | return value_node; | 2368 | return value_node; |
| 2353 | return trans_create_node_addr_of(c, value_node); | 2369 | return trans_create_node_addr_of(c, value_node); |
| 2354 | } | 2370 | } |
| 2355 | case clang::UO_Deref: | 2371 | case ZigClangUO_Deref: |
| 2356 | { | 2372 | { |
| 2357 | AstNode *value_node = trans_expr(c, result_used, scope, bitcast(stmt->getSubExpr()), TransRValue); | 2373 | AstNode *value_node = trans_expr(c, result_used, scope, ZigClangUnaryOperator_getSubExpr(stmt), TransRValue); |
| 2358 | if (value_node == nullptr) | 2374 | if (value_node == nullptr) |
| 2359 | return nullptr; | 2375 | return nullptr; |
| 2360 | bool is_fn_ptr = qual_type_is_fn_ptr(bitcast(stmt->getSubExpr()->getType())); | 2376 | bool is_fn_ptr = qual_type_is_fn_ptr(ZigClangExpr_getType(ZigClangUnaryOperator_getSubExpr(stmt))); |
| 2361 | if (is_fn_ptr) | 2377 | if (is_fn_ptr) |
| 2362 | return value_node; | 2378 | return value_node; |
| 2363 | AstNode *unwrapped = trans_create_node_unwrap_null(c, value_node); | 2379 | AstNode *unwrapped = trans_create_node_unwrap_null(c, value_node); |
| 2364 | return trans_create_node_ptr_deref(c, unwrapped); | 2380 | return trans_create_node_ptr_deref(c, unwrapped); |
| 2365 | } | 2381 | } |
| 2366 | case clang::UO_Plus: | 2382 | case ZigClangUO_Plus: |
| 2367 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation UO_Plus"); | 2383 | emit_warning(c, ZigClangUnaryOperator_getBeginLoc(stmt), "TODO handle C translation UO_Plus"); |
| 2368 | return nullptr; | 2384 | return nullptr; |
| 2369 | case clang::UO_Minus: | 2385 | case ZigClangUO_Minus: |
| 2370 | { | 2386 | { |
| 2371 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); | 2387 | const ZigClangExpr *op_expr = ZigClangUnaryOperator_getSubExpr(stmt); |
| 2372 | if (!qual_type_has_wrapping_overflow(c, ZigClangExpr_getType(op_expr))) { | 2388 | if (!qual_type_has_wrapping_overflow(c, ZigClangExpr_getType(op_expr))) { |
| 2373 | AstNode *node = trans_create_node(c, NodeTypePrefixOpExpr); | 2389 | AstNode *node = trans_create_node(c, NodeTypePrefixOpExpr); |
| 2374 | node->data.prefix_op_expr.prefix_op = PrefixOpNegation; | 2390 | node->data.prefix_op_expr.prefix_op = PrefixOpNegation; |
| ... | @@ -2390,44 +2406,44 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2390,44 +2406,44 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2390 | node->data.bin_op_expr.bin_op = BinOpTypeSubWrap; | 2406 | node->data.bin_op_expr.bin_op = BinOpTypeSubWrap; |
| 2391 | return node; | 2407 | return node; |
| 2392 | } else { | 2408 | } else { |
| 2393 | emit_warning(c, bitcast(stmt->getBeginLoc()), "C negation with non float non integer"); | 2409 | emit_warning(c, ZigClangUnaryOperator_getBeginLoc(stmt), "C negation with non float non integer"); |
| 2394 | return nullptr; | 2410 | return nullptr; |
| 2395 | } | 2411 | } |
| 2396 | } | 2412 | } |
| 2397 | case clang::UO_Not: | 2413 | case ZigClangUO_Not: |
| 2398 | { | 2414 | { |
| 2399 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); | 2415 | const ZigClangExpr *op_expr = ZigClangUnaryOperator_getSubExpr(stmt); |
| 2400 | AstNode *sub_node = trans_expr(c, ResultUsedYes, scope, op_expr, TransRValue); | 2416 | AstNode *sub_node = trans_expr(c, ResultUsedYes, scope, op_expr, TransRValue); |
| 2401 | if (sub_node == nullptr) | 2417 | if (sub_node == nullptr) |
| 2402 | return nullptr; | 2418 | return nullptr; |
| 2403 | | 2419 | |
| 2404 | return trans_create_node_prefix_op(c, PrefixOpBinNot, sub_node); | 2420 | return trans_create_node_prefix_op(c, PrefixOpBinNot, sub_node); |
| 2405 | } | 2421 | } |
| 2406 | case clang::UO_LNot: | 2422 | case ZigClangUO_LNot: |
| 2407 | { | 2423 | { |
| 2408 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); | 2424 | const ZigClangExpr *op_expr = ZigClangUnaryOperator_getSubExpr(stmt); |
| 2409 | AstNode *sub_node = trans_bool_expr(c, ResultUsedYes, scope, op_expr, TransRValue); | 2425 | AstNode *sub_node = trans_bool_expr(c, ResultUsedYes, scope, op_expr, TransRValue); |
| 2410 | if (sub_node == nullptr) | 2426 | if (sub_node == nullptr) |
| 2411 | return nullptr; | 2427 | return nullptr; |
| 2412 | | 2428 | |
| 2413 | return trans_create_node_prefix_op(c, PrefixOpBoolNot, sub_node); | 2429 | return trans_create_node_prefix_op(c, PrefixOpBoolNot, sub_node); |
| 2414 | } | 2430 | } |
| 2415 | case clang::UO_Real: | 2431 | case ZigClangUO_Real: |
| 2416 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation UO_Real"); | 2432 | emit_warning(c, ZigClangUnaryOperator_getBeginLoc(stmt), "TODO handle C translation UO_Real"); |
| 2417 | return nullptr; | 2433 | return nullptr; |
| 2418 | case clang::UO_Imag: | 2434 | case ZigClangUO_Imag: |
| 2419 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation UO_Imag"); | 2435 | emit_warning(c, ZigClangUnaryOperator_getBeginLoc(stmt), "TODO handle C translation UO_Imag"); |
| 2420 | return nullptr; | 2436 | return nullptr; |
| 2421 | case clang::UO_Extension: | 2437 | case ZigClangUO_Extension: |
| 2422 | return trans_expr(c, result_used, scope, bitcast(stmt->getSubExpr()), TransLValue); | 2438 | return trans_expr(c, result_used, scope, ZigClangUnaryOperator_getSubExpr(stmt), TransLValue); |
| 2423 | case clang::UO_Coawait: | 2439 | case ZigClangUO_Coawait: |
| 2424 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation UO_Coawait"); | 2440 | emit_warning(c, ZigClangUnaryOperator_getBeginLoc(stmt), "TODO handle C translation UO_Coawait"); |
| 2425 | return nullptr; | 2441 | return nullptr; |
| 2426 | } | 2442 | } |
| 2427 | zig_unreachable(); | 2443 | zig_unreachable(); |
| 2428 | } | 2444 | } |
| 2429 | | 2445 | |
| 2430 | static int trans_local_declaration(Context *c, TransScope *scope, const clang::DeclStmt *stmt, | 2446 | static int trans_local_declaration(Context *c, TransScope *scope, const ZigClangDeclStmt *stmt, |
| 2431 | AstNode **out_node, TransScope **out_scope) | 2447 | AstNode **out_node, TransScope **out_scope) |
| 2432 | { | 2448 | { |
| 2433 | // declarations are added via the scope | 2449 | // declarations are added via the scope |
| ... | @@ -2436,10 +2452,11 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D | ... | @@ -2436,10 +2452,11 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D |
| 2436 | TransScopeBlock *scope_block = trans_scope_block_find(scope); | 2452 | TransScopeBlock *scope_block = trans_scope_block_find(scope); |
| 2437 | assert(scope_block != nullptr); | 2453 | assert(scope_block != nullptr); |
| 2438 | | 2454 | |
| 2439 | for (auto iter = stmt->decl_begin(); iter != stmt->decl_end(); iter++) { | 2455 | for (auto iter = reinterpret_cast<const clang::DeclStmt *>(stmt)->decl_begin(); |
| 2440 | clang::Decl *decl = *iter; | 2456 | iter != reinterpret_cast<const clang::DeclStmt *>(stmt)->decl_end(); iter++) { |
| 2441 | switch (decl->getKind()) { | 2457 | ZigClangDecl *decl = reinterpret_cast<ZigClangDecl *>(*iter); |
| 2442 | case clang::Decl::Var: { | 2458 | switch (ZigClangDecl_getKind(decl)) { |
| | 2459 | case ZigClangDeclVar: { |
| 2443 | clang::VarDecl *var_decl = (clang::VarDecl *)decl; | 2460 | clang::VarDecl *var_decl = (clang::VarDecl *)decl; |
| 2444 | ZigClangQualType qual_type = bitcast(var_decl->getTypeSourceInfo()->getType()); | 2461 | ZigClangQualType qual_type = bitcast(var_decl->getTypeSourceInfo()->getType()); |
| 2445 | AstNode *init_node = nullptr; | 2462 | AstNode *init_node = nullptr; |
| ... | @@ -2451,7 +2468,7 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D | ... | @@ -2451,7 +2468,7 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D |
| 2451 | } else { | 2468 | } else { |
| 2452 | init_node = trans_create_node(c, NodeTypeUndefinedLiteral); | 2469 | init_node = trans_create_node(c, NodeTypeUndefinedLiteral); |
| 2453 | } | 2470 | } |
| 2454 | AstNode *type_node = trans_qual_type(c, qual_type, bitcast(stmt->getBeginLoc())); | 2471 | AstNode *type_node = trans_qual_type(c, qual_type, ZigClangDeclStmt_getBeginLoc(stmt)); |
| 2455 | if (type_node == nullptr) | 2472 | if (type_node == nullptr) |
| 2456 | return ErrorUnexpected; | 2473 | return ErrorUnexpected; |
| 2457 | | 2474 | |
| ... | @@ -2467,233 +2484,233 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D | ... | @@ -2467,233 +2484,233 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D |
| 2467 | scope_block->node->data.block.statements.append(node); | 2484 | scope_block->node->data.block.statements.append(node); |
| 2468 | continue; | 2485 | continue; |
| 2469 | } | 2486 | } |
| 2470 | case clang::Decl::AccessSpec: | 2487 | case ZigClangDeclAccessSpec: |
| 2471 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle decl kind AccessSpec"); | 2488 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle decl kind AccessSpec"); |
| 2472 | return ErrorUnexpected; | 2489 | return ErrorUnexpected; |
| 2473 | case clang::Decl::Block: | 2490 | case ZigClangDeclBlock: |
| 2474 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Block"); | 2491 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Block"); |
| 2475 | return ErrorUnexpected; | 2492 | return ErrorUnexpected; |
| 2476 | case clang::Decl::Captured: | 2493 | case ZigClangDeclCaptured: |
| 2477 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Captured"); | 2494 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Captured"); |
| 2478 | return ErrorUnexpected; | 2495 | return ErrorUnexpected; |
| 2479 | case clang::Decl::ClassScopeFunctionSpecialization: | 2496 | case ZigClangDeclClassScopeFunctionSpecialization: |
| 2480 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ClassScopeFunctionSpecialization"); | 2497 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ClassScopeFunctionSpecialization"); |
| 2481 | return ErrorUnexpected; | 2498 | return ErrorUnexpected; |
| 2482 | case clang::Decl::Empty: | 2499 | case ZigClangDeclEmpty: |
| 2483 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Empty"); | 2500 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Empty"); |
| 2484 | return ErrorUnexpected; | 2501 | return ErrorUnexpected; |
| 2485 | case clang::Decl::Export: | 2502 | case ZigClangDeclExport: |
| 2486 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Export"); | 2503 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Export"); |
| 2487 | return ErrorUnexpected; | 2504 | return ErrorUnexpected; |
| 2488 | case clang::Decl::ExternCContext: | 2505 | case ZigClangDeclExternCContext: |
| 2489 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ExternCContext"); | 2506 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ExternCContext"); |
| 2490 | return ErrorUnexpected; | 2507 | return ErrorUnexpected; |
| 2491 | case clang::Decl::FileScopeAsm: | 2508 | case ZigClangDeclFileScopeAsm: |
| 2492 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C FileScopeAsm"); | 2509 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C FileScopeAsm"); |
| 2493 | return ErrorUnexpected; | 2510 | return ErrorUnexpected; |
| 2494 | case clang::Decl::Friend: | 2511 | case ZigClangDeclFriend: |
| 2495 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Friend"); | 2512 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Friend"); |
| 2496 | return ErrorUnexpected; | 2513 | return ErrorUnexpected; |
| 2497 | case clang::Decl::FriendTemplate: | 2514 | case ZigClangDeclFriendTemplate: |
| 2498 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C FriendTemplate"); | 2515 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C FriendTemplate"); |
| 2499 | return ErrorUnexpected; | 2516 | return ErrorUnexpected; |
| 2500 | case clang::Decl::Import: | 2517 | case ZigClangDeclImport: |
| 2501 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Import"); | 2518 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Import"); |
| 2502 | return ErrorUnexpected; | 2519 | return ErrorUnexpected; |
| 2503 | case clang::Decl::LinkageSpec: | 2520 | case ZigClangDeclLinkageSpec: |
| 2504 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C LinkageSpec"); | 2521 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C LinkageSpec"); |
| 2505 | return ErrorUnexpected; | 2522 | return ErrorUnexpected; |
| 2506 | case clang::Decl::Label: | 2523 | case ZigClangDeclLabel: |
| 2507 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Label"); | 2524 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Label"); |
| 2508 | return ErrorUnexpected; | 2525 | return ErrorUnexpected; |
| 2509 | case clang::Decl::Namespace: | 2526 | case ZigClangDeclNamespace: |
| 2510 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Namespace"); | 2527 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Namespace"); |
| 2511 | return ErrorUnexpected; | 2528 | return ErrorUnexpected; |
| 2512 | case clang::Decl::NamespaceAlias: | 2529 | case ZigClangDeclNamespaceAlias: |
| 2513 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C NamespaceAlias"); | 2530 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C NamespaceAlias"); |
| 2514 | return ErrorUnexpected; | 2531 | return ErrorUnexpected; |
| 2515 | case clang::Decl::ObjCCompatibleAlias: | 2532 | case ZigClangDeclObjCCompatibleAlias: |
| 2516 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCCompatibleAlias"); | 2533 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCCompatibleAlias"); |
| 2517 | return ErrorUnexpected; | 2534 | return ErrorUnexpected; |
| 2518 | case clang::Decl::ObjCCategory: | 2535 | case ZigClangDeclObjCCategory: |
| 2519 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCCategory"); | 2536 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCCategory"); |
| 2520 | return ErrorUnexpected; | 2537 | return ErrorUnexpected; |
| 2521 | case clang::Decl::ObjCCategoryImpl: | 2538 | case ZigClangDeclObjCCategoryImpl: |
| 2522 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCCategoryImpl"); | 2539 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCCategoryImpl"); |
| 2523 | return ErrorUnexpected; | 2540 | return ErrorUnexpected; |
| 2524 | case clang::Decl::ObjCImplementation: | 2541 | case ZigClangDeclObjCImplementation: |
| 2525 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCImplementation"); | 2542 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCImplementation"); |
| 2526 | return ErrorUnexpected; | 2543 | return ErrorUnexpected; |
| 2527 | case clang::Decl::ObjCInterface: | 2544 | case ZigClangDeclObjCInterface: |
| 2528 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCInterface"); | 2545 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCInterface"); |
| 2529 | return ErrorUnexpected; | 2546 | return ErrorUnexpected; |
| 2530 | case clang::Decl::ObjCProtocol: | 2547 | case ZigClangDeclObjCProtocol: |
| 2531 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCProtocol"); | 2548 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCProtocol"); |
| 2532 | return ErrorUnexpected; | 2549 | return ErrorUnexpected; |
| 2533 | case clang::Decl::ObjCMethod: | 2550 | case ZigClangDeclObjCMethod: |
| 2534 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCMethod"); | 2551 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCMethod"); |
| 2535 | return ErrorUnexpected; | 2552 | return ErrorUnexpected; |
| 2536 | case clang::Decl::ObjCProperty: | 2553 | case ZigClangDeclObjCProperty: |
| 2537 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCProperty"); | 2554 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCProperty"); |
| 2538 | return ErrorUnexpected; | 2555 | return ErrorUnexpected; |
| 2539 | case clang::Decl::BuiltinTemplate: | 2556 | case ZigClangDeclBuiltinTemplate: |
| 2540 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C BuiltinTemplate"); | 2557 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C BuiltinTemplate"); |
| 2541 | return ErrorUnexpected; | 2558 | return ErrorUnexpected; |
| 2542 | case clang::Decl::ClassTemplate: | 2559 | case ZigClangDeclClassTemplate: |
| 2543 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ClassTemplate"); | 2560 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ClassTemplate"); |
| 2544 | return ErrorUnexpected; | 2561 | return ErrorUnexpected; |
| 2545 | case clang::Decl::FunctionTemplate: | 2562 | case ZigClangDeclFunctionTemplate: |
| 2546 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C FunctionTemplate"); | 2563 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C FunctionTemplate"); |
| 2547 | return ErrorUnexpected; | 2564 | return ErrorUnexpected; |
| 2548 | case clang::Decl::TypeAliasTemplate: | 2565 | case ZigClangDeclTypeAliasTemplate: |
| 2549 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C TypeAliasTemplate"); | 2566 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C TypeAliasTemplate"); |
| 2550 | return ErrorUnexpected; | 2567 | return ErrorUnexpected; |
| 2551 | case clang::Decl::VarTemplate: | 2568 | case ZigClangDeclVarTemplate: |
| 2552 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C VarTemplate"); | 2569 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C VarTemplate"); |
| 2553 | return ErrorUnexpected; | 2570 | return ErrorUnexpected; |
| 2554 | case clang::Decl::TemplateTemplateParm: | 2571 | case ZigClangDeclTemplateTemplateParm: |
| 2555 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C TemplateTemplateParm"); | 2572 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C TemplateTemplateParm"); |
| 2556 | return ErrorUnexpected; | 2573 | return ErrorUnexpected; |
| 2557 | case clang::Decl::Enum: | 2574 | case ZigClangDeclEnum: |
| 2558 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Enum"); | 2575 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Enum"); |
| 2559 | return ErrorUnexpected; | 2576 | return ErrorUnexpected; |
| 2560 | case clang::Decl::Record: | 2577 | case ZigClangDeclRecord: |
| 2561 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Record"); | 2578 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Record"); |
| 2562 | return ErrorUnexpected; | 2579 | return ErrorUnexpected; |
| 2563 | case clang::Decl::CXXRecord: | 2580 | case ZigClangDeclCXXRecord: |
| 2564 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CXXRecord"); | 2581 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C CXXRecord"); |
| 2565 | return ErrorUnexpected; | 2582 | return ErrorUnexpected; |
| 2566 | case clang::Decl::ClassTemplateSpecialization: | 2583 | case ZigClangDeclClassTemplateSpecialization: |
| 2567 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ClassTemplateSpecialization"); | 2584 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ClassTemplateSpecialization"); |
| 2568 | return ErrorUnexpected; | 2585 | return ErrorUnexpected; |
| 2569 | case clang::Decl::ClassTemplatePartialSpecialization: | 2586 | case ZigClangDeclClassTemplatePartialSpecialization: |
| 2570 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ClassTemplatePartialSpecialization"); | 2587 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ClassTemplatePartialSpecialization"); |
| 2571 | return ErrorUnexpected; | 2588 | return ErrorUnexpected; |
| 2572 | case clang::Decl::TemplateTypeParm: | 2589 | case ZigClangDeclTemplateTypeParm: |
| 2573 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C TemplateTypeParm"); | 2590 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C TemplateTypeParm"); |
| 2574 | return ErrorUnexpected; | 2591 | return ErrorUnexpected; |
| 2575 | case clang::Decl::ObjCTypeParam: | 2592 | case ZigClangDeclObjCTypeParam: |
| 2576 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCTypeParam"); | 2593 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCTypeParam"); |
| 2577 | return ErrorUnexpected; | 2594 | return ErrorUnexpected; |
| 2578 | case clang::Decl::TypeAlias: | 2595 | case ZigClangDeclTypeAlias: |
| 2579 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C TypeAlias"); | 2596 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C TypeAlias"); |
| 2580 | return ErrorUnexpected; | 2597 | return ErrorUnexpected; |
| 2581 | case clang::Decl::Typedef: | 2598 | case ZigClangDeclTypedef: |
| 2582 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Typedef"); | 2599 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Typedef"); |
| 2583 | return ErrorUnexpected; | 2600 | return ErrorUnexpected; |
| 2584 | case clang::Decl::UnresolvedUsingTypename: | 2601 | case ZigClangDeclUnresolvedUsingTypename: |
| 2585 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C UnresolvedUsingTypename"); | 2602 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C UnresolvedUsingTypename"); |
| 2586 | return ErrorUnexpected; | 2603 | return ErrorUnexpected; |
| 2587 | case clang::Decl::Using: | 2604 | case ZigClangDeclUsing: |
| 2588 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Using"); | 2605 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Using"); |
| 2589 | return ErrorUnexpected; | 2606 | return ErrorUnexpected; |
| 2590 | case clang::Decl::UsingDirective: | 2607 | case ZigClangDeclUsingDirective: |
| 2591 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C UsingDirective"); | 2608 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C UsingDirective"); |
| 2592 | return ErrorUnexpected; | 2609 | return ErrorUnexpected; |
| 2593 | case clang::Decl::UsingPack: | 2610 | case ZigClangDeclUsingPack: |
| 2594 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C UsingPack"); | 2611 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C UsingPack"); |
| 2595 | return ErrorUnexpected; | 2612 | return ErrorUnexpected; |
| 2596 | case clang::Decl::UsingShadow: | 2613 | case ZigClangDeclUsingShadow: |
| 2597 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C UsingShadow"); | 2614 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C UsingShadow"); |
| 2598 | return ErrorUnexpected; | 2615 | return ErrorUnexpected; |
| 2599 | case clang::Decl::ConstructorUsingShadow: | 2616 | case ZigClangDeclConstructorUsingShadow: |
| 2600 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ConstructorUsingShadow"); | 2617 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ConstructorUsingShadow"); |
| 2601 | return ErrorUnexpected; | 2618 | return ErrorUnexpected; |
| 2602 | case clang::Decl::Binding: | 2619 | case ZigClangDeclBinding: |
| 2603 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Binding"); | 2620 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Binding"); |
| 2604 | return ErrorUnexpected; | 2621 | return ErrorUnexpected; |
| 2605 | case clang::Decl::Field: | 2622 | case ZigClangDeclField: |
| 2606 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Field"); | 2623 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Field"); |
| 2607 | return ErrorUnexpected; | 2624 | return ErrorUnexpected; |
| 2608 | case clang::Decl::ObjCAtDefsField: | 2625 | case ZigClangDeclObjCAtDefsField: |
| 2609 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCAtDefsField"); | 2626 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCAtDefsField"); |
| 2610 | return ErrorUnexpected; | 2627 | return ErrorUnexpected; |
| 2611 | case clang::Decl::ObjCIvar: | 2628 | case ZigClangDeclObjCIvar: |
| 2612 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCIvar"); | 2629 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCIvar"); |
| 2613 | return ErrorUnexpected; | 2630 | return ErrorUnexpected; |
| 2614 | case clang::Decl::Function: | 2631 | case ZigClangDeclFunction: |
| 2615 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Function"); | 2632 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Function"); |
| 2616 | return ErrorUnexpected; | 2633 | return ErrorUnexpected; |
| 2617 | case clang::Decl::CXXDeductionGuide: | 2634 | case ZigClangDeclCXXDeductionGuide: |
| 2618 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CXXDeductionGuide"); | 2635 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C CXXDeductionGuide"); |
| 2619 | return ErrorUnexpected; | 2636 | return ErrorUnexpected; |
| 2620 | case clang::Decl::CXXMethod: | 2637 | case ZigClangDeclCXXMethod: |
| 2621 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CXXMethod"); | 2638 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C CXXMethod"); |
| 2622 | return ErrorUnexpected; | 2639 | return ErrorUnexpected; |
| 2623 | case clang::Decl::CXXConstructor: | 2640 | case ZigClangDeclCXXConstructor: |
| 2624 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CXXConstructor"); | 2641 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C CXXConstructor"); |
| 2625 | return ErrorUnexpected; | 2642 | return ErrorUnexpected; |
| 2626 | case clang::Decl::CXXConversion: | 2643 | case ZigClangDeclCXXConversion: |
| 2627 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CXXConversion"); | 2644 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C CXXConversion"); |
| 2628 | return ErrorUnexpected; | 2645 | return ErrorUnexpected; |
| 2629 | case clang::Decl::CXXDestructor: | 2646 | case ZigClangDeclCXXDestructor: |
| 2630 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CXXDestructor"); | 2647 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C CXXDestructor"); |
| 2631 | return ErrorUnexpected; | 2648 | return ErrorUnexpected; |
| 2632 | case clang::Decl::MSProperty: | 2649 | case ZigClangDeclMSProperty: |
| 2633 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C MSProperty"); | 2650 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C MSProperty"); |
| 2634 | return ErrorUnexpected; | 2651 | return ErrorUnexpected; |
| 2635 | case clang::Decl::NonTypeTemplateParm: | 2652 | case ZigClangDeclNonTypeTemplateParm: |
| 2636 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C NonTypeTemplateParm"); | 2653 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C NonTypeTemplateParm"); |
| 2637 | return ErrorUnexpected; | 2654 | return ErrorUnexpected; |
| 2638 | case clang::Decl::Decomposition: | 2655 | case ZigClangDeclDecomposition: |
| 2639 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Decomposition"); | 2656 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Decomposition"); |
| 2640 | return ErrorUnexpected; | 2657 | return ErrorUnexpected; |
| 2641 | case clang::Decl::ImplicitParam: | 2658 | case ZigClangDeclImplicitParam: |
| 2642 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ImplicitParam"); | 2659 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ImplicitParam"); |
| 2643 | return ErrorUnexpected; | 2660 | return ErrorUnexpected; |
| 2644 | case clang::Decl::OMPCapturedExpr: | 2661 | case ZigClangDeclOMPCapturedExpr: |
| 2645 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C OMPCapturedExpr"); | 2662 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C OMPCapturedExpr"); |
| 2646 | return ErrorUnexpected; | 2663 | return ErrorUnexpected; |
| 2647 | case clang::Decl::ParmVar: | 2664 | case ZigClangDeclParmVar: |
| 2648 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ParmVar"); | 2665 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ParmVar"); |
| 2649 | return ErrorUnexpected; | 2666 | return ErrorUnexpected; |
| 2650 | case clang::Decl::VarTemplateSpecialization: | 2667 | case ZigClangDeclVarTemplateSpecialization: |
| 2651 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C VarTemplateSpecialization"); | 2668 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C VarTemplateSpecialization"); |
| 2652 | return ErrorUnexpected; | 2669 | return ErrorUnexpected; |
| 2653 | case clang::Decl::VarTemplatePartialSpecialization: | 2670 | case ZigClangDeclVarTemplatePartialSpecialization: |
| 2654 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C VarTemplatePartialSpecialization"); | 2671 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C VarTemplatePartialSpecialization"); |
| 2655 | return ErrorUnexpected; | 2672 | return ErrorUnexpected; |
| 2656 | case clang::Decl::EnumConstant: | 2673 | case ZigClangDeclEnumConstant: |
| 2657 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C EnumConstant"); | 2674 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C EnumConstant"); |
| 2658 | return ErrorUnexpected; | 2675 | return ErrorUnexpected; |
| 2659 | case clang::Decl::IndirectField: | 2676 | case ZigClangDeclIndirectField: |
| 2660 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C IndirectField"); | 2677 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C IndirectField"); |
| 2661 | return ErrorUnexpected; | 2678 | return ErrorUnexpected; |
| 2662 | case clang::Decl::OMPDeclareReduction: | 2679 | case ZigClangDeclOMPDeclareReduction: |
| 2663 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C OMPDeclareReduction"); | 2680 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C OMPDeclareReduction"); |
| 2664 | return ErrorUnexpected; | 2681 | return ErrorUnexpected; |
| 2665 | case clang::Decl::UnresolvedUsingValue: | 2682 | case ZigClangDeclUnresolvedUsingValue: |
| 2666 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C UnresolvedUsingValue"); | 2683 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C UnresolvedUsingValue"); |
| 2667 | return ErrorUnexpected; | 2684 | return ErrorUnexpected; |
| 2668 | case clang::Decl::OMPRequires: | 2685 | case ZigClangDeclOMPRequires: |
| 2669 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C OMPRequires"); | 2686 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C OMPRequires"); |
| 2670 | return ErrorUnexpected; | 2687 | return ErrorUnexpected; |
| 2671 | case clang::Decl::OMPThreadPrivate: | 2688 | case ZigClangDeclOMPThreadPrivate: |
| 2672 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C OMPThreadPrivate"); | 2689 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C OMPThreadPrivate"); |
| 2673 | return ErrorUnexpected; | 2690 | return ErrorUnexpected; |
| 2674 | case clang::Decl::ObjCPropertyImpl: | 2691 | case ZigClangDeclObjCPropertyImpl: |
| 2675 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C ObjCPropertyImpl"); | 2692 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C ObjCPropertyImpl"); |
| 2676 | return ErrorUnexpected; | 2693 | return ErrorUnexpected; |
| 2677 | case clang::Decl::PragmaComment: | 2694 | case ZigClangDeclPragmaComment: |
| 2678 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C PragmaComment"); | 2695 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C PragmaComment"); |
| 2679 | return ErrorUnexpected; | 2696 | return ErrorUnexpected; |
| 2680 | case clang::Decl::PragmaDetectMismatch: | 2697 | case ZigClangDeclPragmaDetectMismatch: |
| 2681 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C PragmaDetectMismatch"); | 2698 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C PragmaDetectMismatch"); |
| 2682 | return ErrorUnexpected; | 2699 | return ErrorUnexpected; |
| 2683 | case clang::Decl::StaticAssert: | 2700 | case ZigClangDeclStaticAssert: |
| 2684 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C StaticAssert"); | 2701 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C StaticAssert"); |
| 2685 | return ErrorUnexpected; | 2702 | return ErrorUnexpected; |
| 2686 | case clang::Decl::TranslationUnit: | 2703 | case ZigClangDeclTranslationUnit: |
| 2687 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C TranslationUnit"); | 2704 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C TranslationUnit"); |
| 2688 | return ErrorUnexpected; | 2705 | return ErrorUnexpected; |
| 2689 | case clang::Decl::Concept: | 2706 | case ZigClangDeclConcept: |
| 2690 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C Concept"); | 2707 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C Concept"); |
| 2691 | return ErrorUnexpected; | 2708 | return ErrorUnexpected; |
| 2692 | case clang::Decl::OMPDeclareMapper: | 2709 | case ZigClangDeclOMPDeclareMapper: |
| 2693 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C OMPDeclareMapper"); | 2710 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C OMPDeclareMapper"); |
| 2694 | return ErrorUnexpected; | 2711 | return ErrorUnexpected; |
| 2695 | case clang::Decl::OMPAllocate: | 2712 | case ZigClangDeclOMPAllocate: |
| 2696 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C OMPAllocate"); | 2713 | emit_warning(c, ZigClangDeclStmt_getBeginLoc(stmt), "TODO handle C OMPAllocate"); |
| 2697 | return ErrorUnexpected; | 2714 | return ErrorUnexpected; |
| 2698 | } | 2715 | } |
| 2699 | zig_unreachable(); | 2716 | zig_unreachable(); |
| ... | @@ -2911,19 +2928,19 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2911,19 +2928,19 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2911 | | 2928 | |
| 2912 | case ZigClangType_Elaborated: | 2929 | case ZigClangType_Elaborated: |
| 2913 | { | 2930 | { |
| 2914 | const clang::ElaboratedType *elaborated_ty = reinterpret_cast<const clang::ElaboratedType*>(ty); | 2931 | const ZigClangElaboratedType *elaborated_ty = reinterpret_cast<const ZigClangElaboratedType*>(ty); |
| 2915 | switch (elaborated_ty->getKeyword()) { | 2932 | switch (ZigClangElaboratedType_getKeyword(elaborated_ty)) { |
| 2916 | case clang::ETK_Enum: { | 2933 | case ZigClangETK_Enum: { |
| 2917 | AstNode *enum_type = trans_qual_type(c, bitcast(elaborated_ty->getNamedType()), | 2934 | AstNode *enum_type = trans_qual_type(c, ZigClangElaboratedType_getNamedType(elaborated_ty), |
| 2918 | ZigClangExpr_getBeginLoc(expr)); | 2935 | ZigClangExpr_getBeginLoc(expr)); |
| 2919 | return to_enum_zero_cmp(c, res, enum_type); | 2936 | return to_enum_zero_cmp(c, res, enum_type); |
| 2920 | } | 2937 | } |
| 2921 | case clang::ETK_Struct: | 2938 | case ZigClangETK_Struct: |
| 2922 | case clang::ETK_Union: | 2939 | case ZigClangETK_Union: |
| 2923 | case clang::ETK_Interface: | 2940 | case ZigClangETK_Interface: |
| 2924 | case clang::ETK_Class: | 2941 | case ZigClangETK_Class: |
| 2925 | case clang::ETK_Typename: | 2942 | case ZigClangETK_Typename: |
| 2926 | case clang::ETK_None: | 2943 | case ZigClangETK_None: |
| 2927 | return res; | 2944 | return res; |
| 2928 | } | 2945 | } |
| 2929 | } | 2946 | } |
| ... | @@ -2976,15 +2993,15 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2976,15 +2993,15 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2976 | zig_unreachable(); | 2993 | zig_unreachable(); |
| 2977 | } | 2994 | } |
| 2978 | | 2995 | |
| 2979 | static AstNode *trans_while_loop(Context *c, TransScope *scope, const clang::WhileStmt *stmt) { | 2996 | static AstNode *trans_while_loop(Context *c, TransScope *scope, const ZigClangWhileStmt *stmt) { |
| 2980 | TransScopeWhile *while_scope = trans_scope_while_create(c, scope); | 2997 | TransScopeWhile *while_scope = trans_scope_while_create(c, scope); |
| 2981 | | 2998 | |
| 2982 | while_scope->node->data.while_expr.condition = trans_bool_expr(c, ResultUsedYes, scope, | 2999 | while_scope->node->data.while_expr.condition = trans_bool_expr(c, ResultUsedYes, scope, |
| 2983 | bitcast(stmt->getCond()), TransRValue); | 3000 | ZigClangWhileStmt_getCond(stmt), TransRValue); |
| 2984 | if (while_scope->node->data.while_expr.condition == nullptr) | 3001 | if (while_scope->node->data.while_expr.condition == nullptr) |
| 2985 | return nullptr; | 3002 | return nullptr; |
| 2986 | | 3003 | |
| 2987 | TransScope *body_scope = trans_stmt(c, &while_scope->base, bitcast(stmt->getBody()), | 3004 | TransScope *body_scope = trans_stmt(c, &while_scope->base, ZigClangWhileStmt_getBody(stmt), |
| 2988 | &while_scope->node->data.while_expr.body); | 3005 | &while_scope->node->data.while_expr.body); |
| 2989 | if (body_scope == nullptr) | 3006 | if (body_scope == nullptr) |
| 2990 | return nullptr; | 3007 | return nullptr; |
| ... | @@ -2992,22 +3009,22 @@ static AstNode *trans_while_loop(Context *c, TransScope *scope, const clang::Whi | ... | @@ -2992,22 +3009,22 @@ static AstNode *trans_while_loop(Context *c, TransScope *scope, const clang::Whi |
| 2992 | return while_scope->node; | 3009 | return while_scope->node; |
| 2993 | } | 3010 | } |
| 2994 | | 3011 | |
| 2995 | static AstNode *trans_if_statement(Context *c, TransScope *scope, const clang::IfStmt *stmt) { | 3012 | static AstNode *trans_if_statement(Context *c, TransScope *scope, const ZigClangIfStmt *stmt) { |
| 2996 | // if (c) t | 3013 | // if (c) t |
| 2997 | // if (c) t else e | 3014 | // if (c) t else e |
| 2998 | AstNode *if_node = trans_create_node(c, NodeTypeIfBoolExpr); | 3015 | AstNode *if_node = trans_create_node(c, NodeTypeIfBoolExpr); |
| 2999 | | 3016 | |
| 3000 | TransScope *then_scope = trans_stmt(c, scope, bitcast(stmt->getThen()), &if_node->data.if_bool_expr.then_block); | 3017 | TransScope *then_scope = trans_stmt(c, scope, ZigClangIfStmt_getThen(stmt), &if_node->data.if_bool_expr.then_block); |
| 3001 | if (then_scope == nullptr) | 3018 | if (then_scope == nullptr) |
| 3002 | return nullptr; | 3019 | return nullptr; |
| 3003 | | 3020 | |
| 3004 | if (stmt->getElse() != nullptr) { | 3021 | if (ZigClangIfStmt_getElse(stmt) != nullptr) { |
| 3005 | TransScope *else_scope = trans_stmt(c, scope, bitcast(stmt->getElse()), &if_node->data.if_bool_expr.else_node); | 3022 | TransScope *else_scope = trans_stmt(c, scope, ZigClangIfStmt_getElse(stmt), &if_node->data.if_bool_expr.else_node); |
| 3006 | if (else_scope == nullptr) | 3023 | if (else_scope == nullptr) |
| 3007 | return nullptr; | 3024 | return nullptr; |
| 3008 | } | 3025 | } |
| 3009 | | 3026 | |
| 3010 | if_node->data.if_bool_expr.condition = trans_bool_expr(c, ResultUsedYes, scope, bitcast(stmt->getCond()), | 3027 | if_node->data.if_bool_expr.condition = trans_bool_expr(c, ResultUsedYes, scope, ZigClangIfStmt_getCond(stmt), |
| 3011 | TransRValue); | 3028 | TransRValue); |
| 3012 | if (if_node->data.if_bool_expr.condition == nullptr) | 3029 | if (if_node->data.if_bool_expr.condition == nullptr) |
| 3013 | return nullptr; | 3030 | return nullptr; |
| ... | @@ -3015,24 +3032,27 @@ static AstNode *trans_if_statement(Context *c, TransScope *scope, const clang::I | ... | @@ -3015,24 +3032,27 @@ static AstNode *trans_if_statement(Context *c, TransScope *scope, const clang::I |
| 3015 | return if_node; | 3032 | return if_node; |
| 3016 | } | 3033 | } |
| 3017 | | 3034 | |
| 3018 | static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::CallExpr *stmt) { | 3035 | static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope *scope, const ZigClangCallExpr *stmt) { |
| 3019 | AstNode *node = trans_create_node(c, NodeTypeFnCallExpr); | 3036 | AstNode *node = trans_create_node(c, NodeTypeFnCallExpr); |
| 3020 | | 3037 | |
| 3021 | AstNode *callee_raw_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getCallee()), TransRValue); | 3038 | AstNode *callee_raw_node = trans_expr(c, ResultUsedYes, scope, ZigClangCallExpr_getCallee(stmt), TransRValue); |
| 3022 | if (callee_raw_node == nullptr) | 3039 | if (callee_raw_node == nullptr) |
| 3023 | return nullptr; | 3040 | return nullptr; |
| 3024 | | 3041 | |
| 3025 | bool is_ptr = false; | 3042 | bool is_ptr = false; |
| 3026 | const clang::FunctionProtoType *fn_ty = qual_type_get_fn_proto(bitcast(stmt->getCallee()->getType()), &is_ptr); | 3043 | const ZigClangFunctionProtoType *fn_ty = qual_type_get_fn_proto( |
| | 3044 | ZigClangExpr_getType(ZigClangCallExpr_getCallee(stmt)), &is_ptr); |
| 3027 | AstNode *callee_node = nullptr; | 3045 | AstNode *callee_node = nullptr; |
| 3028 | if (is_ptr && fn_ty) { | 3046 | if (is_ptr && fn_ty) { |
| 3029 | if ((ZigClangStmtClass)stmt->getCallee()->getStmtClass() == ZigClangStmt_ImplicitCastExprClass) { | 3047 | if (ZigClangExpr_getStmtClass(ZigClangCallExpr_getCallee(stmt)) == ZigClangStmt_ImplicitCastExprClass) { |
| 3030 | const clang::ImplicitCastExpr *implicit_cast = static_cast<const clang::ImplicitCastExpr *>(stmt->getCallee()); | 3048 | const ZigClangImplicitCastExpr *implicit_cast = reinterpret_cast<const ZigClangImplicitCastExpr *>( |
| 3031 | if ((ZigClangCK)implicit_cast->getCastKind() == ZigClangCK_FunctionToPointerDecay) { | 3049 | ZigClangCallExpr_getCallee(stmt)); |
| 3032 | if ((ZigClangStmtClass)implicit_cast->getSubExpr()->getStmtClass() == ZigClangStmt_DeclRefExprClass) { | 3050 | if (ZigClangImplicitCastExpr_getCastKind(implicit_cast) == ZigClangCK_FunctionToPointerDecay) { |
| 3033 | const clang::DeclRefExpr *decl_ref = static_cast<const clang::DeclRefExpr *>(implicit_cast->getSubExpr()); | 3051 | const ZigClangExpr *subexpr = ZigClangImplicitCastExpr_getSubExpr(implicit_cast); |
| 3034 | const clang::Decl *decl = decl_ref->getFoundDecl(); | 3052 | if (ZigClangExpr_getStmtClass(subexpr) == ZigClangStmt_DeclRefExprClass) { |
| 3035 | if (decl->getKind() == clang::Decl::Function) { | 3053 | const ZigClangDeclRefExpr *decl_ref = reinterpret_cast<const ZigClangDeclRefExpr *>(subexpr); |
| | 3054 | const ZigClangNamedDecl *named_decl = ZigClangDeclRefExpr_getFoundDecl(decl_ref); |
| | 3055 | if (ZigClangDecl_getKind((const ZigClangDecl *)named_decl) == ZigClangDeclFunction) { |
| 3036 | callee_node = callee_raw_node; | 3056 | callee_node = callee_raw_node; |
| 3037 | } | 3057 | } |
| 3038 | } | 3058 | } |
| ... | @@ -3047,8 +3067,8 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -3047,8 +3067,8 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * |
| 3047 | | 3067 | |
| 3048 | node->data.fn_call_expr.fn_ref_expr = callee_node; | 3068 | node->data.fn_call_expr.fn_ref_expr = callee_node; |
| 3049 | | 3069 | |
| 3050 | unsigned num_args = stmt->getNumArgs(); | 3070 | unsigned num_args = ZigClangCallExpr_getNumArgs(stmt); |
| 3051 | const ZigClangExpr * const* args = reinterpret_cast<const ZigClangExpr * const*>(stmt->getArgs()); | 3071 | const ZigClangExpr * const* args = ZigClangCallExpr_getArgs(stmt); |
| 3052 | for (unsigned i = 0; i < num_args; i += 1) { | 3072 | for (unsigned i = 0; i < num_args; i += 1) { |
| 3053 | AstNode *arg_node = trans_expr(c, ResultUsedYes, scope, args[i], TransRValue); | 3073 | AstNode *arg_node = trans_expr(c, ResultUsedYes, scope, args[i], TransRValue); |
| 3054 | if (arg_node == nullptr) | 3074 | if (arg_node == nullptr) |
| ... | @@ -3058,7 +3078,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -3058,7 +3078,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * |
| 3058 | } | 3078 | } |
| 3059 | | 3079 | |
| 3060 | if (result_used == ResultUsedNo && fn_ty && | 3080 | if (result_used == ResultUsedNo && fn_ty && |
| 3061 | !ZigClangType_isVoidType(qual_type_canon(bitcast(fn_ty->getReturnType())))) | 3081 | !ZigClangType_isVoidType(qual_type_canon(ZigClangFunctionProtoType_getReturnType(fn_ty)))) |
| 3062 | { | 3082 | { |
| 3063 | node = trans_create_node_bin_op(c, trans_create_node_symbol_str(c, "_"), BinOpTypeAssign, node); | 3083 | node = trans_create_node_bin_op(c, trans_create_node_symbol_str(c, "_"), BinOpTypeAssign, node); |
| 3064 | } | 3084 | } |
| ... | @@ -3067,28 +3087,31 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -3067,28 +3087,31 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * |
| 3067 | } | 3087 | } |
| 3068 | | 3088 | |
| 3069 | static AstNode *trans_member_expr(Context *c, ResultUsed result_used, TransScope *scope, | 3089 | static AstNode *trans_member_expr(Context *c, ResultUsed result_used, TransScope *scope, |
| 3070 | const clang::MemberExpr *stmt) | 3090 | const ZigClangMemberExpr *stmt) |
| 3071 | { | 3091 | { |
| 3072 | AstNode *container_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getBase()), TransRValue); | 3092 | AstNode *container_node = trans_expr(c, ResultUsedYes, scope, ZigClangMemberExpr_getBase(stmt), TransRValue); |
| 3073 | if (container_node == nullptr) | 3093 | if (container_node == nullptr) |
| 3074 | return nullptr; | 3094 | return nullptr; |
| 3075 | | 3095 | |
| 3076 | if (stmt->isArrow()) { | 3096 | if (ZigClangMemberExpr_isArrow(stmt)) { |
| 3077 | container_node = trans_create_node_unwrap_null(c, container_node); | 3097 | container_node = trans_create_node_unwrap_null(c, container_node); |
| 3078 | } | 3098 | } |
| 3079 | | 3099 | |
| 3080 | const char *name = ZigClangDecl_getName_bytes_begin((const ZigClangDecl *)stmt->getMemberDecl()); | 3100 | const char *name = ZigClangDecl_getName_bytes_begin((const ZigClangDecl *)ZigClangMemberExpr_getMemberDecl(stmt)); |
| 3081 | | 3101 | |
| 3082 | AstNode *node = trans_create_node_field_access_str(c, container_node, name); | 3102 | AstNode *node = trans_create_node_field_access_str(c, container_node, name); |
| 3083 | return maybe_suppress_result(c, result_used, node); | 3103 | return maybe_suppress_result(c, result_used, node); |
| 3084 | } | 3104 | } |
| 3085 | | 3105 | |
| 3086 | static AstNode *trans_array_subscript_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::ArraySubscriptExpr *stmt) { | 3106 | static AstNode *trans_array_subscript_expr(Context *c, ResultUsed result_used, TransScope *scope, |
| 3087 | AstNode *container_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getBase()), TransRValue); | 3107 | const ZigClangArraySubscriptExpr *stmt) |
| | 3108 | { |
| | 3109 | AstNode *container_node = trans_expr(c, ResultUsedYes, scope, ZigClangArraySubscriptExpr_getBase(stmt), |
| | 3110 | TransRValue); |
| 3088 | if (container_node == nullptr) | 3111 | if (container_node == nullptr) |
| 3089 | return nullptr; | 3112 | return nullptr; |
| 3090 | | 3113 | |
| 3091 | AstNode *idx_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getIdx()), TransRValue); | 3114 | AstNode *idx_node = trans_expr(c, ResultUsedYes, scope, ZigClangArraySubscriptExpr_getIdx(stmt), TransRValue); |
| 3092 | if (idx_node == nullptr) | 3115 | if (idx_node == nullptr) |
| 3093 | return nullptr; | 3116 | return nullptr; |
| 3094 | | 3117 | |
| ... | @@ -3100,14 +3123,14 @@ static AstNode *trans_array_subscript_expr(Context *c, ResultUsed result_used, T | ... | @@ -3100,14 +3123,14 @@ static AstNode *trans_array_subscript_expr(Context *c, ResultUsed result_used, T |
| 3100 | } | 3123 | } |
| 3101 | | 3124 | |
| 3102 | static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, TransScope *scope, | 3125 | static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, TransScope *scope, |
| 3103 | const clang::CStyleCastExpr *stmt, TransLRValue lrvalue) | 3126 | const ZigClangCStyleCastExpr *stmt, TransLRValue lrvalue) |
| 3104 | { | 3127 | { |
| 3105 | AstNode *sub_expr_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getSubExpr()), lrvalue); | 3128 | AstNode *sub_expr_node = trans_expr(c, ResultUsedYes, scope, ZigClangCStyleCastExpr_getSubExpr(stmt), lrvalue); |
| 3106 | if (sub_expr_node == nullptr) | 3129 | if (sub_expr_node == nullptr) |
| 3107 | return nullptr; | 3130 | return nullptr; |
| 3108 | | 3131 | |
| 3109 | AstNode *cast = trans_c_cast(c, bitcast(stmt->getBeginLoc()), bitcast(stmt->getType()), | 3132 | AstNode *cast = trans_c_cast(c, ZigClangCStyleCastExpr_getBeginLoc(stmt), ZigClangCStyleCastExpr_getType(stmt), |
| 3110 | bitcast(stmt->getSubExpr()->getType()), sub_expr_node); | 3133 | ZigClangExpr_getType(ZigClangCStyleCastExpr_getSubExpr(stmt)), sub_expr_node); |
| 3111 | if (cast == nullptr) | 3134 | if (cast == nullptr) |
| 3112 | return nullptr; | 3135 | return nullptr; |
| 3113 | | 3136 | |
| ... | @@ -3115,9 +3138,10 @@ static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, Tran | ... | @@ -3115,9 +3138,10 @@ static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, Tran |
| 3115 | } | 3138 | } |
| 3116 | | 3139 | |
| 3117 | static AstNode *trans_unary_expr_or_type_trait_expr(Context *c, ResultUsed result_used, | 3140 | static AstNode *trans_unary_expr_or_type_trait_expr(Context *c, ResultUsed result_used, |
| 3118 | TransScope *scope, const clang::UnaryExprOrTypeTraitExpr *stmt) | 3141 | TransScope *scope, const ZigClangUnaryExprOrTypeTraitExpr *stmt) |
| 3119 | { | 3142 | { |
| 3120 | AstNode *type_node = trans_qual_type(c, bitcast(stmt->getTypeOfArgument()), bitcast(stmt->getBeginLoc())); | 3143 | AstNode *type_node = trans_qual_type(c, ZigClangUnaryExprOrTypeTraitExpr_getTypeOfArgument(stmt), |
| | 3144 | ZigClangUnaryExprOrTypeTraitExpr_getBeginLoc(stmt)); |
| 3121 | if (type_node == nullptr) | 3145 | if (type_node == nullptr) |
| 3122 | return nullptr; | 3146 | return nullptr; |
| 3123 | | 3147 | |
| ... | @@ -3126,14 +3150,14 @@ static AstNode *trans_unary_expr_or_type_trait_expr(Context *c, ResultUsed resul | ... | @@ -3126,14 +3150,14 @@ static AstNode *trans_unary_expr_or_type_trait_expr(Context *c, ResultUsed resul |
| 3126 | return maybe_suppress_result(c, result_used, node); | 3150 | return maybe_suppress_result(c, result_used, node); |
| 3127 | } | 3151 | } |
| 3128 | | 3152 | |
| 3129 | static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang::DoStmt *stmt) { | 3153 | static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const ZigClangDoStmt *stmt) { |
| 3130 | TransScopeWhile *while_scope = trans_scope_while_create(c, parent_scope); | 3154 | TransScopeWhile *while_scope = trans_scope_while_create(c, parent_scope); |
| 3131 | | 3155 | |
| 3132 | while_scope->node->data.while_expr.condition = trans_create_node_bool(c, true); | 3156 | while_scope->node->data.while_expr.condition = trans_create_node_bool(c, true); |
| 3133 | | 3157 | |
| 3134 | AstNode *body_node; | 3158 | AstNode *body_node; |
| 3135 | TransScope *child_scope; | 3159 | TransScope *child_scope; |
| 3136 | if ((ZigClangStmtClass)stmt->getBody()->getStmtClass() == ZigClangStmt_CompoundStmtClass) { | 3160 | if (ZigClangStmt_getStmtClass(ZigClangDoStmt_getBody(stmt)) == ZigClangStmt_CompoundStmtClass) { |
| 3137 | // there's already a block in C, so we'll append our condition to it. | 3161 | // there's already a block in C, so we'll append our condition to it. |
| 3138 | // c: do { | 3162 | // c: do { |
| 3139 | // c: a; | 3163 | // c: a; |
| ... | @@ -3146,8 +3170,8 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: | ... | @@ -3146,8 +3170,8 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: |
| 3146 | // zig: } | 3170 | // zig: } |
| 3147 | | 3171 | |
| 3148 | // We call the low level function so that we can set child_scope to the scope of the generated block. | 3172 | // We call the low level function so that we can set child_scope to the scope of the generated block. |
| 3149 | if (trans_stmt_extra(c, &while_scope->base, bitcast(stmt->getBody()), ResultUsedNo, TransRValue, &body_node, | 3173 | if (trans_stmt_extra(c, &while_scope->base, ZigClangDoStmt_getBody(stmt), ResultUsedNo, TransRValue, |
| 3150 | nullptr, &child_scope)) | 3174 | &body_node, nullptr, &child_scope)) |
| 3151 | { | 3175 | { |
| 3152 | return nullptr; | 3176 | return nullptr; |
| 3153 | } | 3177 | } |
| ... | @@ -3164,7 +3188,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: | ... | @@ -3164,7 +3188,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: |
| 3164 | TransScopeBlock *child_block_scope = trans_scope_block_create(c, &while_scope->base); | 3188 | TransScopeBlock *child_block_scope = trans_scope_block_create(c, &while_scope->base); |
| 3165 | body_node = child_block_scope->node; | 3189 | body_node = child_block_scope->node; |
| 3166 | AstNode *child_statement; | 3190 | AstNode *child_statement; |
| 3167 | child_scope = trans_stmt(c, &child_block_scope->base, bitcast(stmt->getBody()), &child_statement); | 3191 | child_scope = trans_stmt(c, &child_block_scope->base, ZigClangDoStmt_getBody(stmt), &child_statement); |
| 3168 | if (child_scope == nullptr) return nullptr; | 3192 | if (child_scope == nullptr) return nullptr; |
| 3169 | if (child_statement != nullptr) { | 3193 | if (child_statement != nullptr) { |
| 3170 | body_node->data.block.statements.append(child_statement); | 3194 | body_node->data.block.statements.append(child_statement); |
| ... | @@ -3172,7 +3196,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: | ... | @@ -3172,7 +3196,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: |
| 3172 | } | 3196 | } |
| 3173 | | 3197 | |
| 3174 | // if (!cond) break; | 3198 | // if (!cond) break; |
| 3175 | AstNode *condition_node = trans_expr(c, ResultUsedYes, child_scope, bitcast(stmt->getCond()), TransRValue); | 3199 | AstNode *condition_node = trans_expr(c, ResultUsedYes, child_scope, ZigClangDoStmt_getCond(stmt), TransRValue); |
| 3176 | if (condition_node == nullptr) return nullptr; | 3200 | if (condition_node == nullptr) return nullptr; |
| 3177 | AstNode *terminator_node = trans_create_node(c, NodeTypeIfBoolExpr); | 3201 | AstNode *terminator_node = trans_create_node(c, NodeTypeIfBoolExpr); |
| 3178 | terminator_node->data.if_bool_expr.condition = trans_create_node_prefix_op(c, PrefixOpBoolNot, condition_node); | 3202 | terminator_node->data.if_bool_expr.condition = trans_create_node_prefix_op(c, PrefixOpBoolNot, condition_node); |
| ... | @@ -3186,11 +3210,11 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: | ... | @@ -3186,11 +3210,11 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: |
| 3186 | return while_scope->node; | 3210 | return while_scope->node; |
| 3187 | } | 3211 | } |
| 3188 | | 3212 | |
| 3189 | static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang::ForStmt *stmt) { | 3213 | static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const ZigClangForStmt *stmt) { |
| 3190 | AstNode *loop_block_node; | 3214 | AstNode *loop_block_node; |
| 3191 | TransScopeWhile *while_scope; | 3215 | TransScopeWhile *while_scope; |
| 3192 | TransScope *cond_scope; | 3216 | TransScope *cond_scope; |
| 3193 | const ZigClangStmt *init_stmt = bitcast(stmt->getInit()); | 3217 | const ZigClangStmt *init_stmt = ZigClangForStmt_getInit(stmt); |
| 3194 | if (init_stmt == nullptr) { | 3218 | if (init_stmt == nullptr) { |
| 3195 | while_scope = trans_scope_while_create(c, parent_scope); | 3219 | while_scope = trans_scope_while_create(c, parent_scope); |
| 3196 | loop_block_node = while_scope->node; | 3220 | loop_block_node = while_scope->node; |
| ... | @@ -3211,7 +3235,7 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang | ... | @@ -3211,7 +3235,7 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang |
| 3211 | child_scope->node->data.block.statements.append(while_scope->node); | 3235 | child_scope->node->data.block.statements.append(while_scope->node); |
| 3212 | } | 3236 | } |
| 3213 | | 3237 | |
| 3214 | const ZigClangExpr *cond_expr = bitcast(stmt->getCond()); | 3238 | const ZigClangExpr *cond_expr = ZigClangForStmt_getCond(stmt); |
| 3215 | if (cond_expr == nullptr) { | 3239 | if (cond_expr == nullptr) { |
| 3216 | while_scope->node->data.while_expr.condition = trans_create_node_bool(c, true); | 3240 | while_scope->node->data.while_expr.condition = trans_create_node_bool(c, true); |
| 3217 | } else { | 3241 | } else { |
| ... | @@ -3222,7 +3246,7 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang | ... | @@ -3222,7 +3246,7 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang |
| 3222 | return nullptr; | 3246 | return nullptr; |
| 3223 | } | 3247 | } |
| 3224 | | 3248 | |
| 3225 | const ZigClangExpr *inc_expr = bitcast(stmt->getInc()); | 3249 | const ZigClangExpr *inc_expr = ZigClangForStmt_getInc(stmt); |
| 3226 | if (inc_expr != nullptr) { | 3250 | if (inc_expr != nullptr) { |
| 3227 | AstNode *inc_node = trans_expr(c, ResultUsedNo, cond_scope, inc_expr, TransRValue); | 3251 | AstNode *inc_node = trans_expr(c, ResultUsedNo, cond_scope, inc_expr, TransRValue); |
| 3228 | if (inc_node == nullptr) | 3252 | if (inc_node == nullptr) |
| ... | @@ -3231,7 +3255,7 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang | ... | @@ -3231,7 +3255,7 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang |
| 3231 | } | 3255 | } |
| 3232 | | 3256 | |
| 3233 | AstNode *body_statement; | 3257 | AstNode *body_statement; |
| 3234 | TransScope *body_scope = trans_stmt(c, &while_scope->base, bitcast(stmt->getBody()), &body_statement); | 3258 | TransScope *body_scope = trans_stmt(c, &while_scope->base, ZigClangForStmt_getBody(stmt), &body_statement); |
| 3235 | if (body_scope == nullptr) | 3259 | if (body_scope == nullptr) |
| 3236 | return nullptr; | 3260 | return nullptr; |
| 3237 | | 3261 | |
| ... | @@ -3244,12 +3268,12 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang | ... | @@ -3244,12 +3268,12 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang |
| 3244 | return loop_block_node; | 3268 | return loop_block_node; |
| 3245 | } | 3269 | } |
| 3246 | | 3270 | |
| 3247 | static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const clang::SwitchStmt *stmt) { | 3271 | static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const ZigClangSwitchStmt *stmt) { |
| 3248 | TransScopeBlock *block_scope = trans_scope_block_create(c, parent_scope); | 3272 | TransScopeBlock *block_scope = trans_scope_block_create(c, parent_scope); |
| 3249 | | 3273 | |
| 3250 | TransScopeSwitch *switch_scope; | 3274 | TransScopeSwitch *switch_scope; |
| 3251 | | 3275 | |
| 3252 | const clang::DeclStmt *var_decl_stmt = stmt->getConditionVariableDeclStmt(); | 3276 | const ZigClangDeclStmt *var_decl_stmt = ZigClangSwitchStmt_getConditionVariableDeclStmt(stmt); |
| 3253 | if (var_decl_stmt == nullptr) { | 3277 | if (var_decl_stmt == nullptr) { |
| 3254 | switch_scope = trans_scope_switch_create(c, &block_scope->base); | 3278 | switch_scope = trans_scope_switch_create(c, &block_scope->base); |
| 3255 | } else { | 3279 | } else { |
| ... | @@ -3268,7 +3292,7 @@ static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const cl | ... | @@ -3268,7 +3292,7 @@ static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const cl |
| 3268 | switch_scope->end_label_name = end_label_name; | 3292 | switch_scope->end_label_name = end_label_name; |
| 3269 | block_scope->node->data.block.name = end_label_name; | 3293 | block_scope->node->data.block.name = end_label_name; |
| 3270 | | 3294 | |
| 3271 | const ZigClangExpr *cond_expr = bitcast(stmt->getCond()); | 3295 | const ZigClangExpr *cond_expr = ZigClangSwitchStmt_getCond(stmt); |
| 3272 | assert(cond_expr != nullptr); | 3296 | assert(cond_expr != nullptr); |
| 3273 | | 3297 | |
| 3274 | AstNode *expr_node = trans_expr(c, ResultUsedYes, &block_scope->base, cond_expr, TransRValue); | 3298 | AstNode *expr_node = trans_expr(c, ResultUsedYes, &block_scope->base, cond_expr, TransRValue); |
| ... | @@ -3277,7 +3301,7 @@ static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const cl | ... | @@ -3277,7 +3301,7 @@ static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const cl |
| 3277 | switch_scope->switch_node->data.switch_expr.expr = expr_node; | 3301 | switch_scope->switch_node->data.switch_expr.expr = expr_node; |
| 3278 | | 3302 | |
| 3279 | AstNode *body_node; | 3303 | AstNode *body_node; |
| 3280 | const ZigClangStmt *body_stmt = bitcast(stmt->getBody()); | 3304 | const ZigClangStmt *body_stmt = ZigClangSwitchStmt_getBody(stmt); |
| 3281 | if (ZigClangStmt_getStmtClass(body_stmt) == ZigClangStmt_CompoundStmtClass) { | 3305 | if (ZigClangStmt_getStmtClass(body_stmt) == ZigClangStmt_CompoundStmtClass) { |
| 3282 | if (trans_compound_stmt_inline(c, &switch_scope->base, (const ZigClangCompoundStmt *)body_stmt, | 3306 | if (trans_compound_stmt_inline(c, &switch_scope->base, (const ZigClangCompoundStmt *)body_stmt, |
| 3283 | block_scope->node, nullptr)) | 3307 | block_scope->node, nullptr)) |
| ... | @@ -3292,7 +3316,7 @@ static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const cl | ... | @@ -3292,7 +3316,7 @@ static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const cl |
| 3292 | block_scope->node->data.block.statements.append(body_node); | 3316 | block_scope->node->data.block.statements.append(body_node); |
| 3293 | } | 3317 | } |
| 3294 | | 3318 | |
| 3295 | if (!switch_scope->found_default && !stmt->isAllEnumCasesCovered()) { | 3319 | if (!switch_scope->found_default && !ZigClangSwitchStmt_isAllEnumCasesCovered(stmt)) { |
| 3296 | AstNode *prong_node = trans_create_node(c, NodeTypeSwitchProng); | 3320 | AstNode *prong_node = trans_create_node(c, NodeTypeSwitchProng); |
| 3297 | prong_node->data.switch_prong.expr = trans_create_node_break(c, end_label_name, nullptr); | 3321 | prong_node->data.switch_prong.expr = trans_create_node_break(c, end_label_name, nullptr); |
| 3298 | switch_scope->switch_node->data.switch_expr.prongs.append(prong_node); | 3322 | switch_scope->switch_node->data.switch_expr.prongs.append(prong_node); |
| ... | @@ -3311,12 +3335,12 @@ static TransScopeSwitch *trans_scope_switch_find(TransScope *scope) { | ... | @@ -3311,12 +3335,12 @@ static TransScopeSwitch *trans_scope_switch_find(TransScope *scope) { |
| 3311 | return nullptr; | 3335 | return nullptr; |
| 3312 | } | 3336 | } |
| 3313 | | 3337 | |
| 3314 | static int trans_switch_case(Context *c, TransScope *parent_scope, const clang::CaseStmt *stmt, AstNode **out_node, | 3338 | static int trans_switch_case(Context *c, TransScope *parent_scope, const ZigClangCaseStmt *stmt, AstNode **out_node, |
| 3315 | TransScope **out_scope) { | 3339 | TransScope **out_scope) { |
| 3316 | *out_node = nullptr; | 3340 | *out_node = nullptr; |
| 3317 | | 3341 | |
| 3318 | if (stmt->getRHS() != nullptr) { | 3342 | if (ZigClangCaseStmt_getRHS(stmt) != nullptr) { |
| 3319 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO support GNU switch case a ... b extension"); | 3343 | emit_warning(c, ZigClangCaseStmt_getBeginLoc(stmt), "TODO support GNU switch case a ... b extension"); |
| 3320 | return ErrorUnexpected; | 3344 | return ErrorUnexpected; |
| 3321 | } | 3345 | } |
| 3322 | | 3346 | |
| ... | @@ -3329,7 +3353,8 @@ static int trans_switch_case(Context *c, TransScope *parent_scope, const clang:: | ... | @@ -3329,7 +3353,8 @@ static int trans_switch_case(Context *c, TransScope *parent_scope, const clang:: |
| 3329 | { | 3353 | { |
| 3330 | // Add the prong | 3354 | // Add the prong |
| 3331 | AstNode *prong_node = trans_create_node(c, NodeTypeSwitchProng); | 3355 | AstNode *prong_node = trans_create_node(c, NodeTypeSwitchProng); |
| 3332 | AstNode *item_node = trans_expr(c, ResultUsedYes, &switch_scope->base, bitcast(stmt->getLHS()), TransRValue); | 3356 | AstNode *item_node = trans_expr(c, ResultUsedYes, &switch_scope->base, ZigClangCaseStmt_getLHS(stmt), |
| | 3357 | TransRValue); |
| 3333 | if (item_node == nullptr) | 3358 | if (item_node == nullptr) |
| 3334 | return ErrorUnexpected; | 3359 | return ErrorUnexpected; |
| 3335 | prong_node->data.switch_prong.items.append(item_node); | 3360 | prong_node->data.switch_prong.items.append(item_node); |
| ... | @@ -3346,7 +3371,7 @@ static int trans_switch_case(Context *c, TransScope *parent_scope, const clang:: | ... | @@ -3346,7 +3371,7 @@ static int trans_switch_case(Context *c, TransScope *parent_scope, const clang:: |
| 3346 | scope_block->node->data.block.statements.append(case_block); | 3371 | scope_block->node->data.block.statements.append(case_block); |
| 3347 | | 3372 | |
| 3348 | AstNode *sub_stmt_node; | 3373 | AstNode *sub_stmt_node; |
| 3349 | TransScope *new_scope = trans_stmt(c, parent_scope, bitcast(stmt->getSubStmt()), &sub_stmt_node); | 3374 | TransScope *new_scope = trans_stmt(c, parent_scope, ZigClangCaseStmt_getSubStmt(stmt), &sub_stmt_node); |
| 3350 | if (new_scope == nullptr) | 3375 | if (new_scope == nullptr) |
| 3351 | return ErrorUnexpected; | 3376 | return ErrorUnexpected; |
| 3352 | if (sub_stmt_node != nullptr) | 3377 | if (sub_stmt_node != nullptr) |
| ... | @@ -3356,8 +3381,8 @@ static int trans_switch_case(Context *c, TransScope *parent_scope, const clang:: | ... | @@ -3356,8 +3381,8 @@ static int trans_switch_case(Context *c, TransScope *parent_scope, const clang:: |
| 3356 | return ErrorNone; | 3381 | return ErrorNone; |
| 3357 | } | 3382 | } |
| 3358 | | 3383 | |
| 3359 | static int trans_switch_default(Context *c, TransScope *parent_scope, const clang::DefaultStmt *stmt, AstNode **out_node, | 3384 | static int trans_switch_default(Context *c, TransScope *parent_scope, const ZigClangDefaultStmt *stmt, |
| 3360 | TransScope **out_scope) | 3385 | AstNode **out_node, TransScope **out_scope) |
| 3361 | { | 3386 | { |
| 3362 | *out_node = nullptr; | 3387 | *out_node = nullptr; |
| 3363 | | 3388 | |
| ... | @@ -3383,7 +3408,7 @@ static int trans_switch_default(Context *c, TransScope *parent_scope, const clan | ... | @@ -3383,7 +3408,7 @@ static int trans_switch_default(Context *c, TransScope *parent_scope, const clan |
| 3383 | scope_block->node->data.block.statements.append(case_block); | 3408 | scope_block->node->data.block.statements.append(case_block); |
| 3384 | | 3409 | |
| 3385 | AstNode *sub_stmt_node; | 3410 | AstNode *sub_stmt_node; |
| 3386 | TransScope *new_scope = trans_stmt(c, parent_scope, bitcast(stmt->getSubStmt()), &sub_stmt_node); | 3411 | TransScope *new_scope = trans_stmt(c, parent_scope, ZigClangDefaultStmt_getSubStmt(stmt), &sub_stmt_node); |
| 3387 | if (new_scope == nullptr) | 3412 | if (new_scope == nullptr) |
| 3388 | return ErrorUnexpected; | 3413 | return ErrorUnexpected; |
| 3389 | if (sub_stmt_node != nullptr) | 3414 | if (sub_stmt_node != nullptr) |
| ... | @@ -3393,7 +3418,9 @@ static int trans_switch_default(Context *c, TransScope *parent_scope, const clan | ... | @@ -3393,7 +3418,9 @@ static int trans_switch_default(Context *c, TransScope *parent_scope, const clan |
| 3393 | return ErrorNone; | 3418 | return ErrorNone; |
| 3394 | } | 3419 | } |
| 3395 | | 3420 | |
| 3396 | static AstNode *trans_string_literal(Context *c, ResultUsed result_used, TransScope *scope, const ZigClangStringLiteral *stmt) { | 3421 | static AstNode *trans_string_literal(Context *c, ResultUsed result_used, TransScope *scope, |
| | 3422 | const ZigClangStringLiteral *stmt) |
| | 3423 | { |
| 3397 | switch (ZigClangStringLiteral_getKind(stmt)) { | 3424 | switch (ZigClangStringLiteral_getKind(stmt)) { |
| 3398 | case ZigClangStringLiteral_StringKind_Ascii: | 3425 | case ZigClangStringLiteral_StringKind_Ascii: |
| 3399 | case ZigClangStringLiteral_StringKind_UTF8: { | 3426 | case ZigClangStringLiteral_StringKind_UTF8: { |
| ... | @@ -3415,7 +3442,7 @@ static AstNode *trans_string_literal(Context *c, ResultUsed result_used, TransSc | ... | @@ -3415,7 +3442,7 @@ static AstNode *trans_string_literal(Context *c, ResultUsed result_used, TransSc |
| 3415 | zig_unreachable(); | 3442 | zig_unreachable(); |
| 3416 | } | 3443 | } |
| 3417 | | 3444 | |
| 3418 | static AstNode *trans_break_stmt(Context *c, TransScope *scope, const clang::BreakStmt *stmt) { | 3445 | static AstNode *trans_break_stmt(Context *c, TransScope *scope, const ZigClangBreakStmt *stmt) { |
| 3419 | TransScope *cur_scope = scope; | 3446 | TransScope *cur_scope = scope; |
| 3420 | while (cur_scope != nullptr) { | 3447 | while (cur_scope != nullptr) { |
| 3421 | if (cur_scope->id == TransScopeIdWhile) { | 3448 | if (cur_scope->id == TransScopeIdWhile) { |
| ... | @@ -3457,38 +3484,38 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3457,38 +3484,38 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3457 | switch (sc) { | 3484 | switch (sc) { |
| 3458 | case ZigClangStmt_ReturnStmtClass: | 3485 | case ZigClangStmt_ReturnStmtClass: |
| 3459 | return wrap_stmt(out_node, out_child_scope, scope, | 3486 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3460 | trans_return_stmt(c, scope, (const clang::ReturnStmt *)stmt)); | 3487 | trans_return_stmt(c, scope, (const ZigClangReturnStmt *)stmt)); |
| 3461 | case ZigClangStmt_CompoundStmtClass: | 3488 | case ZigClangStmt_CompoundStmtClass: |
| 3462 | return wrap_stmt(out_node, out_child_scope, scope, | 3489 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3463 | trans_compound_stmt(c, scope, (const ZigClangCompoundStmt *)stmt, out_node_scope)); | 3490 | trans_compound_stmt(c, scope, (const ZigClangCompoundStmt *)stmt, out_node_scope)); |
| 3464 | case ZigClangStmt_IntegerLiteralClass: | 3491 | case ZigClangStmt_IntegerLiteralClass: |
| 3465 | return wrap_stmt(out_node, out_child_scope, scope, | 3492 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3466 | trans_integer_literal(c, result_used, (const clang::IntegerLiteral *)stmt)); | 3493 | trans_integer_literal(c, result_used, (const ZigClangIntegerLiteral *)stmt)); |
| 3467 | case ZigClangStmt_ConditionalOperatorClass: | 3494 | case ZigClangStmt_ConditionalOperatorClass: |
| 3468 | return wrap_stmt(out_node, out_child_scope, scope, | 3495 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3469 | trans_conditional_operator(c, result_used, scope, (const clang::ConditionalOperator *)stmt)); | 3496 | trans_conditional_operator(c, result_used, scope, (const ZigClangConditionalOperator *)stmt)); |
| 3470 | case ZigClangStmt_BinaryOperatorClass: | 3497 | case ZigClangStmt_BinaryOperatorClass: |
| 3471 | return wrap_stmt(out_node, out_child_scope, scope, | 3498 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3472 | trans_binary_operator(c, result_used, scope, (const clang::BinaryOperator *)stmt)); | 3499 | trans_binary_operator(c, result_used, scope, (const ZigClangBinaryOperator *)stmt)); |
| 3473 | case ZigClangStmt_CompoundAssignOperatorClass: | 3500 | case ZigClangStmt_CompoundAssignOperatorClass: |
| 3474 | return wrap_stmt(out_node, out_child_scope, scope, | 3501 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3475 | trans_compound_assign_operator(c, result_used, scope, (const clang::CompoundAssignOperator *)stmt)); | 3502 | trans_compound_assign_operator(c, result_used, scope, (const ZigClangCompoundAssignOperator *)stmt)); |
| 3476 | case ZigClangStmt_ImplicitCastExprClass: | 3503 | case ZigClangStmt_ImplicitCastExprClass: |
| 3477 | return wrap_stmt(out_node, out_child_scope, scope, | 3504 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3478 | trans_implicit_cast_expr(c, result_used, scope, (const ZigClangImplicitCastExpr *)stmt)); | 3505 | trans_implicit_cast_expr(c, result_used, scope, (const ZigClangImplicitCastExpr *)stmt)); |
| 3479 | case ZigClangStmt_DeclRefExprClass: | 3506 | case ZigClangStmt_DeclRefExprClass: |
| 3480 | return wrap_stmt(out_node, out_child_scope, scope, | 3507 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3481 | trans_decl_ref_expr(c, scope, (const clang::DeclRefExpr *)stmt, lrvalue)); | 3508 | trans_decl_ref_expr(c, scope, (const ZigClangDeclRefExpr *)stmt, lrvalue)); |
| 3482 | case ZigClangStmt_UnaryOperatorClass: | 3509 | case ZigClangStmt_UnaryOperatorClass: |
| 3483 | return wrap_stmt(out_node, out_child_scope, scope, | 3510 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3484 | trans_unary_operator(c, result_used, scope, (const clang::UnaryOperator *)stmt)); | 3511 | trans_unary_operator(c, result_used, scope, (const ZigClangUnaryOperator *)stmt)); |
| 3485 | case ZigClangStmt_DeclStmtClass: | 3512 | case ZigClangStmt_DeclStmtClass: |
| 3486 | return trans_local_declaration(c, scope, (const clang::DeclStmt *)stmt, out_node, out_child_scope); | 3513 | return trans_local_declaration(c, scope, (const ZigClangDeclStmt *)stmt, out_node, out_child_scope); |
| 3487 | case ZigClangStmt_DoStmtClass: | 3514 | case ZigClangStmt_DoStmtClass: |
| 3488 | case ZigClangStmt_WhileStmtClass: { | 3515 | case ZigClangStmt_WhileStmtClass: { |
| 3489 | AstNode *while_node = sc == ZigClangStmt_DoStmtClass | 3516 | AstNode *while_node = sc == ZigClangStmt_DoStmtClass |
| 3490 | ? trans_do_loop(c, scope, (const clang::DoStmt *)stmt) | 3517 | ? trans_do_loop(c, scope, (const ZigClangDoStmt *)stmt) |
| 3491 | : trans_while_loop(c, scope, (const clang::WhileStmt *)stmt); | 3518 | : trans_while_loop(c, scope, (const ZigClangWhileStmt *)stmt); |
| 3492 | | 3519 | |
| 3493 | if (while_node == nullptr) | 3520 | if (while_node == nullptr) |
| 3494 | return ErrorUnexpected; | 3521 | return ErrorUnexpected; |
| ... | @@ -3501,28 +3528,28 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3501,28 +3528,28 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3501 | } | 3528 | } |
| 3502 | case ZigClangStmt_IfStmtClass: | 3529 | case ZigClangStmt_IfStmtClass: |
| 3503 | return wrap_stmt(out_node, out_child_scope, scope, | 3530 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3504 | trans_if_statement(c, scope, (const clang::IfStmt *)stmt)); | 3531 | trans_if_statement(c, scope, (const ZigClangIfStmt *)stmt)); |
| 3505 | case ZigClangStmt_CallExprClass: | 3532 | case ZigClangStmt_CallExprClass: |
| 3506 | return wrap_stmt(out_node, out_child_scope, scope, | 3533 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3507 | trans_call_expr(c, result_used, scope, (const clang::CallExpr *)stmt)); | 3534 | trans_call_expr(c, result_used, scope, (const ZigClangCallExpr *)stmt)); |
| 3508 | case ZigClangStmt_NullStmtClass: | 3535 | case ZigClangStmt_NullStmtClass: |
| 3509 | *out_node = trans_create_node(c, NodeTypeBlock); | 3536 | *out_node = trans_create_node(c, NodeTypeBlock); |
| 3510 | *out_child_scope = scope; | 3537 | *out_child_scope = scope; |
| 3511 | return ErrorNone; | 3538 | return ErrorNone; |
| 3512 | case ZigClangStmt_MemberExprClass: | 3539 | case ZigClangStmt_MemberExprClass: |
| 3513 | return wrap_stmt(out_node, out_child_scope, scope, | 3540 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3514 | trans_member_expr(c, result_used, scope, (const clang::MemberExpr *)stmt)); | 3541 | trans_member_expr(c, result_used, scope, (const ZigClangMemberExpr *)stmt)); |
| 3515 | case ZigClangStmt_ArraySubscriptExprClass: | 3542 | case ZigClangStmt_ArraySubscriptExprClass: |
| 3516 | return wrap_stmt(out_node, out_child_scope, scope, | 3543 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3517 | trans_array_subscript_expr(c, result_used, scope, (const clang::ArraySubscriptExpr *)stmt)); | 3544 | trans_array_subscript_expr(c, result_used, scope, (const ZigClangArraySubscriptExpr *)stmt)); |
| 3518 | case ZigClangStmt_CStyleCastExprClass: | 3545 | case ZigClangStmt_CStyleCastExprClass: |
| 3519 | return wrap_stmt(out_node, out_child_scope, scope, | 3546 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3520 | trans_c_style_cast_expr(c, result_used, scope, (const clang::CStyleCastExpr *)stmt, lrvalue)); | 3547 | trans_c_style_cast_expr(c, result_used, scope, (const ZigClangCStyleCastExpr *)stmt, lrvalue)); |
| 3521 | case ZigClangStmt_UnaryExprOrTypeTraitExprClass: | 3548 | case ZigClangStmt_UnaryExprOrTypeTraitExprClass: |
| 3522 | return wrap_stmt(out_node, out_child_scope, scope, | 3549 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3523 | trans_unary_expr_or_type_trait_expr(c, result_used, scope, (const clang::UnaryExprOrTypeTraitExpr *)stmt)); | 3550 | trans_unary_expr_or_type_trait_expr(c, result_used, scope, (const ZigClangUnaryExprOrTypeTraitExpr *)stmt)); |
| 3524 | case ZigClangStmt_ForStmtClass: { | 3551 | case ZigClangStmt_ForStmtClass: { |
| 3525 | AstNode *node = trans_for_loop(c, scope, (const clang::ForStmt *)stmt); | 3552 | AstNode *node = trans_for_loop(c, scope, (const ZigClangForStmt *)stmt); |
| 3526 | return wrap_stmt(out_node, out_child_scope, scope, node); | 3553 | return wrap_stmt(out_node, out_child_scope, scope, node); |
| 3527 | } | 3554 | } |
| 3528 | case ZigClangStmt_StringLiteralClass: | 3555 | case ZigClangStmt_StringLiteralClass: |
| ... | @@ -3530,30 +3557,30 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3530,30 +3557,30 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3530 | trans_string_literal(c, result_used, scope, (const ZigClangStringLiteral *)stmt)); | 3557 | trans_string_literal(c, result_used, scope, (const ZigClangStringLiteral *)stmt)); |
| 3531 | case ZigClangStmt_BreakStmtClass: | 3558 | case ZigClangStmt_BreakStmtClass: |
| 3532 | return wrap_stmt(out_node, out_child_scope, scope, | 3559 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3533 | trans_break_stmt(c, scope, (const clang::BreakStmt *)stmt)); | 3560 | trans_break_stmt(c, scope, (const ZigClangBreakStmt *)stmt)); |
| 3534 | case ZigClangStmt_ContinueStmtClass: | 3561 | case ZigClangStmt_ContinueStmtClass: |
| 3535 | return wrap_stmt(out_node, out_child_scope, scope, | 3562 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3536 | trans_continue_stmt(c, scope, (const ZigClangContinueStmt *)stmt)); | 3563 | trans_continue_stmt(c, scope, (const ZigClangContinueStmt *)stmt)); |
| 3537 | case ZigClangStmt_ParenExprClass: | 3564 | case ZigClangStmt_ParenExprClass: |
| 3538 | return wrap_stmt(out_node, out_child_scope, scope, | 3565 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3539 | trans_expr(c, result_used, scope, | 3566 | trans_expr(c, result_used, scope, |
| 3540 | bitcast(((const clang::ParenExpr*)stmt)->getSubExpr()), lrvalue)); | 3567 | ZigClangParenExpr_getSubExpr((const ZigClangParenExpr *)stmt), lrvalue)); |
| 3541 | case ZigClangStmt_SwitchStmtClass: | 3568 | case ZigClangStmt_SwitchStmtClass: |
| 3542 | return wrap_stmt(out_node, out_child_scope, scope, | 3569 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3543 | trans_switch_stmt(c, scope, (const clang::SwitchStmt *)stmt)); | 3570 | trans_switch_stmt(c, scope, (const ZigClangSwitchStmt *)stmt)); |
| 3544 | case ZigClangStmt_CaseStmtClass: | 3571 | case ZigClangStmt_CaseStmtClass: |
| 3545 | return trans_switch_case(c, scope, (const clang::CaseStmt *)stmt, out_node, out_child_scope); | 3572 | return trans_switch_case(c, scope, (const ZigClangCaseStmt *)stmt, out_node, out_child_scope); |
| 3546 | case ZigClangStmt_DefaultStmtClass: | 3573 | case ZigClangStmt_DefaultStmtClass: |
| 3547 | return trans_switch_default(c, scope, (const clang::DefaultStmt *)stmt, out_node, out_child_scope); | 3574 | return trans_switch_default(c, scope, (const ZigClangDefaultStmt *)stmt, out_node, out_child_scope); |
| 3548 | case ZigClangStmt_ConstantExprClass: | 3575 | case ZigClangStmt_ConstantExprClass: |
| 3549 | return wrap_stmt(out_node, out_child_scope, scope, | 3576 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3550 | trans_constant_expr(c, result_used, (const clang::ConstantExpr *)stmt)); | 3577 | trans_constant_expr(c, result_used, (const ZigClangConstantExpr *)stmt)); |
| 3551 | case ZigClangStmt_PredefinedExprClass: | 3578 | case ZigClangStmt_PredefinedExprClass: |
| 3552 | return wrap_stmt(out_node, out_child_scope, scope, | 3579 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3553 | trans_predefined_expr(c, result_used, scope, (const ZigClangPredefinedExpr *)stmt)); | 3580 | trans_predefined_expr(c, result_used, scope, (const ZigClangPredefinedExpr *)stmt)); |
| 3554 | case ZigClangStmt_StmtExprClass: | 3581 | case ZigClangStmt_StmtExprClass: |
| 3555 | return wrap_stmt(out_node, out_child_scope, scope, | 3582 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3556 | trans_stmt_expr(c, result_used, scope, (const clang::StmtExpr *)stmt, out_node_scope)); | 3583 | trans_stmt_expr(c, result_used, scope, (const ZigClangStmtExpr *)stmt, out_node_scope)); |
| 3557 | case ZigClangStmt_NoStmtClass: | 3584 | case ZigClangStmt_NoStmtClass: |
| 3558 | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C NoStmtClass"); | 3585 | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C NoStmtClass"); |
| 3559 | return ErrorUnexpected; | 3586 | return ErrorUnexpected; |
| ... | @@ -3703,7 +3730,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3703,7 +3730,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3703 | return ErrorUnexpected; | 3730 | return ErrorUnexpected; |
| 3704 | case ZigClangStmt_CharacterLiteralClass: | 3731 | case ZigClangStmt_CharacterLiteralClass: |
| 3705 | return wrap_stmt(out_node, out_child_scope, scope, | 3732 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3706 | trans_character_literal(c, result_used, (const clang::CharacterLiteral *)stmt)); | 3733 | trans_character_literal(c, result_used, (const ZigClangCharacterLiteral *)stmt)); |
| 3707 | return ErrorUnexpected; | 3734 | return ErrorUnexpected; |
| 3708 | case ZigClangStmt_ChooseExprClass: | 3735 | case ZigClangStmt_ChooseExprClass: |
| 3709 | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C ChooseExprClass"); | 3736 | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C ChooseExprClass"); |
| ... | @@ -3743,7 +3770,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3743,7 +3770,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3743 | return ErrorUnexpected; | 3770 | return ErrorUnexpected; |
| 3744 | case ZigClangStmt_FloatingLiteralClass: | 3771 | case ZigClangStmt_FloatingLiteralClass: |
| 3745 | return wrap_stmt(out_node, out_child_scope, scope, | 3772 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3746 | trans_floating_literal(c, result_used, (const clang::FloatingLiteral *)stmt)); | 3773 | trans_floating_literal(c, result_used, (const ZigClangFloatingLiteral *)stmt)); |
| 3747 | case ZigClangStmt_ExprWithCleanupsClass: | 3774 | case ZigClangStmt_ExprWithCleanupsClass: |
| 3748 | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C ExprWithCleanupsClass"); | 3775 | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C ExprWithCleanupsClass"); |
| 3749 | return ErrorUnexpected; | 3776 | return ErrorUnexpected; |