| ... | @@ -503,10 +503,6 @@ static AstNode *add_global_var(Context *c, Buf *var_name, AstNode *value_node) { | ... | @@ -503,10 +503,6 @@ static AstNode *add_global_var(Context *c, Buf *var_name, AstNode *value_node) { |
| 503 | return node; | 503 | return node; |
| 504 | } | 504 | } |
| 505 | | 505 | |
| 506 | static Buf *string_ref_to_buf(llvm::StringRef string_ref) { | | |
| 507 | return buf_create_from_mem((const char *)string_ref.bytes_begin(), string_ref.size()); | | |
| 508 | } | | |
| 509 | | | |
| 510 | static AstNode *trans_create_node_apint(Context *c, const ZigClangAPSInt *aps_int) { | 506 | static AstNode *trans_create_node_apint(Context *c, const ZigClangAPSInt *aps_int) { |
| 511 | AstNode *node = trans_create_node(c, NodeTypeIntLiteral); | 507 | AstNode *node = trans_create_node(c, NodeTypeIntLiteral); |
| 512 | node->data.int_literal.bigint = allocate<BigInt>(1); | 508 | node->data.int_literal.bigint = allocate<BigInt>(1); |
| ... | @@ -671,7 +667,7 @@ static AstNode *qual_type_to_log2_int_ref(Context *c, const ZigClangQualType qt, | ... | @@ -671,7 +667,7 @@ static AstNode *qual_type_to_log2_int_ref(Context *c, const ZigClangQualType qt, |
| 671 | // FieldAccess | 667 | // FieldAccess |
| 672 | // FnCall (.builtin = true) | 668 | // FnCall (.builtin = true) |
| 673 | // Symbol "import" | 669 | // Symbol "import" |
| 674 | // clang::StringLiteral "std" | 670 | // ZigClangStringLiteral "std" |
| 675 | // Symbol "math" | 671 | // Symbol "math" |
| 676 | // Symbol "Log2Int" | 672 | // Symbol "Log2Int" |
| 677 | // zig_type_node | 673 | // zig_type_node |
| ... | @@ -3334,21 +3330,23 @@ static int trans_switch_default(Context *c, TransScope *parent_scope, const clan | ... | @@ -3334,21 +3330,23 @@ static int trans_switch_default(Context *c, TransScope *parent_scope, const clan |
| 3334 | return ErrorNone; | 3330 | return ErrorNone; |
| 3335 | } | 3331 | } |
| 3336 | | 3332 | |
| 3337 | static AstNode *trans_string_literal(Context *c, ResultUsed result_used, TransScope *scope, const clang::StringLiteral *stmt) { | 3333 | static AstNode *trans_string_literal(Context *c, ResultUsed result_used, TransScope *scope, const ZigClangStringLiteral *stmt) { |
| 3338 | switch (stmt->getKind()) { | 3334 | switch (ZigClangStringLiteral_getKind(stmt)) { |
| 3339 | case clang::StringLiteral::Ascii: | 3335 | case ZigClangStringLiteral_StringKind_Ascii: |
| 3340 | case clang::StringLiteral::UTF8: { | 3336 | case ZigClangStringLiteral_StringKind_UTF8: { |
| 3341 | AstNode *node = trans_create_node_str_lit_c(c, string_ref_to_buf(stmt->getString())); | 3337 | size_t str_len; |
| | 3338 | const char *str_ptr = ZigClangStringLiteral_getString_bytes_begin_size(stmt, &str_len); |
| | 3339 | AstNode *node = trans_create_node_str_lit_c(c, buf_create_from_mem(str_ptr, str_len)); |
| 3342 | return maybe_suppress_result(c, result_used, node); | 3340 | return maybe_suppress_result(c, result_used, node); |
| 3343 | } | 3341 | } |
| 3344 | case clang::StringLiteral::UTF16: | 3342 | case ZigClangStringLiteral_StringKind_UTF16: |
| 3345 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO support UTF16 string literals"); | 3343 | emit_warning(c, ZigClangStmt_getBeginLoc((const ZigClangStmt *)stmt), "TODO support UTF16 string literals"); |
| 3346 | return nullptr; | 3344 | return nullptr; |
| 3347 | case clang::StringLiteral::UTF32: | 3345 | case ZigClangStringLiteral_StringKind_UTF32: |
| 3348 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO support UTF32 string literals"); | 3346 | emit_warning(c, ZigClangStmt_getBeginLoc((const ZigClangStmt *)stmt), "TODO support UTF32 string literals"); |
| 3349 | return nullptr; | 3347 | return nullptr; |
| 3350 | case clang::StringLiteral::Wide: | 3348 | case ZigClangStringLiteral_StringKind_Wide: |
| 3351 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO support wide string literals"); | 3349 | emit_warning(c, ZigClangStmt_getBeginLoc((const ZigClangStmt *)stmt), "TODO support wide string literals"); |
| 3352 | return nullptr; | 3350 | return nullptr; |
| 3353 | } | 3351 | } |
| 3354 | zig_unreachable(); | 3352 | zig_unreachable(); |
| ... | @@ -3368,14 +3366,14 @@ static AstNode *trans_break_stmt(Context *c, TransScope *scope, const clang::Bre | ... | @@ -3368,14 +3366,14 @@ static AstNode *trans_break_stmt(Context *c, TransScope *scope, const clang::Bre |
| 3368 | zig_unreachable(); | 3366 | zig_unreachable(); |
| 3369 | } | 3367 | } |
| 3370 | | 3368 | |
| 3371 | static AstNode *trans_continue_stmt(Context *c, TransScope *scope, const clang::ContinueStmt *stmt) { | 3369 | static AstNode *trans_continue_stmt(Context *c, TransScope *scope, const ZigClangContinueStmt *stmt) { |
| 3372 | return trans_create_node(c, NodeTypeContinue); | 3370 | return trans_create_node(c, NodeTypeContinue); |
| 3373 | } | 3371 | } |
| 3374 | | 3372 | |
| 3375 | static AstNode *trans_predefined_expr(Context *c, ResultUsed result_used, TransScope *scope, | 3373 | static AstNode *trans_predefined_expr(Context *c, ResultUsed result_used, TransScope *scope, |
| 3376 | const clang::PredefinedExpr *expr) | 3374 | const ZigClangPredefinedExpr *expr) |
| 3377 | { | 3375 | { |
| 3378 | return trans_string_literal(c, result_used, scope, expr->getFunctionName()); | 3376 | return trans_string_literal(c, result_used, scope, ZigClangPredefinedExpr_getFunctionName(expr)); |
| 3379 | } | 3377 | } |
| 3380 | | 3378 | |
| 3381 | static int wrap_stmt(AstNode **out_node, TransScope **out_scope, TransScope *in_scope, AstNode *result_node) { | 3379 | static int wrap_stmt(AstNode **out_node, TransScope **out_scope, TransScope *in_scope, AstNode *result_node) { |
| ... | @@ -3466,13 +3464,13 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3466,13 +3464,13 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3466 | } | 3464 | } |
| 3467 | case ZigClangStmt_StringLiteralClass: | 3465 | case ZigClangStmt_StringLiteralClass: |
| 3468 | return wrap_stmt(out_node, out_child_scope, scope, | 3466 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3469 | trans_string_literal(c, result_used, scope, (const clang::StringLiteral *)stmt)); | 3467 | trans_string_literal(c, result_used, scope, (const ZigClangStringLiteral *)stmt)); |
| 3470 | case ZigClangStmt_BreakStmtClass: | 3468 | case ZigClangStmt_BreakStmtClass: |
| 3471 | return wrap_stmt(out_node, out_child_scope, scope, | 3469 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3472 | trans_break_stmt(c, scope, (const clang::BreakStmt *)stmt)); | 3470 | trans_break_stmt(c, scope, (const clang::BreakStmt *)stmt)); |
| 3473 | case ZigClangStmt_ContinueStmtClass: | 3471 | case ZigClangStmt_ContinueStmtClass: |
| 3474 | return wrap_stmt(out_node, out_child_scope, scope, | 3472 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3475 | trans_continue_stmt(c, scope, (const clang::ContinueStmt *)stmt)); | 3473 | trans_continue_stmt(c, scope, (const ZigClangContinueStmt *)stmt)); |
| 3476 | case ZigClangStmt_ParenExprClass: | 3474 | case ZigClangStmt_ParenExprClass: |
| 3477 | return wrap_stmt(out_node, out_child_scope, scope, | 3475 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3478 | trans_expr(c, result_used, scope, | 3476 | trans_expr(c, result_used, scope, |
| ... | @@ -3489,7 +3487,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s | ... | @@ -3489,7 +3487,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3489 | trans_constant_expr(c, result_used, (const clang::ConstantExpr *)stmt)); | 3487 | trans_constant_expr(c, result_used, (const clang::ConstantExpr *)stmt)); |
| 3490 | case ZigClangStmt_PredefinedExprClass: | 3488 | case ZigClangStmt_PredefinedExprClass: |
| 3491 | return wrap_stmt(out_node, out_child_scope, scope, | 3489 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3492 | trans_predefined_expr(c, result_used, scope, (const clang::PredefinedExpr *)stmt)); | 3490 | trans_predefined_expr(c, result_used, scope, (const ZigClangPredefinedExpr *)stmt)); |
| 3493 | case ZigClangStmt_StmtExprClass: | 3491 | case ZigClangStmt_StmtExprClass: |
| 3494 | return wrap_stmt(out_node, out_child_scope, scope, | 3492 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3495 | trans_stmt_expr(c, result_used, scope, (const clang::StmtExpr *)stmt, out_node_scope)); | 3493 | trans_stmt_expr(c, result_used, scope, (const clang::StmtExpr *)stmt, out_node_scope)); |