| ... | ... | @@ -329,9 +329,10 @@ fn transStmt( |
| 329 | 329 | const sc = ZigClangStmt_getStmtClass(stmt); |
| 330 | 330 | switch (sc) { |
| 331 | 331 | .CompoundStmtClass => return transCompoundStmt(rp, scope, @ptrCast(*const ZigClangCompoundStmt, stmt)), |
| 332 | .CStyleCastExprClass => return transCStyleCastExprClass(rp, scope, @ptrCast(*const ZigClangCStyleCastExpr, stmt), result_used, lrvalue), |
| 332 | 333 | .DeclStmtClass => return transDeclStmt(rp, scope, @ptrCast(*const ZigClangDeclStmt, stmt)), |
| 333 | 334 | .DeclRefExprClass => return transDeclRefExpr(rp, scope, @ptrCast(*const ZigClangDeclRefExpr, stmt), lrvalue), |
| 334 | | .ImplicitCastExprClass => return transImplicitCastExpr(rp, scope, @ptrCast(*const ZigClangImplicitCastExpr, stmt)), |
| 335 | .ImplicitCastExprClass => return transImplicitCastExpr(rp, scope, @ptrCast(*const ZigClangImplicitCastExpr, stmt), result_used), |
| 335 | 336 | else => { |
| 336 | 337 | return revertAndWarn( |
| 337 | 338 | rp, |
| ... | ... | @@ -377,6 +378,30 @@ fn transCompoundStmt(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangCompo |
| 377 | 378 | }; |
| 378 | 379 | } |
| 379 | 380 | |
| 381 | fn transCStyleCastExprClass( |
| 382 | rp: RestorePoint, |
| 383 | scope: *Scope, |
| 384 | stmt: *const ZigClangCStyleCastExpr, |
| 385 | result_used: ResultUsed, |
| 386 | lrvalue: LRValue, |
| 387 | ) !TransResult { |
| 388 | const sub_expr = ZigClangCStyleCastExpr_getSubExpr(stmt); |
| 389 | const cast_node = (try transCCast( |
| 390 | rp, |
| 391 | scope, |
| 392 | ZigClangCStyleCastExpr_getBeginLoc(stmt), |
| 393 | ZigClangCStyleCastExpr_getType(stmt), |
| 394 | ZigClangExpr_getType(sub_expr), |
| 395 | (try transExpr(rp, scope, sub_expr, .used, lrvalue)).node, |
| 396 | )); |
| 397 | const cast_res = TransResult{ |
| 398 | .node = cast_node, |
| 399 | .child_scope = scope, |
| 400 | .node_scope = scope, |
| 401 | }; |
| 402 | return maybeSuppressResult(rp, scope, result_used, cast_res); |
| 403 | } |
| 404 | |
| 380 | 405 | fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDeclStmt) !TransResult { |
| 381 | 406 | const c = rp.c; |
| 382 | 407 | const block_scope = findBlockScope(parent_scope); |
| ... | ... | @@ -478,27 +503,23 @@ fn transImplicitCastExpr( |
| 478 | 503 | rp: RestorePoint, |
| 479 | 504 | scope: *Scope, |
| 480 | 505 | expr: *const ZigClangImplicitCastExpr, |
| 506 | result_used: ResultUsed, |
| 481 | 507 | ) !TransResult { |
| 482 | 508 | const c = rp.c; |
| 483 | 509 | const sub_expr = ZigClangImplicitCastExpr_getSubExpr(expr); |
| 510 | const sub_expr_node = try transExpr(rp, scope, @ptrCast(*const ZigClangExpr, sub_expr), .used, .r_value); |
| 484 | 511 | switch (ZigClangImplicitCastExpr_getCastKind(expr)) { |
| 485 | 512 | .BitCast => { |
| 486 | | const node = try transExpr(rp, scope, @ptrCast(*const ZigClangExpr, sub_expr), .used, .r_value); |
| 487 | 513 | const dest_type = getExprQualType(c, @ptrCast(*const ZigClangExpr, expr)); |
| 488 | 514 | const src_type = getExprQualType(c, sub_expr); |
| 489 | 515 | return TransResult{ |
| 490 | | .node = try transCCast(rp, scope, ZigClangImplicitCastExpr_getBeginLoc(expr), dest_type, src_type, node.node), |
| 516 | .node = try transCCast(rp, scope, ZigClangImplicitCastExpr_getBeginLoc(expr), dest_type, src_type, sub_expr_node.node), |
| 491 | 517 | .node_scope = scope, |
| 492 | 518 | .child_scope = scope, |
| 493 | 519 | }; |
| 494 | 520 | }, |
| 495 | 521 | .FunctionToPointerDecay, .ArrayToPointerDecay => { |
| 496 | | return maybeSuppressResult( |
| 497 | | rp, |
| 498 | | scope, |
| 499 | | .used, |
| 500 | | try transExpr(rp, scope, @ptrCast(*const ZigClangExpr, sub_expr), .used, .r_value), |
| 501 | | ); |
| 522 | return maybeSuppressResult(rp, scope, result_used, sub_expr_node); |
| 502 | 523 | }, |
| 503 | 524 | else => |kind| return revertAndWarn( |
| 504 | 525 | rp, |