| ... | @@ -121,15 +121,20 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -121,15 +121,20 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 121 | AstNode **out_node, TransScope **out_child_scope, | 121 | AstNode **out_node, TransScope **out_child_scope, |
| 122 | TransScope **out_node_scope); | 122 | TransScope **out_node_scope); |
| 123 | static TransScope *trans_stmt(Context *c, TransScope *scope, const ZigClangStmt *stmt, AstNode **out_node); | 123 | static TransScope *trans_stmt(Context *c, TransScope *scope, const ZigClangStmt *stmt, AstNode **out_node); |
| 124 | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::Expr *expr, TransLRValue lrval); | 124 | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const ZigClangExpr *expr, TransLRValue lrval); |
| 125 | static AstNode *trans_qual_type(Context *c, ZigClangQualType qt, ZigClangSourceLocation source_loc); | 125 | static AstNode *trans_qual_type(Context *c, ZigClangQualType qt, ZigClangSourceLocation source_loc); |
| 126 | static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::Expr *expr, TransLRValue lrval); | 126 | static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, |
| | 127 | const ZigClangExpr *expr, TransLRValue lrval); |
| 127 | static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQualType qt, ZigClangSourceLocation source_loc); | 128 | static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQualType qt, ZigClangSourceLocation source_loc); |
| 128 | | 129 | |
| 129 | static const ZigClangStmt *bitcast(const clang::Stmt *src) { | 130 | static const ZigClangStmt *bitcast(const clang::Stmt *src) { |
| 130 | return reinterpret_cast<const ZigClangStmt *>(src); | 131 | return reinterpret_cast<const ZigClangStmt *>(src); |
| 131 | } | 132 | } |
| 132 | | 133 | |
| | 134 | static const ZigClangExpr *bitcast(const clang::Expr *src) { |
| | 135 | return reinterpret_cast<const ZigClangExpr *>(src); |
| | 136 | } |
| | 137 | |
| 133 | static ZigClangSourceLocation bitcast(clang::SourceLocation src) { | 138 | static ZigClangSourceLocation bitcast(clang::SourceLocation src) { |
| 134 | ZigClangSourceLocation dest; | 139 | ZigClangSourceLocation dest; |
| 135 | memcpy(&dest, static_cast<void *>(&src), sizeof(ZigClangSourceLocation)); | 140 | memcpy(&dest, static_cast<void *>(&src), sizeof(ZigClangSourceLocation)); |
| ... | @@ -511,14 +516,14 @@ static const ZigClangType *qual_type_canon(ZigClangQualType qt) { | ... | @@ -511,14 +516,14 @@ static const ZigClangType *qual_type_canon(ZigClangQualType qt) { |
| 511 | return ZigClangQualType_getTypePtr(canon); | 516 | return ZigClangQualType_getTypePtr(canon); |
| 512 | } | 517 | } |
| 513 | | 518 | |
| 514 | static ZigClangQualType get_expr_qual_type(Context *c, const clang::Expr *expr) { | 519 | static ZigClangQualType get_expr_qual_type(Context *c, const ZigClangExpr *expr) { |
| 515 | // String literals in C are `char *` but they should really be `const char *`. | 520 | // String literals in C are `char *` but they should really be `const char *`. |
| 516 | if ((ZigClangStmtClass)expr->getStmtClass() == ZigClangStmt_ImplicitCastExprClass) { | 521 | if (ZigClangExpr_getStmtClass(expr) == ZigClangStmt_ImplicitCastExprClass) { |
| 517 | const clang::ImplicitCastExpr *cast_expr = static_cast<const clang::ImplicitCastExpr *>(expr); | 522 | const clang::ImplicitCastExpr *cast_expr = reinterpret_cast<const clang::ImplicitCastExpr *>(expr); |
| 518 | if (cast_expr->getCastKind() == clang::CK_ArrayToPointerDecay) { | 523 | if ((ZigClangCK)cast_expr->getCastKind() == ZigClangCK_ArrayToPointerDecay) { |
| 519 | const clang::Expr *sub_expr = cast_expr->getSubExpr(); | 524 | const ZigClangExpr *sub_expr = bitcast(cast_expr->getSubExpr()); |
| 520 | if ((ZigClangStmtClass)sub_expr->getStmtClass() == ZigClangStmt_StringLiteralClass) { | 525 | if (ZigClangExpr_getStmtClass(sub_expr) == ZigClangStmt_StringLiteralClass) { |
| 521 | ZigClangQualType array_qt = bitcast(sub_expr->getType()); | 526 | ZigClangQualType array_qt = ZigClangExpr_getType(sub_expr); |
| 522 | const clang::ArrayType *array_type = reinterpret_cast<const clang::ArrayType *>( | 527 | const clang::ArrayType *array_type = reinterpret_cast<const clang::ArrayType *>( |
| 523 | ZigClangQualType_getTypePtr(array_qt)); | 528 | ZigClangQualType_getTypePtr(array_qt)); |
| 524 | ZigClangQualType pointee_qt = bitcast(array_type->getElementType()); | 529 | ZigClangQualType pointee_qt = bitcast(array_type->getElementType()); |
| ... | @@ -527,26 +532,26 @@ static ZigClangQualType get_expr_qual_type(Context *c, const clang::Expr *expr) | ... | @@ -527,26 +532,26 @@ static ZigClangQualType get_expr_qual_type(Context *c, const clang::Expr *expr) |
| 527 | } | 532 | } |
| 528 | } | 533 | } |
| 529 | } | 534 | } |
| 530 | return bitcast(expr->getType()); | 535 | return ZigClangExpr_getType(expr); |
| 531 | } | 536 | } |
| 532 | | 537 | |
| 533 | static ZigClangQualType get_expr_qual_type_before_implicit_cast(Context *c, const clang::Expr *expr) { | 538 | static ZigClangQualType get_expr_qual_type_before_implicit_cast(Context *c, const ZigClangExpr *expr) { |
| 534 | if ((ZigClangStmtClass)expr->getStmtClass() == ZigClangStmt_ImplicitCastExprClass) { | 539 | if (ZigClangExpr_getStmtClass(expr) == ZigClangStmt_ImplicitCastExprClass) { |
| 535 | const clang::ImplicitCastExpr *cast_expr = static_cast<const clang::ImplicitCastExpr *>(expr); | 540 | const clang::ImplicitCastExpr *cast_expr = reinterpret_cast<const clang::ImplicitCastExpr *>(expr); |
| 536 | return get_expr_qual_type(c, cast_expr->getSubExpr()); | 541 | return get_expr_qual_type(c, bitcast(cast_expr->getSubExpr())); |
| 537 | } | 542 | } |
| 538 | return bitcast(expr->getType()); | 543 | return ZigClangExpr_getType(expr); |
| 539 | } | 544 | } |
| 540 | | 545 | |
| 541 | static AstNode *get_expr_type(Context *c, const clang::Expr *expr) { | 546 | static AstNode *get_expr_type(Context *c, const ZigClangExpr *expr) { |
| 542 | return trans_qual_type(c, get_expr_qual_type(c, expr), bitcast(expr->getBeginLoc())); | 547 | return trans_qual_type(c, get_expr_qual_type(c, expr), ZigClangExpr_getBeginLoc(expr)); |
| 543 | } | 548 | } |
| 544 | | 549 | |
| 545 | static bool is_c_void_type(AstNode *node) { | 550 | static bool is_c_void_type(AstNode *node) { |
| 546 | return (node->type == NodeTypeSymbol && buf_eql_str(node->data.symbol_expr.symbol, "c_void")); | 551 | return (node->type == NodeTypeSymbol && buf_eql_str(node->data.symbol_expr.symbol, "c_void")); |
| 547 | } | 552 | } |
| 548 | | 553 | |
| 549 | static bool expr_types_equal(Context *c, const clang::Expr *expr1, const clang::Expr *expr2) { | 554 | static bool expr_types_equal(Context *c, const ZigClangExpr *expr1, const ZigClangExpr *expr2) { |
| 550 | ZigClangQualType t1 = get_expr_qual_type(c, expr1); | 555 | ZigClangQualType t1 = get_expr_qual_type(c, expr1); |
| 551 | ZigClangQualType t2 = get_expr_qual_type(c, expr2); | 556 | ZigClangQualType t2 = get_expr_qual_type(c, expr2); |
| 552 | | 557 | |
| ... | @@ -1272,7 +1277,7 @@ static AstNode *trans_stmt_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -1272,7 +1277,7 @@ static AstNode *trans_stmt_expr(Context *c, ResultUsed result_used, TransScope * |
| 1272 | } | 1277 | } |
| 1273 | | 1278 | |
| 1274 | static AstNode *trans_return_stmt(Context *c, TransScope *scope, const clang::ReturnStmt *stmt) { | 1279 | static AstNode *trans_return_stmt(Context *c, TransScope *scope, const clang::ReturnStmt *stmt) { |
| 1275 | const clang::Expr *value_expr = stmt->getRetValue(); | 1280 | const ZigClangExpr *value_expr = bitcast(stmt->getRetValue()); |
| 1276 | if (value_expr == nullptr) { | 1281 | if (value_expr == nullptr) { |
| 1277 | return trans_create_node(c, NodeTypeReturnExpr); | 1282 | return trans_create_node(c, NodeTypeReturnExpr); |
| 1278 | } else { | 1283 | } else { |
| ... | @@ -1311,9 +1316,9 @@ static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, T | ... | @@ -1311,9 +1316,9 @@ static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, T |
| 1311 | { | 1316 | { |
| 1312 | AstNode *node = trans_create_node(c, NodeTypeIfBoolExpr); | 1317 | AstNode *node = trans_create_node(c, NodeTypeIfBoolExpr); |
| 1313 | | 1318 | |
| 1314 | clang::Expr *cond_expr = stmt->getCond(); | 1319 | const ZigClangExpr *cond_expr = bitcast(stmt->getCond()); |
| 1315 | clang::Expr *true_expr = stmt->getTrueExpr(); | 1320 | const ZigClangExpr *true_expr = bitcast(stmt->getTrueExpr()); |
| 1316 | clang::Expr *false_expr = stmt->getFalseExpr(); | 1321 | const ZigClangExpr *false_expr = bitcast(stmt->getFalseExpr()); |
| 1317 | | 1322 | |
| 1318 | node->data.if_bool_expr.condition = trans_expr(c, ResultUsedYes, scope, cond_expr, TransRValue); | 1323 | node->data.if_bool_expr.condition = trans_expr(c, ResultUsedYes, scope, cond_expr, TransRValue); |
| 1319 | if (node->data.if_bool_expr.condition == nullptr) | 1324 | if (node->data.if_bool_expr.condition == nullptr) |
| ... | @@ -1330,7 +1335,9 @@ static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, T | ... | @@ -1330,7 +1335,9 @@ static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, T |
| 1330 | return maybe_suppress_result(c, result_used, node); | 1335 | return maybe_suppress_result(c, result_used, node); |
| 1331 | } | 1336 | } |
| 1332 | | 1337 | |
| 1333 | static AstNode *trans_create_bin_op(Context *c, TransScope *scope, clang::Expr *lhs, BinOpType bin_op, clang::Expr *rhs) { | 1338 | static AstNode *trans_create_bin_op(Context *c, TransScope *scope, const ZigClangExpr *lhs, |
| | 1339 | BinOpType bin_op, const ZigClangExpr *rhs) |
| | 1340 | { |
| 1334 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); | 1341 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); |
| 1335 | node->data.bin_op_expr.bin_op = bin_op; | 1342 | node->data.bin_op_expr.bin_op = bin_op; |
| 1336 | | 1343 | |
| ... | @@ -1345,7 +1352,9 @@ static AstNode *trans_create_bin_op(Context *c, TransScope *scope, clang::Expr * | ... | @@ -1345,7 +1352,9 @@ static AstNode *trans_create_bin_op(Context *c, TransScope *scope, clang::Expr * |
| 1345 | return node; | 1352 | return node; |
| 1346 | } | 1353 | } |
| 1347 | | 1354 | |
| 1348 | static AstNode *trans_create_bool_bin_op(Context *c, TransScope *scope, clang::Expr *lhs, BinOpType bin_op, clang::Expr *rhs) { | 1355 | static AstNode *trans_create_bool_bin_op(Context *c, TransScope *scope, const ZigClangExpr *lhs, |
| | 1356 | BinOpType bin_op, const ZigClangExpr *rhs) |
| | 1357 | { |
| 1349 | assert(bin_op == BinOpTypeBoolAnd || bin_op == BinOpTypeBoolOr); | 1358 | assert(bin_op == BinOpTypeBoolAnd || bin_op == BinOpTypeBoolOr); |
| 1350 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); | 1359 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); |
| 1351 | node->data.bin_op_expr.bin_op = bin_op; | 1360 | node->data.bin_op_expr.bin_op = bin_op; |
| ... | @@ -1361,7 +1370,9 @@ static AstNode *trans_create_bool_bin_op(Context *c, TransScope *scope, clang::E | ... | @@ -1361,7 +1370,9 @@ static AstNode *trans_create_bool_bin_op(Context *c, TransScope *scope, clang::E |
| 1361 | return node; | 1370 | return node; |
| 1362 | } | 1371 | } |
| 1363 | | 1372 | |
| 1364 | static AstNode *trans_create_assign(Context *c, ResultUsed result_used, TransScope *scope, clang::Expr *lhs, clang::Expr *rhs) { | 1373 | static AstNode *trans_create_assign(Context *c, ResultUsed result_used, TransScope *scope, |
| | 1374 | const ZigClangExpr *lhs, const ZigClangExpr *rhs) |
| | 1375 | { |
| 1365 | if (result_used == ResultUsedNo) { | 1376 | if (result_used == ResultUsedNo) { |
| 1366 | // common case | 1377 | // common case |
| 1367 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); | 1378 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); |
| ... | @@ -1413,9 +1424,9 @@ static AstNode *trans_create_assign(Context *c, ResultUsed result_used, TransSco | ... | @@ -1413,9 +1424,9 @@ static AstNode *trans_create_assign(Context *c, ResultUsed result_used, TransSco |
| 1413 | } | 1424 | } |
| 1414 | | 1425 | |
| 1415 | static AstNode *trans_create_shift_op(Context *c, TransScope *scope, ZigClangQualType result_type, | 1426 | static AstNode *trans_create_shift_op(Context *c, TransScope *scope, ZigClangQualType result_type, |
| 1416 | clang::Expr *lhs_expr, BinOpType bin_op, clang::Expr *rhs_expr) | 1427 | const ZigClangExpr *lhs_expr, BinOpType bin_op, const ZigClangExpr *rhs_expr) |
| 1417 | { | 1428 | { |
| 1418 | ZigClangSourceLocation rhs_location = bitcast(rhs_expr->getBeginLoc()); | 1429 | ZigClangSourceLocation rhs_location = ZigClangExpr_getBeginLoc(rhs_expr); |
| 1419 | AstNode *rhs_type = qual_type_to_log2_int_ref(c, result_type, rhs_location); | 1430 | AstNode *rhs_type = qual_type_to_log2_int_ref(c, result_type, rhs_location); |
| 1420 | // lhs >> u5(rh) | 1431 | // lhs >> u5(rh) |
| 1421 | | 1432 | |
| ... | @@ -1441,23 +1452,23 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS | ... | @@ -1441,23 +1452,23 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS |
| 1441 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C binary operators: BO_Cmp"); | 1452 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle more C binary operators: BO_Cmp"); |
| 1442 | return nullptr; | 1453 | return nullptr; |
| 1443 | case clang::BO_Mul: { | 1454 | case clang::BO_Mul: { |
| 1444 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), | 1455 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), |
| 1445 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeMultWrap : BinOpTypeMult, | 1456 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeMultWrap : BinOpTypeMult, |
| 1446 | stmt->getRHS()); | 1457 | bitcast(stmt->getRHS())); |
| 1447 | return maybe_suppress_result(c, result_used, node); | 1458 | return maybe_suppress_result(c, result_used, node); |
| 1448 | } | 1459 | } |
| 1449 | case clang::BO_Div: | 1460 | case clang::BO_Div: |
| 1450 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) { | 1461 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) { |
| 1451 | // unsigned/float division uses the operator | 1462 | // unsigned/float division uses the operator |
| 1452 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeDiv, stmt->getRHS()); | 1463 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeDiv, bitcast(stmt->getRHS())); |
| 1453 | return maybe_suppress_result(c, result_used, node); | 1464 | return maybe_suppress_result(c, result_used, node); |
| 1454 | } else { | 1465 | } else { |
| 1455 | // signed integer division uses @divTrunc | 1466 | // signed integer division uses @divTrunc |
| 1456 | AstNode *fn_call = trans_create_node_builtin_fn_call_str(c, "divTrunc"); | 1467 | AstNode *fn_call = trans_create_node_builtin_fn_call_str(c, "divTrunc"); |
| 1457 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, stmt->getLHS(), TransLValue); | 1468 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getLHS()), TransLValue); |
| 1458 | if (lhs == nullptr) return nullptr; | 1469 | if (lhs == nullptr) return nullptr; |
| 1459 | fn_call->data.fn_call_expr.params.append(lhs); | 1470 | fn_call->data.fn_call_expr.params.append(lhs); |
| 1460 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, stmt->getRHS(), TransLValue); | 1471 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getRHS()), TransLValue); |
| 1461 | if (rhs == nullptr) return nullptr; | 1472 | if (rhs == nullptr) return nullptr; |
| 1462 | fn_call->data.fn_call_expr.params.append(rhs); | 1473 | fn_call->data.fn_call_expr.params.append(rhs); |
| 1463 | return maybe_suppress_result(c, result_used, fn_call); | 1474 | return maybe_suppress_result(c, result_used, fn_call); |
| ... | @@ -1465,97 +1476,97 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS | ... | @@ -1465,97 +1476,97 @@ static AstNode *trans_binary_operator(Context *c, ResultUsed result_used, TransS |
| 1465 | case clang::BO_Rem: | 1476 | case clang::BO_Rem: |
| 1466 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) { | 1477 | if (qual_type_has_wrapping_overflow(c, bitcast(stmt->getType()))) { |
| 1467 | // unsigned/float division uses the operator | 1478 | // unsigned/float division uses the operator |
| 1468 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeMod, stmt->getRHS()); | 1479 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeMod, bitcast(stmt->getRHS())); |
| 1469 | return maybe_suppress_result(c, result_used, node); | 1480 | return maybe_suppress_result(c, result_used, node); |
| 1470 | } else { | 1481 | } else { |
| 1471 | // signed integer division uses @rem | 1482 | // signed integer division uses @rem |
| 1472 | AstNode *fn_call = trans_create_node_builtin_fn_call_str(c, "rem"); | 1483 | AstNode *fn_call = trans_create_node_builtin_fn_call_str(c, "rem"); |
| 1473 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, stmt->getLHS(), TransLValue); | 1484 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getLHS()), TransLValue); |
| 1474 | if (lhs == nullptr) return nullptr; | 1485 | if (lhs == nullptr) return nullptr; |
| 1475 | fn_call->data.fn_call_expr.params.append(lhs); | 1486 | fn_call->data.fn_call_expr.params.append(lhs); |
| 1476 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, stmt->getRHS(), TransLValue); | 1487 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getRHS()), TransLValue); |
| 1477 | if (rhs == nullptr) return nullptr; | 1488 | if (rhs == nullptr) return nullptr; |
| 1478 | fn_call->data.fn_call_expr.params.append(rhs); | 1489 | fn_call->data.fn_call_expr.params.append(rhs); |
| 1479 | return maybe_suppress_result(c, result_used, fn_call); | 1490 | return maybe_suppress_result(c, result_used, fn_call); |
| 1480 | } | 1491 | } |
| 1481 | case clang::BO_Add: { | 1492 | case clang::BO_Add: { |
| 1482 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), | 1493 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), |
| 1483 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeAddWrap : BinOpTypeAdd, | 1494 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeAddWrap : BinOpTypeAdd, |
| 1484 | stmt->getRHS()); | 1495 | bitcast(stmt->getRHS())); |
| 1485 | return maybe_suppress_result(c, result_used, node); | 1496 | return maybe_suppress_result(c, result_used, node); |
| 1486 | } | 1497 | } |
| 1487 | case clang::BO_Sub: { | 1498 | case clang::BO_Sub: { |
| 1488 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), | 1499 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), |
| 1489 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeSubWrap : BinOpTypeSub, | 1500 | qual_type_has_wrapping_overflow(c, bitcast(stmt->getType())) ? BinOpTypeSubWrap : BinOpTypeSub, |
| 1490 | stmt->getRHS()); | 1501 | bitcast(stmt->getRHS())); |
| 1491 | return maybe_suppress_result(c, result_used, node); | 1502 | return maybe_suppress_result(c, result_used, node); |
| 1492 | } | 1503 | } |
| 1493 | case clang::BO_Shl: { | 1504 | case clang::BO_Shl: { |
| 1494 | AstNode *node = trans_create_shift_op(c, scope, bitcast(stmt->getType()), stmt->getLHS(), BinOpTypeBitShiftLeft, stmt->getRHS()); | 1505 | AstNode *node = trans_create_shift_op(c, scope, bitcast(stmt->getType()), bitcast(stmt->getLHS()), BinOpTypeBitShiftLeft, bitcast(stmt->getRHS())); |
| 1495 | return maybe_suppress_result(c, result_used, node); | 1506 | return maybe_suppress_result(c, result_used, node); |
| 1496 | } | 1507 | } |
| 1497 | case clang::BO_Shr: { | 1508 | case clang::BO_Shr: { |
| 1498 | AstNode *node = trans_create_shift_op(c, scope, bitcast(stmt->getType()), stmt->getLHS(), BinOpTypeBitShiftRight, stmt->getRHS()); | 1509 | AstNode *node = trans_create_shift_op(c, scope, bitcast(stmt->getType()), bitcast(stmt->getLHS()), BinOpTypeBitShiftRight, bitcast(stmt->getRHS())); |
| 1499 | return maybe_suppress_result(c, result_used, node); | 1510 | return maybe_suppress_result(c, result_used, node); |
| 1500 | } | 1511 | } |
| 1501 | case clang::BO_LT: { | 1512 | case clang::BO_LT: { |
| 1502 | AstNode *node =trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeCmpLessThan, stmt->getRHS()); | 1513 | AstNode *node =trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpLessThan, bitcast(stmt->getRHS())); |
| 1503 | return maybe_suppress_result(c, result_used, node); | 1514 | return maybe_suppress_result(c, result_used, node); |
| 1504 | } | 1515 | } |
| 1505 | case clang::BO_GT: { | 1516 | case clang::BO_GT: { |
| 1506 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeCmpGreaterThan, stmt->getRHS()); | 1517 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpGreaterThan, bitcast(stmt->getRHS())); |
| 1507 | return maybe_suppress_result(c, result_used, node); | 1518 | return maybe_suppress_result(c, result_used, node); |
| 1508 | } | 1519 | } |
| 1509 | case clang::BO_LE: { | 1520 | case clang::BO_LE: { |
| 1510 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeCmpLessOrEq, stmt->getRHS()); | 1521 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpLessOrEq, bitcast(stmt->getRHS())); |
| 1511 | return maybe_suppress_result(c, result_used, node); | 1522 | return maybe_suppress_result(c, result_used, node); |
| 1512 | } | 1523 | } |
| 1513 | case clang::BO_GE: { | 1524 | case clang::BO_GE: { |
| 1514 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeCmpGreaterOrEq, stmt->getRHS()); | 1525 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpGreaterOrEq, bitcast(stmt->getRHS())); |
| 1515 | return maybe_suppress_result(c, result_used, node); | 1526 | return maybe_suppress_result(c, result_used, node); |
| 1516 | } | 1527 | } |
| 1517 | case clang::BO_EQ: { | 1528 | case clang::BO_EQ: { |
| 1518 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeCmpEq, stmt->getRHS()); | 1529 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpEq, bitcast(stmt->getRHS())); |
| 1519 | return maybe_suppress_result(c, result_used, node); | 1530 | return maybe_suppress_result(c, result_used, node); |
| 1520 | } | 1531 | } |
| 1521 | case clang::BO_NE: { | 1532 | case clang::BO_NE: { |
| 1522 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeCmpNotEq, stmt->getRHS()); | 1533 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeCmpNotEq, bitcast(stmt->getRHS())); |
| 1523 | return maybe_suppress_result(c, result_used, node); | 1534 | return maybe_suppress_result(c, result_used, node); |
| 1524 | } | 1535 | } |
| 1525 | case clang::BO_And: { | 1536 | case clang::BO_And: { |
| 1526 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeBinAnd, stmt->getRHS()); | 1537 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBinAnd, bitcast(stmt->getRHS())); |
| 1527 | return maybe_suppress_result(c, result_used, node); | 1538 | return maybe_suppress_result(c, result_used, node); |
| 1528 | } | 1539 | } |
| 1529 | case clang::BO_Xor: { | 1540 | case clang::BO_Xor: { |
| 1530 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeBinXor, stmt->getRHS()); | 1541 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBinXor, bitcast(stmt->getRHS())); |
| 1531 | return maybe_suppress_result(c, result_used, node); | 1542 | return maybe_suppress_result(c, result_used, node); |
| 1532 | } | 1543 | } |
| 1533 | case clang::BO_Or: { | 1544 | case clang::BO_Or: { |
| 1534 | AstNode *node = trans_create_bin_op(c, scope, stmt->getLHS(), BinOpTypeBinOr, stmt->getRHS()); | 1545 | AstNode *node = trans_create_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBinOr, bitcast(stmt->getRHS())); |
| 1535 | return maybe_suppress_result(c, result_used, node); | 1546 | return maybe_suppress_result(c, result_used, node); |
| 1536 | } | 1547 | } |
| 1537 | case clang::BO_LAnd: { | 1548 | case clang::BO_LAnd: { |
| 1538 | AstNode *node = trans_create_bool_bin_op(c, scope, stmt->getLHS(), BinOpTypeBoolAnd, stmt->getRHS()); | 1549 | AstNode *node = trans_create_bool_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBoolAnd, bitcast(stmt->getRHS())); |
| 1539 | return maybe_suppress_result(c, result_used, node); | 1550 | return maybe_suppress_result(c, result_used, node); |
| 1540 | } | 1551 | } |
| 1541 | case clang::BO_LOr: { | 1552 | case clang::BO_LOr: { |
| 1542 | AstNode *node = trans_create_bool_bin_op(c, scope, stmt->getLHS(), BinOpTypeBoolOr, stmt->getRHS()); | 1553 | AstNode *node = trans_create_bool_bin_op(c, scope, bitcast(stmt->getLHS()), BinOpTypeBoolOr, bitcast(stmt->getRHS())); |
| 1543 | return maybe_suppress_result(c, result_used, node); | 1554 | return maybe_suppress_result(c, result_used, node); |
| 1544 | } | 1555 | } |
| 1545 | case clang::BO_Assign: | 1556 | case clang::BO_Assign: |
| 1546 | return trans_create_assign(c, result_used, scope, stmt->getLHS(), stmt->getRHS()); | 1557 | return trans_create_assign(c, result_used, scope, bitcast(stmt->getLHS()), bitcast(stmt->getRHS())); |
| 1547 | case clang::BO_Comma: | 1558 | case clang::BO_Comma: |
| 1548 | { | 1559 | { |
| 1549 | TransScopeBlock *scope_block = trans_scope_block_create(c, scope); | 1560 | TransScopeBlock *scope_block = trans_scope_block_create(c, scope); |
| 1550 | Buf *label_name = buf_create_from_str("x"); | 1561 | Buf *label_name = buf_create_from_str("x"); |
| 1551 | scope_block->node->data.block.name = label_name; | 1562 | scope_block->node->data.block.name = label_name; |
| 1552 | | 1563 | |
| 1553 | AstNode *lhs = trans_expr(c, ResultUsedNo, &scope_block->base, stmt->getLHS(), TransRValue); | 1564 | AstNode *lhs = trans_expr(c, ResultUsedNo, &scope_block->base, bitcast(stmt->getLHS()), TransRValue); |
| 1554 | if (lhs == nullptr) | 1565 | if (lhs == nullptr) |
| 1555 | return nullptr; | 1566 | return nullptr; |
| 1556 | scope_block->node->data.block.statements.append(lhs); | 1567 | scope_block->node->data.block.statements.append(lhs); |
| 1557 | | 1568 | |
| 1558 | AstNode *rhs = trans_expr(c, ResultUsedYes, &scope_block->base, stmt->getRHS(), TransRValue); | 1569 | AstNode *rhs = trans_expr(c, ResultUsedYes, &scope_block->base, bitcast(stmt->getRHS()), TransRValue); |
| 1559 | if (rhs == nullptr) | 1570 | if (rhs == nullptr) |
| 1560 | return nullptr; | 1571 | return nullptr; |
| 1561 | | 1572 | |
| ... | @@ -1589,10 +1600,10 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result | ... | @@ -1589,10 +1600,10 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result |
| 1589 | if (!use_intermediate_casts && result_used == ResultUsedNo) { | 1600 | if (!use_intermediate_casts && result_used == ResultUsedNo) { |
| 1590 | // simple common case, where the C and Zig are identical: | 1601 | // simple common case, where the C and Zig are identical: |
| 1591 | // lhs >>= rhs | 1602 | // lhs >>= rhs |
| 1592 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, stmt->getLHS(), TransLValue); | 1603 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getLHS()), TransLValue); |
| 1593 | if (lhs == nullptr) return nullptr; | 1604 | if (lhs == nullptr) return nullptr; |
| 1594 | | 1605 | |
| 1595 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, stmt->getRHS(), TransRValue); | 1606 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getRHS()), TransRValue); |
| 1596 | if (rhs == nullptr) return nullptr; | 1607 | if (rhs == nullptr) return nullptr; |
| 1597 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); | 1608 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); |
| 1598 | | 1609 | |
| ... | @@ -1612,7 +1623,7 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result | ... | @@ -1612,7 +1623,7 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result |
| 1612 | child_scope->node->data.block.name = label_name; | 1623 | child_scope->node->data.block.name = label_name; |
| 1613 | | 1624 | |
| 1614 | // const _ref = &lhs; | 1625 | // const _ref = &lhs; |
| 1615 | AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, stmt->getLHS(), TransLValue); | 1626 | AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, bitcast(stmt->getLHS()), TransLValue); |
| 1616 | if (lhs == nullptr) return nullptr; | 1627 | if (lhs == nullptr) return nullptr; |
| 1617 | AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs); | 1628 | AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs); |
| 1618 | // TODO: avoid name collisions with generated variable names | 1629 | // TODO: avoid name collisions with generated variable names |
| ... | @@ -1622,7 +1633,7 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result | ... | @@ -1622,7 +1633,7 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result |
| 1622 | | 1633 | |
| 1623 | // *_ref = result_type(operation_type(*_ref) >> u5(rhs)); | 1634 | // *_ref = result_type(operation_type(*_ref) >> u5(rhs)); |
| 1624 | | 1635 | |
| 1625 | AstNode *rhs = trans_expr(c, ResultUsedYes, &child_scope->base, stmt->getRHS(), TransRValue); | 1636 | AstNode *rhs = trans_expr(c, ResultUsedYes, &child_scope->base, bitcast(stmt->getRHS()), TransRValue); |
| 1626 | if (rhs == nullptr) return nullptr; | 1637 | if (rhs == nullptr) return nullptr; |
| 1627 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); | 1638 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); |
| 1628 | | 1639 | |
| ... | @@ -1667,9 +1678,9 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, | ... | @@ -1667,9 +1678,9 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, |
| 1667 | if (result_used == ResultUsedNo) { | 1678 | if (result_used == ResultUsedNo) { |
| 1668 | // simple common case, where the C and Zig are identical: | 1679 | // simple common case, where the C and Zig are identical: |
| 1669 | // lhs += rhs | 1680 | // lhs += rhs |
| 1670 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, stmt->getLHS(), TransLValue); | 1681 | AstNode *lhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getLHS()), TransLValue); |
| 1671 | if (lhs == nullptr) return nullptr; | 1682 | if (lhs == nullptr) return nullptr; |
| 1672 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, stmt->getRHS(), TransRValue); | 1683 | AstNode *rhs = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getRHS()), TransRValue); |
| 1673 | if (rhs == nullptr) return nullptr; | 1684 | if (rhs == nullptr) return nullptr; |
| 1674 | return trans_create_node_bin_op(c, lhs, assign_op, rhs); | 1685 | return trans_create_node_bin_op(c, lhs, assign_op, rhs); |
| 1675 | } else { | 1686 | } else { |
| ... | @@ -1686,7 +1697,7 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, | ... | @@ -1686,7 +1697,7 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, |
| 1686 | child_scope->node->data.block.name = label_name; | 1697 | child_scope->node->data.block.name = label_name; |
| 1687 | | 1698 | |
| 1688 | // const _ref = &lhs; | 1699 | // const _ref = &lhs; |
| 1689 | AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, stmt->getLHS(), TransLValue); | 1700 | AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, bitcast(stmt->getLHS()), TransLValue); |
| 1690 | if (lhs == nullptr) return nullptr; | 1701 | if (lhs == nullptr) return nullptr; |
| 1691 | AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs); | 1702 | AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs); |
| 1692 | // TODO: avoid name collisions with generated variable names | 1703 | // TODO: avoid name collisions with generated variable names |
| ... | @@ -1696,7 +1707,7 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, | ... | @@ -1696,7 +1707,7 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used, |
| 1696 | | 1707 | |
| 1697 | // *_ref = *_ref + rhs; | 1708 | // *_ref = *_ref + rhs; |
| 1698 | | 1709 | |
| 1699 | AstNode *rhs = trans_expr(c, ResultUsedYes, &child_scope->base, stmt->getRHS(), TransRValue); | 1710 | AstNode *rhs = trans_expr(c, ResultUsedYes, &child_scope->base, bitcast(stmt->getRHS()), TransRValue); |
| 1700 | if (rhs == nullptr) return nullptr; | 1711 | if (rhs == nullptr) return nullptr; |
| 1701 | | 1712 | |
| 1702 | AstNode *assign_statement = trans_create_node_bin_op(c, | 1713 | AstNode *assign_statement = trans_create_node_bin_op(c, |
| ... | @@ -1788,201 +1799,201 @@ static AstNode *trans_compound_assign_operator(Context *c, ResultUsed result_use | ... | @@ -1788,201 +1799,201 @@ static AstNode *trans_compound_assign_operator(Context *c, ResultUsed result_use |
| 1788 | } | 1799 | } |
| 1789 | | 1800 | |
| 1790 | static AstNode *trans_implicit_cast_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::ImplicitCastExpr *stmt) { | 1801 | static AstNode *trans_implicit_cast_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::ImplicitCastExpr *stmt) { |
| 1791 | switch (stmt->getCastKind()) { | 1802 | switch ((ZigClangCK)stmt->getCastKind()) { |
| 1792 | case clang::CK_LValueToRValue: | 1803 | case ZigClangCK_LValueToRValue: |
| 1793 | return trans_expr(c, ResultUsedYes, scope, stmt->getSubExpr(), TransRValue); | 1804 | return trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getSubExpr()), TransRValue); |
| 1794 | case clang::CK_IntegralCast: | 1805 | case ZigClangCK_IntegralCast: |
| 1795 | { | 1806 | { |
| 1796 | AstNode *target_node = trans_expr(c, ResultUsedYes, scope, stmt->getSubExpr(), TransRValue); | 1807 | AstNode *target_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getSubExpr()), TransRValue); |
| 1797 | if (target_node == nullptr) | 1808 | if (target_node == nullptr) |
| 1798 | return nullptr; | 1809 | return nullptr; |
| 1799 | AstNode *node = trans_c_cast(c, bitcast(stmt->getExprLoc()), bitcast(stmt->getType()), | 1810 | AstNode *node = trans_c_cast(c, bitcast(stmt->getExprLoc()), bitcast(stmt->getType()), |
| 1800 | bitcast(stmt->getSubExpr()->getType()), target_node); | 1811 | bitcast(stmt->getSubExpr()->getType()), target_node); |
| 1801 | return maybe_suppress_result(c, result_used, node); | 1812 | return maybe_suppress_result(c, result_used, node); |
| 1802 | } | 1813 | } |
| 1803 | case clang::CK_FunctionToPointerDecay: | 1814 | case ZigClangCK_FunctionToPointerDecay: |
| 1804 | case clang::CK_ArrayToPointerDecay: | 1815 | case ZigClangCK_ArrayToPointerDecay: |
| 1805 | { | 1816 | { |
| 1806 | AstNode *target_node = trans_expr(c, ResultUsedYes, scope, stmt->getSubExpr(), TransRValue); | 1817 | AstNode *target_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getSubExpr()), TransRValue); |
| 1807 | if (target_node == nullptr) | 1818 | if (target_node == nullptr) |
| 1808 | return nullptr; | 1819 | return nullptr; |
| 1809 | return maybe_suppress_result(c, result_used, target_node); | 1820 | return maybe_suppress_result(c, result_used, target_node); |
| 1810 | } | 1821 | } |
| 1811 | case clang::CK_BitCast: | 1822 | case ZigClangCK_BitCast: |
| 1812 | { | 1823 | { |
| 1813 | AstNode *target_node = trans_expr(c, ResultUsedYes, scope, stmt->getSubExpr(), TransRValue); | 1824 | AstNode *target_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getSubExpr()), TransRValue); |
| 1814 | if (target_node == nullptr) | 1825 | if (target_node == nullptr) |
| 1815 | return nullptr; | 1826 | return nullptr; |
| 1816 | | 1827 | |
| 1817 | if (expr_types_equal(c, stmt, stmt->getSubExpr())) { | 1828 | if (expr_types_equal(c, (const ZigClangExpr *)stmt, bitcast(stmt->getSubExpr()))) { |
| 1818 | return target_node; | 1829 | return target_node; |
| 1819 | } | 1830 | } |
| 1820 | | 1831 | |
| 1821 | AstNode *dest_type_node = get_expr_type(c, stmt); | 1832 | AstNode *dest_type_node = get_expr_type(c, (const ZigClangExpr *)stmt); |
| 1822 | | 1833 | |
| 1823 | AstNode *node = trans_create_node_builtin_fn_call_str(c, "ptrCast"); | 1834 | AstNode *node = trans_create_node_builtin_fn_call_str(c, "ptrCast"); |
| 1824 | node->data.fn_call_expr.params.append(dest_type_node); | 1835 | node->data.fn_call_expr.params.append(dest_type_node); |
| 1825 | node->data.fn_call_expr.params.append(target_node); | 1836 | node->data.fn_call_expr.params.append(target_node); |
| 1826 | return maybe_suppress_result(c, result_used, node); | 1837 | return maybe_suppress_result(c, result_used, node); |
| 1827 | } | 1838 | } |
| 1828 | case clang::CK_NullToPointer: | 1839 | case ZigClangCK_NullToPointer: |
| 1829 | return trans_create_node_unsigned(c, 0); | 1840 | return trans_create_node_unsigned(c, 0); |
| 1830 | case clang::CK_NoOp: | 1841 | case ZigClangCK_NoOp: |
| 1831 | return trans_expr(c, ResultUsedYes, scope, stmt->getSubExpr(), TransRValue); | 1842 | return trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getSubExpr()), TransRValue); |
| 1832 | case clang::CK_Dependent: | 1843 | case ZigClangCK_Dependent: |
| 1833 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_Dependent"); | 1844 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_Dependent"); |
| 1834 | return nullptr; | 1845 | return nullptr; |
| 1835 | case clang::CK_LValueBitCast: | 1846 | case ZigClangCK_LValueBitCast: |
| 1836 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_LValueBitCast"); | 1847 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_LValueBitCast"); |
| 1837 | return nullptr; | 1848 | return nullptr; |
| 1838 | case clang::CK_BaseToDerived: | 1849 | case ZigClangCK_BaseToDerived: |
| 1839 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_BaseToDerived"); | 1850 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_BaseToDerived"); |
| 1840 | return nullptr; | 1851 | return nullptr; |
| 1841 | case clang::CK_DerivedToBase: | 1852 | case ZigClangCK_DerivedToBase: |
| 1842 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_DerivedToBase"); | 1853 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_DerivedToBase"); |
| 1843 | return nullptr; | 1854 | return nullptr; |
| 1844 | case clang::CK_UncheckedDerivedToBase: | 1855 | case ZigClangCK_UncheckedDerivedToBase: |
| 1845 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_UncheckedDerivedToBase"); | 1856 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_UncheckedDerivedToBase"); |
| 1846 | return nullptr; | 1857 | return nullptr; |
| 1847 | case clang::CK_Dynamic: | 1858 | case ZigClangCK_Dynamic: |
| 1848 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_Dynamic"); | 1859 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_Dynamic"); |
| 1849 | return nullptr; | 1860 | return nullptr; |
| 1850 | case clang::CK_ToUnion: | 1861 | case ZigClangCK_ToUnion: |
| 1851 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_ToUnion"); | 1862 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_ToUnion"); |
| 1852 | return nullptr; | 1863 | return nullptr; |
| 1853 | case clang::CK_NullToMemberPointer: | 1864 | case ZigClangCK_NullToMemberPointer: |
| 1854 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_NullToMemberPointer"); | 1865 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_NullToMemberPointer"); |
| 1855 | return nullptr; | 1866 | return nullptr; |
| 1856 | case clang::CK_BaseToDerivedMemberPointer: | 1867 | case ZigClangCK_BaseToDerivedMemberPointer: |
| 1857 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_BaseToDerivedMemberPointer"); | 1868 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_BaseToDerivedMemberPointer"); |
| 1858 | return nullptr; | 1869 | return nullptr; |
| 1859 | case clang::CK_DerivedToBaseMemberPointer: | 1870 | case ZigClangCK_DerivedToBaseMemberPointer: |
| 1860 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_DerivedToBaseMemberPointer"); | 1871 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_DerivedToBaseMemberPointer"); |
| 1861 | return nullptr; | 1872 | return nullptr; |
| 1862 | case clang::CK_MemberPointerToBoolean: | 1873 | case ZigClangCK_MemberPointerToBoolean: |
| 1863 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_MemberPointerToBoolean"); | 1874 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_MemberPointerToBoolean"); |
| 1864 | return nullptr; | 1875 | return nullptr; |
| 1865 | case clang::CK_ReinterpretMemberPointer: | 1876 | case ZigClangCK_ReinterpretMemberPointer: |
| 1866 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_ReinterpretMemberPointer"); | 1877 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_ReinterpretMemberPointer"); |
| 1867 | return nullptr; | 1878 | return nullptr; |
| 1868 | case clang::CK_UserDefinedConversion: | 1879 | case ZigClangCK_UserDefinedConversion: |
| 1869 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_UserDefinedConversion"); | 1880 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation cast CK_UserDefinedConversion"); |
| 1870 | return nullptr; | 1881 | return nullptr; |
| 1871 | case clang::CK_ConstructorConversion: | 1882 | case ZigClangCK_ConstructorConversion: |
| 1872 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ConstructorConversion"); | 1883 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ConstructorConversion"); |
| 1873 | return nullptr; | 1884 | return nullptr; |
| 1874 | case clang::CK_IntegralToPointer: | 1885 | case ZigClangCK_IntegralToPointer: |
| 1875 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralToPointer"); | 1886 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralToPointer"); |
| 1876 | return nullptr; | 1887 | return nullptr; |
| 1877 | case clang::CK_PointerToIntegral: | 1888 | case ZigClangCK_PointerToIntegral: |
| 1878 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_PointerToIntegral"); | 1889 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_PointerToIntegral"); |
| 1879 | return nullptr; | 1890 | return nullptr; |
| 1880 | case clang::CK_PointerToBoolean: | 1891 | case ZigClangCK_PointerToBoolean: |
| 1881 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_PointerToBoolean"); | 1892 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_PointerToBoolean"); |
| 1882 | return nullptr; | 1893 | return nullptr; |
| 1883 | case clang::CK_ToVoid: | 1894 | case ZigClangCK_ToVoid: |
| 1884 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ToVoid"); | 1895 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ToVoid"); |
| 1885 | return nullptr; | 1896 | return nullptr; |
| 1886 | case clang::CK_VectorSplat: | 1897 | case ZigClangCK_VectorSplat: |
| 1887 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_VectorSplat"); | 1898 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_VectorSplat"); |
| 1888 | return nullptr; | 1899 | return nullptr; |
| 1889 | case clang::CK_IntegralToBoolean: | 1900 | case ZigClangCK_IntegralToBoolean: |
| 1890 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralToBoolean"); | 1901 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralToBoolean"); |
| 1891 | return nullptr; | 1902 | return nullptr; |
| 1892 | case clang::CK_IntegralToFloating: | 1903 | case ZigClangCK_IntegralToFloating: |
| 1893 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralToFloating"); | 1904 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralToFloating"); |
| 1894 | return nullptr; | 1905 | return nullptr; |
| 1895 | case clang::CK_FixedPointCast: | 1906 | case ZigClangCK_FixedPointCast: |
| 1896 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FixedPointCast"); | 1907 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FixedPointCast"); |
| 1897 | return nullptr; | 1908 | return nullptr; |
| 1898 | case clang::CK_FixedPointToBoolean: | 1909 | case ZigClangCK_FixedPointToBoolean: |
| 1899 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FixedPointToBoolean"); | 1910 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FixedPointToBoolean"); |
| 1900 | return nullptr; | 1911 | return nullptr; |
| 1901 | case clang::CK_FloatingToIntegral: | 1912 | case ZigClangCK_FloatingToIntegral: |
| 1902 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingToIntegral"); | 1913 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingToIntegral"); |
| 1903 | return nullptr; | 1914 | return nullptr; |
| 1904 | case clang::CK_FloatingToBoolean: | 1915 | case ZigClangCK_FloatingToBoolean: |
| 1905 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingToBoolean"); | 1916 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingToBoolean"); |
| 1906 | return nullptr; | 1917 | return nullptr; |
| 1907 | case clang::CK_BooleanToSignedIntegral: | 1918 | case ZigClangCK_BooleanToSignedIntegral: |
| 1908 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_BooleanToSignedIntegral"); | 1919 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_BooleanToSignedIntegral"); |
| 1909 | return nullptr; | 1920 | return nullptr; |
| 1910 | case clang::CK_FloatingCast: | 1921 | case ZigClangCK_FloatingCast: |
| 1911 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingCast"); | 1922 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingCast"); |
| 1912 | return nullptr; | 1923 | return nullptr; |
| 1913 | case clang::CK_CPointerToObjCPointerCast: | 1924 | case ZigClangCK_CPointerToObjCPointerCast: |
| 1914 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_CPointerToObjCPointerCast"); | 1925 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_CPointerToObjCPointerCast"); |
| 1915 | return nullptr; | 1926 | return nullptr; |
| 1916 | case clang::CK_BlockPointerToObjCPointerCast: | 1927 | case ZigClangCK_BlockPointerToObjCPointerCast: |
| 1917 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_BlockPointerToObjCPointerCast"); | 1928 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_BlockPointerToObjCPointerCast"); |
| 1918 | return nullptr; | 1929 | return nullptr; |
| 1919 | case clang::CK_AnyPointerToBlockPointerCast: | 1930 | case ZigClangCK_AnyPointerToBlockPointerCast: |
| 1920 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_AnyPointerToBlockPointerCast"); | 1931 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_AnyPointerToBlockPointerCast"); |
| 1921 | return nullptr; | 1932 | return nullptr; |
| 1922 | case clang::CK_ObjCObjectLValueCast: | 1933 | case ZigClangCK_ObjCObjectLValueCast: |
| 1923 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ObjCObjectLValueCast"); | 1934 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ObjCObjectLValueCast"); |
| 1924 | return nullptr; | 1935 | return nullptr; |
| 1925 | case clang::CK_FloatingRealToComplex: | 1936 | case ZigClangCK_FloatingRealToComplex: |
| 1926 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingRealToComplex"); | 1937 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingRealToComplex"); |
| 1927 | return nullptr; | 1938 | return nullptr; |
| 1928 | case clang::CK_FloatingComplexToReal: | 1939 | case ZigClangCK_FloatingComplexToReal: |
| 1929 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingComplexToReal"); | 1940 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingComplexToReal"); |
| 1930 | return nullptr; | 1941 | return nullptr; |
| 1931 | case clang::CK_FloatingComplexToBoolean: | 1942 | case ZigClangCK_FloatingComplexToBoolean: |
| 1932 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingComplexToBoolean"); | 1943 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingComplexToBoolean"); |
| 1933 | return nullptr; | 1944 | return nullptr; |
| 1934 | case clang::CK_FloatingComplexCast: | 1945 | case ZigClangCK_FloatingComplexCast: |
| 1935 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingComplexCast"); | 1946 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingComplexCast"); |
| 1936 | return nullptr; | 1947 | return nullptr; |
| 1937 | case clang::CK_FloatingComplexToIntegralComplex: | 1948 | case ZigClangCK_FloatingComplexToIntegralComplex: |
| 1938 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingComplexToIntegralComplex"); | 1949 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_FloatingComplexToIntegralComplex"); |
| 1939 | return nullptr; | 1950 | return nullptr; |
| 1940 | case clang::CK_IntegralRealToComplex: | 1951 | case ZigClangCK_IntegralRealToComplex: |
| 1941 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralRealToComplex"); | 1952 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralRealToComplex"); |
| 1942 | return nullptr; | 1953 | return nullptr; |
| 1943 | case clang::CK_IntegralComplexToReal: | 1954 | case ZigClangCK_IntegralComplexToReal: |
| 1944 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralComplexToReal"); | 1955 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralComplexToReal"); |
| 1945 | return nullptr; | 1956 | return nullptr; |
| 1946 | case clang::CK_IntegralComplexToBoolean: | 1957 | case ZigClangCK_IntegralComplexToBoolean: |
| 1947 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralComplexToBoolean"); | 1958 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralComplexToBoolean"); |
| 1948 | return nullptr; | 1959 | return nullptr; |
| 1949 | case clang::CK_IntegralComplexCast: | 1960 | case ZigClangCK_IntegralComplexCast: |
| 1950 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralComplexCast"); | 1961 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralComplexCast"); |
| 1951 | return nullptr; | 1962 | return nullptr; |
| 1952 | case clang::CK_IntegralComplexToFloatingComplex: | 1963 | case ZigClangCK_IntegralComplexToFloatingComplex: |
| 1953 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralComplexToFloatingComplex"); | 1964 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralComplexToFloatingComplex"); |
| 1954 | return nullptr; | 1965 | return nullptr; |
| 1955 | case clang::CK_ARCProduceObject: | 1966 | case ZigClangCK_ARCProduceObject: |
| 1956 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ARCProduceObject"); | 1967 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ARCProduceObject"); |
| 1957 | return nullptr; | 1968 | return nullptr; |
| 1958 | case clang::CK_ARCConsumeObject: | 1969 | case ZigClangCK_ARCConsumeObject: |
| 1959 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ARCConsumeObject"); | 1970 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ARCConsumeObject"); |
| 1960 | return nullptr; | 1971 | return nullptr; |
| 1961 | case clang::CK_ARCReclaimReturnedObject: | 1972 | case ZigClangCK_ARCReclaimReturnedObject: |
| 1962 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ARCReclaimReturnedObject"); | 1973 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ARCReclaimReturnedObject"); |
| 1963 | return nullptr; | 1974 | return nullptr; |
| 1964 | case clang::CK_ARCExtendBlockObject: | 1975 | case ZigClangCK_ARCExtendBlockObject: |
| 1965 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ARCExtendBlockObject"); | 1976 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ARCExtendBlockObject"); |
| 1966 | return nullptr; | 1977 | return nullptr; |
| 1967 | case clang::CK_AtomicToNonAtomic: | 1978 | case ZigClangCK_AtomicToNonAtomic: |
| 1968 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_AtomicToNonAtomic"); | 1979 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_AtomicToNonAtomic"); |
| 1969 | return nullptr; | 1980 | return nullptr; |
| 1970 | case clang::CK_NonAtomicToAtomic: | 1981 | case ZigClangCK_NonAtomicToAtomic: |
| 1971 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_NonAtomicToAtomic"); | 1982 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_NonAtomicToAtomic"); |
| 1972 | return nullptr; | 1983 | return nullptr; |
| 1973 | case clang::CK_CopyAndAutoreleaseBlockObject: | 1984 | case ZigClangCK_CopyAndAutoreleaseBlockObject: |
| 1974 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_CopyAndAutoreleaseBlockObject"); | 1985 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_CopyAndAutoreleaseBlockObject"); |
| 1975 | return nullptr; | 1986 | return nullptr; |
| 1976 | case clang::CK_BuiltinFnToFnPtr: | 1987 | case ZigClangCK_BuiltinFnToFnPtr: |
| 1977 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_BuiltinFnToFnPtr"); | 1988 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_BuiltinFnToFnPtr"); |
| 1978 | return nullptr; | 1989 | return nullptr; |
| 1979 | case clang::CK_ZeroToOCLOpaqueType: | 1990 | case ZigClangCK_ZeroToOCLOpaqueType: |
| 1980 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ZeroToOCLOpaqueType"); | 1991 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_ZeroToOCLOpaqueType"); |
| 1981 | return nullptr; | 1992 | return nullptr; |
| 1982 | case clang::CK_AddressSpaceConversion: | 1993 | case ZigClangCK_AddressSpaceConversion: |
| 1983 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_AddressSpaceConversion"); | 1994 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_AddressSpaceConversion"); |
| 1984 | return nullptr; | 1995 | return nullptr; |
| 1985 | case clang::CK_IntToOCLSampler: | 1996 | case ZigClangCK_IntToOCLSampler: |
| 1986 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntToOCLSampler"); | 1997 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntToOCLSampler"); |
| 1987 | return nullptr; | 1998 | return nullptr; |
| 1988 | } | 1999 | } |
| ... | @@ -2002,7 +2013,7 @@ static AstNode *trans_decl_ref_expr(Context *c, TransScope *scope, const clang:: | ... | @@ -2002,7 +2013,7 @@ static AstNode *trans_decl_ref_expr(Context *c, TransScope *scope, const clang:: |
| 2002 | static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, TransScope *scope, | 2013 | static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, TransScope *scope, |
| 2003 | const clang::UnaryOperator *stmt, BinOpType assign_op) | 2014 | const clang::UnaryOperator *stmt, BinOpType assign_op) |
| 2004 | { | 2015 | { |
| 2005 | clang::Expr *op_expr = stmt->getSubExpr(); | 2016 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); |
| 2006 | | 2017 | |
| 2007 | if (result_used == ResultUsedNo) { | 2018 | if (result_used == ResultUsedNo) { |
| 2008 | // common case | 2019 | // common case |
| ... | @@ -2058,7 +2069,7 @@ static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, Tr | ... | @@ -2058,7 +2069,7 @@ static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, Tr |
| 2058 | static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, TransScope *scope, | 2069 | static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, TransScope *scope, |
| 2059 | const clang::UnaryOperator *stmt, BinOpType assign_op) | 2070 | const clang::UnaryOperator *stmt, BinOpType assign_op) |
| 2060 | { | 2071 | { |
| 2061 | clang::Expr *op_expr = stmt->getSubExpr(); | 2072 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); |
| 2062 | | 2073 | |
| 2063 | if (result_used == ResultUsedNo) { | 2074 | if (result_used == ResultUsedNo) { |
| 2064 | // common case | 2075 | // common case |
| ... | @@ -2129,14 +2140,14 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2129,14 +2140,14 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2129 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); | 2140 | return trans_create_pre_crement(c, result_used, scope, stmt, BinOpTypeAssignMinus); |
| 2130 | case clang::UO_AddrOf: | 2141 | case clang::UO_AddrOf: |
| 2131 | { | 2142 | { |
| 2132 | AstNode *value_node = trans_expr(c, result_used, scope, stmt->getSubExpr(), TransLValue); | 2143 | AstNode *value_node = trans_expr(c, result_used, scope, bitcast(stmt->getSubExpr()), TransLValue); |
| 2133 | if (value_node == nullptr) | 2144 | if (value_node == nullptr) |
| 2134 | return value_node; | 2145 | return value_node; |
| 2135 | return trans_create_node_addr_of(c, value_node); | 2146 | return trans_create_node_addr_of(c, value_node); |
| 2136 | } | 2147 | } |
| 2137 | case clang::UO_Deref: | 2148 | case clang::UO_Deref: |
| 2138 | { | 2149 | { |
| 2139 | AstNode *value_node = trans_expr(c, result_used, scope, stmt->getSubExpr(), TransRValue); | 2150 | AstNode *value_node = trans_expr(c, result_used, scope, bitcast(stmt->getSubExpr()), TransRValue); |
| 2140 | if (value_node == nullptr) | 2151 | if (value_node == nullptr) |
| 2141 | return nullptr; | 2152 | return nullptr; |
| 2142 | bool is_fn_ptr = qual_type_is_fn_ptr(bitcast(stmt->getSubExpr()->getType())); | 2153 | bool is_fn_ptr = qual_type_is_fn_ptr(bitcast(stmt->getSubExpr()->getType())); |
| ... | @@ -2150,8 +2161,8 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2150,8 +2161,8 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2150 | return nullptr; | 2161 | return nullptr; |
| 2151 | case clang::UO_Minus: | 2162 | case clang::UO_Minus: |
| 2152 | { | 2163 | { |
| 2153 | clang::Expr *op_expr = stmt->getSubExpr(); | 2164 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); |
| 2154 | if (!qual_type_has_wrapping_overflow(c, bitcast(op_expr->getType()))) { | 2165 | if (!qual_type_has_wrapping_overflow(c, ZigClangExpr_getType(op_expr))) { |
| 2155 | AstNode *node = trans_create_node(c, NodeTypePrefixOpExpr); | 2166 | AstNode *node = trans_create_node(c, NodeTypePrefixOpExpr); |
| 2156 | node->data.prefix_op_expr.prefix_op = PrefixOpNegation; | 2167 | node->data.prefix_op_expr.prefix_op = PrefixOpNegation; |
| 2157 | | 2168 | |
| ... | @@ -2160,7 +2171,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2160,7 +2171,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2160 | return nullptr; | 2171 | return nullptr; |
| 2161 | | 2172 | |
| 2162 | return node; | 2173 | return node; |
| 2163 | } else if (c_is_unsigned_integer(c, bitcast(op_expr->getType()))) { | 2174 | } else if (c_is_unsigned_integer(c, ZigClangExpr_getType(op_expr))) { |
| 2164 | // we gotta emit 0 -% x | 2175 | // we gotta emit 0 -% x |
| 2165 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); | 2176 | AstNode *node = trans_create_node(c, NodeTypeBinOpExpr); |
| 2166 | node->data.bin_op_expr.op1 = trans_create_node_unsigned(c, 0); | 2177 | node->data.bin_op_expr.op1 = trans_create_node_unsigned(c, 0); |
| ... | @@ -2178,7 +2189,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2178,7 +2189,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2178 | } | 2189 | } |
| 2179 | case clang::UO_Not: | 2190 | case clang::UO_Not: |
| 2180 | { | 2191 | { |
| 2181 | clang::Expr *op_expr = stmt->getSubExpr(); | 2192 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); |
| 2182 | AstNode *sub_node = trans_expr(c, ResultUsedYes, scope, op_expr, TransRValue); | 2193 | AstNode *sub_node = trans_expr(c, ResultUsedYes, scope, op_expr, TransRValue); |
| 2183 | if (sub_node == nullptr) | 2194 | if (sub_node == nullptr) |
| 2184 | return nullptr; | 2195 | return nullptr; |
| ... | @@ -2187,7 +2198,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2187,7 +2198,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2187 | } | 2198 | } |
| 2188 | case clang::UO_LNot: | 2199 | case clang::UO_LNot: |
| 2189 | { | 2200 | { |
| 2190 | clang::Expr *op_expr = stmt->getSubExpr(); | 2201 | const ZigClangExpr *op_expr = bitcast(stmt->getSubExpr()); |
| 2191 | AstNode *sub_node = trans_bool_expr(c, ResultUsedYes, scope, op_expr, TransRValue); | 2202 | AstNode *sub_node = trans_bool_expr(c, ResultUsedYes, scope, op_expr, TransRValue); |
| 2192 | if (sub_node == nullptr) | 2203 | if (sub_node == nullptr) |
| 2193 | return nullptr; | 2204 | return nullptr; |
| ... | @@ -2201,7 +2212,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc | ... | @@ -2201,7 +2212,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 2201 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation UO_Imag"); | 2212 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation UO_Imag"); |
| 2202 | return nullptr; | 2213 | return nullptr; |
| 2203 | case clang::UO_Extension: | 2214 | case clang::UO_Extension: |
| 2204 | return trans_expr(c, result_used, scope, stmt->getSubExpr(), TransLValue); | 2215 | return trans_expr(c, result_used, scope, bitcast(stmt->getSubExpr()), TransLValue); |
| 2205 | case clang::UO_Coawait: | 2216 | case clang::UO_Coawait: |
| 2206 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation UO_Coawait"); | 2217 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C translation UO_Coawait"); |
| 2207 | return nullptr; | 2218 | return nullptr; |
| ... | @@ -2226,7 +2237,7 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D | ... | @@ -2226,7 +2237,7 @@ static int trans_local_declaration(Context *c, TransScope *scope, const clang::D |
| 2226 | ZigClangQualType qual_type = bitcast(var_decl->getTypeSourceInfo()->getType()); | 2237 | ZigClangQualType qual_type = bitcast(var_decl->getTypeSourceInfo()->getType()); |
| 2227 | AstNode *init_node = nullptr; | 2238 | AstNode *init_node = nullptr; |
| 2228 | if (var_decl->hasInit()) { | 2239 | if (var_decl->hasInit()) { |
| 2229 | init_node = trans_expr(c, ResultUsedYes, scope, var_decl->getInit(), TransRValue); | 2240 | init_node = trans_expr(c, ResultUsedYes, scope, bitcast(var_decl->getInit()), TransRValue); |
| 2230 | if (init_node == nullptr) | 2241 | if (init_node == nullptr) |
| 2231 | return ErrorUnexpected; | 2242 | return ErrorUnexpected; |
| 2232 | | 2243 | |
| ... | @@ -2492,7 +2503,7 @@ static AstNode *to_enum_zero_cmp(Context *c, AstNode *expr, AstNode *enum_type) | ... | @@ -2492,7 +2503,7 @@ static AstNode *to_enum_zero_cmp(Context *c, AstNode *expr, AstNode *enum_type) |
| 2492 | return trans_create_node_bin_op(c, expr, BinOpTypeCmpNotEq, bitcast); | 2503 | return trans_create_node_bin_op(c, expr, BinOpTypeCmpNotEq, bitcast); |
| 2493 | } | 2504 | } |
| 2494 | | 2505 | |
| 2495 | static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::Expr *expr, TransLRValue lrval) { | 2506 | static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, const ZigClangExpr *expr, TransLRValue lrval) { |
| 2496 | AstNode *res = trans_expr(c, result_used, scope, expr, lrval); | 2507 | AstNode *res = trans_expr(c, result_used, scope, expr, lrval); |
| 2497 | if (res == nullptr) | 2508 | if (res == nullptr) |
| 2498 | return nullptr; | 2509 | return nullptr; |
| ... | @@ -2689,7 +2700,7 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2689,7 +2700,7 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2689 | switch (elaborated_ty->getKeyword()) { | 2700 | switch (elaborated_ty->getKeyword()) { |
| 2690 | case clang::ETK_Enum: { | 2701 | case clang::ETK_Enum: { |
| 2691 | AstNode *enum_type = trans_qual_type(c, bitcast(elaborated_ty->getNamedType()), | 2702 | AstNode *enum_type = trans_qual_type(c, bitcast(elaborated_ty->getNamedType()), |
| 2692 | bitcast(expr->getBeginLoc())); | 2703 | ZigClangExpr_getBeginLoc(expr)); |
| 2693 | return to_enum_zero_cmp(c, res, enum_type); | 2704 | return to_enum_zero_cmp(c, res, enum_type); |
| 2694 | } | 2705 | } |
| 2695 | case clang::ETK_Struct: | 2706 | case clang::ETK_Struct: |
| ... | @@ -2752,7 +2763,8 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2752,7 +2763,8 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2752 | static AstNode *trans_while_loop(Context *c, TransScope *scope, const clang::WhileStmt *stmt) { | 2763 | static AstNode *trans_while_loop(Context *c, TransScope *scope, const clang::WhileStmt *stmt) { |
| 2753 | TransScopeWhile *while_scope = trans_scope_while_create(c, scope); | 2764 | TransScopeWhile *while_scope = trans_scope_while_create(c, scope); |
| 2754 | | 2765 | |
| 2755 | while_scope->node->data.while_expr.condition = trans_bool_expr(c, ResultUsedYes, scope, stmt->getCond(), TransRValue); | 2766 | while_scope->node->data.while_expr.condition = trans_bool_expr(c, ResultUsedYes, scope, |
| | 2767 | bitcast(stmt->getCond()), TransRValue); |
| 2756 | if (while_scope->node->data.while_expr.condition == nullptr) | 2768 | if (while_scope->node->data.while_expr.condition == nullptr) |
| 2757 | return nullptr; | 2769 | return nullptr; |
| 2758 | | 2770 | |
| ... | @@ -2779,7 +2791,8 @@ static AstNode *trans_if_statement(Context *c, TransScope *scope, const clang::I | ... | @@ -2779,7 +2791,8 @@ static AstNode *trans_if_statement(Context *c, TransScope *scope, const clang::I |
| 2779 | return nullptr; | 2791 | return nullptr; |
| 2780 | } | 2792 | } |
| 2781 | | 2793 | |
| 2782 | if_node->data.if_bool_expr.condition = trans_bool_expr(c, ResultUsedYes, scope, stmt->getCond(), TransRValue); | 2794 | if_node->data.if_bool_expr.condition = trans_bool_expr(c, ResultUsedYes, scope, bitcast(stmt->getCond()), |
| | 2795 | TransRValue); |
| 2783 | if (if_node->data.if_bool_expr.condition == nullptr) | 2796 | if (if_node->data.if_bool_expr.condition == nullptr) |
| 2784 | return nullptr; | 2797 | return nullptr; |
| 2785 | | 2798 | |
| ... | @@ -2789,7 +2802,7 @@ static AstNode *trans_if_statement(Context *c, TransScope *scope, const clang::I | ... | @@ -2789,7 +2802,7 @@ static AstNode *trans_if_statement(Context *c, TransScope *scope, const clang::I |
| 2789 | static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::CallExpr *stmt) { | 2802 | static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::CallExpr *stmt) { |
| 2790 | AstNode *node = trans_create_node(c, NodeTypeFnCallExpr); | 2803 | AstNode *node = trans_create_node(c, NodeTypeFnCallExpr); |
| 2791 | | 2804 | |
| 2792 | AstNode *callee_raw_node = trans_expr(c, ResultUsedYes, scope, stmt->getCallee(), TransRValue); | 2805 | AstNode *callee_raw_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getCallee()), TransRValue); |
| 2793 | if (callee_raw_node == nullptr) | 2806 | if (callee_raw_node == nullptr) |
| 2794 | return nullptr; | 2807 | return nullptr; |
| 2795 | | 2808 | |
| ... | @@ -2799,7 +2812,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2799,7 +2812,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * |
| 2799 | if (is_ptr && fn_ty) { | 2812 | if (is_ptr && fn_ty) { |
| 2800 | if ((ZigClangStmtClass)stmt->getCallee()->getStmtClass() == ZigClangStmt_ImplicitCastExprClass) { | 2813 | if ((ZigClangStmtClass)stmt->getCallee()->getStmtClass() == ZigClangStmt_ImplicitCastExprClass) { |
| 2801 | const clang::ImplicitCastExpr *implicit_cast = static_cast<const clang::ImplicitCastExpr *>(stmt->getCallee()); | 2814 | const clang::ImplicitCastExpr *implicit_cast = static_cast<const clang::ImplicitCastExpr *>(stmt->getCallee()); |
| 2802 | if (implicit_cast->getCastKind() == clang::CK_FunctionToPointerDecay) { | 2815 | if ((ZigClangCK)implicit_cast->getCastKind() == ZigClangCK_FunctionToPointerDecay) { |
| 2803 | if ((ZigClangStmtClass)implicit_cast->getSubExpr()->getStmtClass() == ZigClangStmt_DeclRefExprClass) { | 2816 | if ((ZigClangStmtClass)implicit_cast->getSubExpr()->getStmtClass() == ZigClangStmt_DeclRefExprClass) { |
| 2804 | const clang::DeclRefExpr *decl_ref = static_cast<const clang::DeclRefExpr *>(implicit_cast->getSubExpr()); | 2817 | const clang::DeclRefExpr *decl_ref = static_cast<const clang::DeclRefExpr *>(implicit_cast->getSubExpr()); |
| 2805 | const clang::Decl *decl = decl_ref->getFoundDecl(); | 2818 | const clang::Decl *decl = decl_ref->getFoundDecl(); |
| ... | @@ -2819,7 +2832,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2819,7 +2832,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * |
| 2819 | node->data.fn_call_expr.fn_ref_expr = callee_node; | 2832 | node->data.fn_call_expr.fn_ref_expr = callee_node; |
| 2820 | | 2833 | |
| 2821 | unsigned num_args = stmt->getNumArgs(); | 2834 | unsigned num_args = stmt->getNumArgs(); |
| 2822 | const clang::Expr * const* args = stmt->getArgs(); | 2835 | const ZigClangExpr * const* args = reinterpret_cast<const ZigClangExpr * const*>(stmt->getArgs()); |
| 2823 | for (unsigned i = 0; i < num_args; i += 1) { | 2836 | for (unsigned i = 0; i < num_args; i += 1) { |
| 2824 | AstNode *arg_node = trans_expr(c, ResultUsedYes, scope, args[i], TransRValue); | 2837 | AstNode *arg_node = trans_expr(c, ResultUsedYes, scope, args[i], TransRValue); |
| 2825 | if (arg_node == nullptr) | 2838 | if (arg_node == nullptr) |
| ... | @@ -2840,7 +2853,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * | ... | @@ -2840,7 +2853,7 @@ static AstNode *trans_call_expr(Context *c, ResultUsed result_used, TransScope * |
| 2840 | static AstNode *trans_member_expr(Context *c, ResultUsed result_used, TransScope *scope, | 2853 | static AstNode *trans_member_expr(Context *c, ResultUsed result_used, TransScope *scope, |
| 2841 | const clang::MemberExpr *stmt) | 2854 | const clang::MemberExpr *stmt) |
| 2842 | { | 2855 | { |
| 2843 | AstNode *container_node = trans_expr(c, ResultUsedYes, scope, stmt->getBase(), TransRValue); | 2856 | AstNode *container_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getBase()), TransRValue); |
| 2844 | if (container_node == nullptr) | 2857 | if (container_node == nullptr) |
| 2845 | return nullptr; | 2858 | return nullptr; |
| 2846 | | 2859 | |
| ... | @@ -2855,11 +2868,11 @@ static AstNode *trans_member_expr(Context *c, ResultUsed result_used, TransScope | ... | @@ -2855,11 +2868,11 @@ static AstNode *trans_member_expr(Context *c, ResultUsed result_used, TransScope |
| 2855 | } | 2868 | } |
| 2856 | | 2869 | |
| 2857 | static AstNode *trans_array_subscript_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::ArraySubscriptExpr *stmt) { | 2870 | static AstNode *trans_array_subscript_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::ArraySubscriptExpr *stmt) { |
| 2858 | AstNode *container_node = trans_expr(c, ResultUsedYes, scope, stmt->getBase(), TransRValue); | 2871 | AstNode *container_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getBase()), TransRValue); |
| 2859 | if (container_node == nullptr) | 2872 | if (container_node == nullptr) |
| 2860 | return nullptr; | 2873 | return nullptr; |
| 2861 | | 2874 | |
| 2862 | AstNode *idx_node = trans_expr(c, ResultUsedYes, scope, stmt->getIdx(), TransRValue); | 2875 | AstNode *idx_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getIdx()), TransRValue); |
| 2863 | if (idx_node == nullptr) | 2876 | if (idx_node == nullptr) |
| 2864 | return nullptr; | 2877 | return nullptr; |
| 2865 | | 2878 | |
| ... | @@ -2873,7 +2886,7 @@ static AstNode *trans_array_subscript_expr(Context *c, ResultUsed result_used, T | ... | @@ -2873,7 +2886,7 @@ static AstNode *trans_array_subscript_expr(Context *c, ResultUsed result_used, T |
| 2873 | static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, TransScope *scope, | 2886 | static AstNode *trans_c_style_cast_expr(Context *c, ResultUsed result_used, TransScope *scope, |
| 2874 | const clang::CStyleCastExpr *stmt, TransLRValue lrvalue) | 2887 | const clang::CStyleCastExpr *stmt, TransLRValue lrvalue) |
| 2875 | { | 2888 | { |
| 2876 | AstNode *sub_expr_node = trans_expr(c, ResultUsedYes, scope, stmt->getSubExpr(), lrvalue); | 2889 | AstNode *sub_expr_node = trans_expr(c, ResultUsedYes, scope, bitcast(stmt->getSubExpr()), lrvalue); |
| 2877 | if (sub_expr_node == nullptr) | 2890 | if (sub_expr_node == nullptr) |
| 2878 | return nullptr; | 2891 | return nullptr; |
| 2879 | | 2892 | |
| ... | @@ -2943,7 +2956,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: | ... | @@ -2943,7 +2956,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const clang: |
| 2943 | } | 2956 | } |
| 2944 | | 2957 | |
| 2945 | // if (!cond) break; | 2958 | // if (!cond) break; |
| 2946 | AstNode *condition_node = trans_expr(c, ResultUsedYes, child_scope, stmt->getCond(), TransRValue); | 2959 | AstNode *condition_node = trans_expr(c, ResultUsedYes, child_scope, bitcast(stmt->getCond()), TransRValue); |
| 2947 | if (condition_node == nullptr) return nullptr; | 2960 | if (condition_node == nullptr) return nullptr; |
| 2948 | AstNode *terminator_node = trans_create_node(c, NodeTypeIfBoolExpr); | 2961 | AstNode *terminator_node = trans_create_node(c, NodeTypeIfBoolExpr); |
| 2949 | terminator_node->data.if_bool_expr.condition = trans_create_node_prefix_op(c, PrefixOpBoolNot, condition_node); | 2962 | terminator_node->data.if_bool_expr.condition = trans_create_node_prefix_op(c, PrefixOpBoolNot, condition_node); |
| ... | @@ -2982,29 +2995,21 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang | ... | @@ -2982,29 +2995,21 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const clang |
| 2982 | child_scope->node->data.block.statements.append(while_scope->node); | 2995 | child_scope->node->data.block.statements.append(while_scope->node); |
| 2983 | } | 2996 | } |
| 2984 | | 2997 | |
| 2985 | const ZigClangStmt *cond_stmt = bitcast(stmt->getCond()); | 2998 | const ZigClangExpr *cond_expr = bitcast(stmt->getCond()); |
| 2986 | if (cond_stmt == nullptr) { | 2999 | if (cond_expr == nullptr) { |
| 2987 | while_scope->node->data.while_expr.condition = trans_create_node_bool(c, true); | 3000 | while_scope->node->data.while_expr.condition = trans_create_node_bool(c, true); |
| 2988 | } else { | 3001 | } else { |
| 2989 | if (ZigClangStmt_classof_Expr(cond_stmt)) { | 3002 | while_scope->node->data.while_expr.condition = trans_bool_expr(c, ResultUsedYes, cond_scope, |
| 2990 | const clang::Expr *cond_expr = reinterpret_cast<const clang::Expr*>(cond_stmt); | 3003 | cond_expr, TransRValue); |
| 2991 | while_scope->node->data.while_expr.condition = trans_bool_expr(c, ResultUsedYes, cond_scope, cond_expr, TransRValue); | | |
| 2992 | | 3004 | |
| 2993 | if (while_scope->node->data.while_expr.condition == nullptr) | 3005 | if (while_scope->node->data.while_expr.condition == nullptr) |
| 2994 | return nullptr; | 3006 | return nullptr; |
| 2995 | } else { | | |
| 2996 | TransScope *end_cond_scope = trans_stmt(c, cond_scope, cond_stmt, | | |
| 2997 | &while_scope->node->data.while_expr.condition); | | |
| 2998 | if (end_cond_scope == nullptr) | | |
| 2999 | return nullptr; | | |
| 3000 | } | | |
| 3001 | } | 3007 | } |
| 3002 | | 3008 | |
| 3003 | const ZigClangStmt *inc_stmt = bitcast(stmt->getInc()); | 3009 | const ZigClangExpr *inc_expr = bitcast(stmt->getInc()); |
| 3004 | if (inc_stmt != nullptr) { | 3010 | if (inc_expr != nullptr) { |
| 3005 | AstNode *inc_node; | 3011 | AstNode *inc_node = trans_expr(c, ResultUsedNo, cond_scope, inc_expr, TransRValue); |
| 3006 | TransScope *inc_scope = trans_stmt(c, cond_scope, inc_stmt, &inc_node); | 3012 | if (inc_node == nullptr) |
| 3007 | if (inc_scope == nullptr) | | |
| 3008 | return nullptr; | 3013 | return nullptr; |
| 3009 | while_scope->node->data.while_expr.continue_expr = inc_node; | 3014 | while_scope->node->data.while_expr.continue_expr = inc_node; |
| 3010 | } | 3015 | } |
| ... | @@ -3047,7 +3052,7 @@ static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const cl | ... | @@ -3047,7 +3052,7 @@ static AstNode *trans_switch_stmt(Context *c, TransScope *parent_scope, const cl |
| 3047 | switch_scope->end_label_name = end_label_name; | 3052 | switch_scope->end_label_name = end_label_name; |
| 3048 | block_scope->node->data.block.name = end_label_name; | 3053 | block_scope->node->data.block.name = end_label_name; |
| 3049 | | 3054 | |
| 3050 | const clang::Expr *cond_expr = stmt->getCond(); | 3055 | const ZigClangExpr *cond_expr = bitcast(stmt->getCond()); |
| 3051 | assert(cond_expr != nullptr); | 3056 | assert(cond_expr != nullptr); |
| 3052 | | 3057 | |
| 3053 | AstNode *expr_node = trans_expr(c, ResultUsedYes, &block_scope->base, cond_expr, TransRValue); | 3058 | AstNode *expr_node = trans_expr(c, ResultUsedYes, &block_scope->base, cond_expr, TransRValue); |
| ... | @@ -3108,7 +3113,7 @@ static int trans_switch_case(Context *c, TransScope *parent_scope, const clang:: | ... | @@ -3108,7 +3113,7 @@ static int trans_switch_case(Context *c, TransScope *parent_scope, const clang:: |
| 3108 | { | 3113 | { |
| 3109 | // Add the prong | 3114 | // Add the prong |
| 3110 | AstNode *prong_node = trans_create_node(c, NodeTypeSwitchProng); | 3115 | AstNode *prong_node = trans_create_node(c, NodeTypeSwitchProng); |
| 3111 | AstNode *item_node = trans_expr(c, ResultUsedYes, &switch_scope->base, stmt->getLHS(), TransRValue); | 3116 | AstNode *item_node = trans_expr(c, ResultUsedYes, &switch_scope->base, bitcast(stmt->getLHS()), TransRValue); |
| 3112 | if (item_node == nullptr) | 3117 | if (item_node == nullptr) |
| 3113 | return ErrorUnexpected; | 3118 | return ErrorUnexpected; |
| 3114 | prong_node->data.switch_prong.items.append(item_node); | 3119 | prong_node->data.switch_prong.items.append(item_node); |
| ... | @@ -3313,7 +3318,8 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3313,7 +3318,8 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3313 | trans_continue_stmt(c, scope, (const clang::ContinueStmt *)stmt)); | 3318 | trans_continue_stmt(c, scope, (const clang::ContinueStmt *)stmt)); |
| 3314 | case ZigClangStmt_ParenExprClass: | 3319 | case ZigClangStmt_ParenExprClass: |
| 3315 | return wrap_stmt(out_node, out_child_scope, scope, | 3320 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3316 | trans_expr(c, result_used, scope, ((const clang::ParenExpr*)stmt)->getSubExpr(), lrvalue)); | 3321 | trans_expr(c, result_used, scope, |
| | 3322 | bitcast(((const clang::ParenExpr*)stmt)->getSubExpr()), lrvalue)); |
| 3317 | case ZigClangStmt_SwitchStmtClass: | 3323 | case ZigClangStmt_SwitchStmtClass: |
| 3318 | return wrap_stmt(out_node, out_child_scope, scope, | 3324 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3319 | trans_switch_stmt(c, scope, (const clang::SwitchStmt *)stmt)); | 3325 | trans_switch_stmt(c, scope, (const clang::SwitchStmt *)stmt)); |
| ... | @@ -3836,7 +3842,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3836,7 +3842,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3836 | } | 3842 | } |
| 3837 | | 3843 | |
| 3838 | // Returns null if there was an error | 3844 | // Returns null if there was an error |
| 3839 | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const clang::Expr *expr, | 3845 | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const ZigClangExpr *expr, |
| 3840 | TransLRValue lrval) | 3846 | TransLRValue lrval) |
| 3841 | { | 3847 | { |
| 3842 | AstNode *result_node; | 3848 | AstNode *result_node; |
| ... | @@ -4304,7 +4310,7 @@ static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQua | ... | @@ -4304,7 +4310,7 @@ static AstNode *trans_ap_value(Context *c, clang::APValue *ap_value, ZigClangQua |
| 4304 | case clang::APValue::LValue: { | 4310 | case clang::APValue::LValue: { |
| 4305 | const clang::APValue::LValueBase lval_base = ap_value->getLValueBase(); | 4311 | const clang::APValue::LValueBase lval_base = ap_value->getLValueBase(); |
| 4306 | if (const clang::Expr *expr = lval_base.dyn_cast<const clang::Expr *>()) { | 4312 | if (const clang::Expr *expr = lval_base.dyn_cast<const clang::Expr *>()) { |
| 4307 | return trans_expr(c, ResultUsedYes, &c->global_scope->base, expr, TransRValue); | 4313 | return trans_expr(c, ResultUsedYes, &c->global_scope->base, bitcast(expr), TransRValue); |
| 4308 | } | 4314 | } |
| 4309 | //const clang::ValueDecl *value_decl = lval_base.get<const clang::ValueDecl *>(); | 4315 | //const clang::ValueDecl *value_decl = lval_base.get<const clang::ValueDecl *>(); |
| 4310 | emit_warning(c, source_loc, "TODO handle initializer LValue clang::ValueDecl"); | 4316 | emit_warning(c, source_loc, "TODO handle initializer LValue clang::ValueDecl"); |