Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpp2rust/converter/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3105,7 +3105,7 @@ bool Converter::ConvertSwitchCaseCondition(clang::SwitchCase *stmt) {
while (auto *sc = clang::dyn_cast<clang::SwitchCase>(cur)) {
if (auto *case_stmt = clang::dyn_cast<clang::CaseStmt>(sc)) {
if (!first) {
StrCat("|| v == ");
StrCat("|| __v == ");
}
Convert(case_stmt->getLHS());
}
Expand All @@ -3127,7 +3127,7 @@ void Converter::EmitSwitchArm(clang::CompoundStmt *body, clang::SwitchCase *sc,
if (is_default) {
StrCat("_ => {");
} else {
StrCat("v if v == ");
StrCat("__v if __v == ");
ConvertSwitchCaseCondition(sc);
}
for (auto *t : GetSwitchCaseBody(body, sc)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/out/refcount/assign_as_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main_0() -> i32 {
(*out.borrow())
}) as i32);
match __match_cond {
v if v == ('x' as i32) => {
__v if __v == ('x' as i32) => {
assert!((1 != 0));
break 'switch;
}
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/out/refcount/enum_int_interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ pub fn classify_option_5(option: i32) -> i32 {
'switch: {
let __match_cond = (*option.borrow());
match __match_cond {
v if v == (Option::OPT_NONE as i32) => {
__v if __v == (Option::OPT_NONE as i32) => {
return -1_i32;
}
v if v == (Option::OPT_A as i32) => {
__v if __v == (Option::OPT_A as i32) => {
return 1;
}
v if v == (Option::OPT_B as i32) => {
__v if __v == (Option::OPT_B as i32) => {
return 2;
}
v if v == (Option::OPT_C as i32) => {
__v if __v == (Option::OPT_C as i32) => {
return 3;
}
_ => {
Expand Down Expand Up @@ -153,13 +153,13 @@ fn main_0() -> i32 {
'switch: {
let __match_cond = ((*c.borrow()) as i32);
match __match_cond {
v if v == 0 => {
__v if __v == 0 => {
break 'switch;
}
v if v == 1 => {
__v if __v == 1 => {
return 1;
}
v if v == 2 => {
__v if __v == 2 => {
return 2;
}
_ => {
Expand Down Expand Up @@ -215,13 +215,13 @@ fn main_0() -> i32 {
'switch: {
let __match_cond = ((*t.borrow()) as i32);
match __match_cond {
v if v == (Tag::TAG_ZERO as i32) => {
__v if __v == (Tag::TAG_ZERO as i32) => {
return 90;
}
v if v == 1 => {
__v if __v == 1 => {
return 91;
}
v if v == 2 => {
__v if __v == 2 => {
break 'switch;
}
_ => {}
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/out/refcount/enum_int_interop_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ pub fn classify_option_5(option: i32) -> i32 {
'switch: {
let __match_cond = (*option.borrow());
match __match_cond {
v if v == (Option::OPT_NONE as i32) => {
__v if __v == (Option::OPT_NONE as i32) => {
return -1_i32;
}
v if v == (Option::OPT_A as i32) => {
__v if __v == (Option::OPT_A as i32) => {
return 1;
}
v if v == (Option::OPT_B as i32) => {
__v if __v == (Option::OPT_B as i32) => {
return 2;
}
v if v == (Option::OPT_C as i32) => {
__v if __v == (Option::OPT_C as i32) => {
return 3;
}
_ => {
Expand Down Expand Up @@ -143,13 +143,13 @@ fn main_0() -> i32 {
'switch: {
let __match_cond = ((*c.borrow()) as u32);
match __match_cond {
v if v == (0 as u32) => {
__v if __v == (0 as u32) => {
break 'switch;
}
v if v == (1 as u32) => {
__v if __v == (1 as u32) => {
return 1;
}
v if v == (2 as u32) => {
__v if __v == (2 as u32) => {
return 2;
}
_ => {
Expand Down Expand Up @@ -209,13 +209,13 @@ fn main_0() -> i32 {
'switch: {
let __match_cond = ((*t.borrow()) as u32);
match __match_cond {
v if v == ((Tag_enum::TAG_ZERO as i32) as u32) => {
__v if __v == ((Tag_enum::TAG_ZERO as i32) as u32) => {
return 90;
}
v if v == (1 as u32) => {
__v if __v == (1 as u32) => {
return 91;
}
v if v == (2 as u32) => {
__v if __v == (2 as u32) => {
break 'switch;
}
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/out/refcount/goto_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn from_switch_2(n: i32) -> i32 {
'switch: {
let __match_cond = (*n.borrow());
match __match_cond {
v if v == 1 => {
__v if __v == 1 => {
(*ret.borrow_mut()) = 10;
goto!('out);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/out/refcount/goto_switch_fallthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ pub fn sm_0(n: i32) -> i32 {
'__entry: {
*ret.borrow_mut() = 0;
switch!(match (*n.borrow()) {
v if v == 0 => {
__v if __v == 0 => {
(*ret.borrow_mut()) += 1;
}
v if v == 1 => {
__v if __v == 1 => {
(*ret.borrow_mut()) += 10;
goto!('out);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/out/refcount/switch_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ use std::rc::{Rc, Weak};
pub fn basic_0(x: i32) -> i32 {
let x: Value<i32> = Rc::new(RefCell::new(x));
let r: Value<i32> = Rc::new(RefCell::new(0));
let v: Value<i32> = Rc::new(RefCell::new(0));
'switch: {
let __match_cond = (*x.borrow());
match __match_cond {
v if v == 0 => {
__v if __v == 0 => {
(*r.borrow_mut()) = 10;
break 'switch;
}
v if v == 1 => {
__v if __v == 1 => {
(*r.borrow_mut()) = 20;
break 'switch;
}
v if v == 2 => {
__v if __v == 2 => {
(*r.borrow_mut()) = 30;
break 'switch;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::rc::{Rc, Weak};
pub fn borrow_in_condition_and_in_body_0(x: i32) -> i32 {
let x: Value<i32> = Rc::new(RefCell::new(x));
switch!(match (*x.borrow()) {
v if v == 0 => {}
__v if __v == 0 => {}
_ => {
return ((*x.borrow()) + 1);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/out/refcount/switch_case_then_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn case_then_default_0(x: i32) -> i32 {
'switch: {
let __match_cond = (*x.borrow());
match __match_cond {
v if v == 2 => {
__v if __v == 2 => {
(*r.borrow_mut()) = 20;
break 'switch;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn cases_and_default_stacked_0(x: i32) -> i32 {
'switch: {
let __match_cond = (*x.borrow());
match __match_cond {
v if v == 3 => {
__v if __v == 3 => {
(*r.borrow_mut()) = 3;
break 'switch;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/out/refcount/switch_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ pub fn switch_char_0(c: u8) -> i32 {
'switch: {
let __match_cond = ((*c.borrow()) as i32);
match __match_cond {
v if v == (('a' as u8) as i32) => {
__v if __v == (('a' as u8) as i32) => {
return 1;
}
v if v == (('b' as u8) as i32) => {
__v if __v == (('b' as u8) as i32) => {
return 2;
}
v if v == (('\n' as u8) as i32) => {
__v if __v == (('\n' as u8) as i32) => {
return 3;
}
v if v == (('\0' as u8) as i32) => {
__v if __v == (('\0' as u8) as i32) => {
return 4;
}
_ => {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/out/refcount/switch_complex_cond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ pub fn switch_complex_cond_0(p: Ptr<i32>, bias: i32) -> i32 {
_lhs + (*bias.borrow())
};
match __match_cond {
v if v == 0 => {
__v if __v == 0 => {
return 1;
}
v if v == 5 => {
__v if __v == 5 => {
return 2;
}
v if v == 10 => {
__v if __v == 10 => {
return 3;
}
_ => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/out/refcount/switch_compound_case_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ pub fn compound_case_body_0(x: i32) -> i32 {
'switch: {
let __match_cond = (*x.borrow());
match __match_cond {
v if v == 1 => {
__v if __v == 1 => {
let y: Value<i32> = Rc::new(RefCell::new(10));
let z: Value<i32> = Rc::new(RefCell::new(20));
(*r.borrow_mut()) = ((*y.borrow()) + (*z.borrow()));
break 'switch;
}
v if v == 2 => {
__v if __v == 2 => {
let y: Value<i32> = Rc::new(RefCell::new(100));
(*r.borrow_mut()) = ((*y.borrow()) - 1);
break 'switch;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/out/refcount/switch_continue_inside_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn continue_inside_switch_0(n: i32) -> i32 {
'switch: {
let __match_cond = (*i.borrow());
match __match_cond {
v if v == 0 || v == 2 || v == 4 => {
__v if __v == 0 || __v == 2 || __v == 4 => {
(*i.borrow_mut()).prefix_inc();
continue 'loop_;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/out/refcount/switch_default_first.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ pub fn default_first_0(x: i32) -> i32 {
'switch: {
let __match_cond = (*x.borrow());
match __match_cond {
v if v == 1 => {
__v if __v == 1 => {
(*r.borrow_mut()) = 1;
break 'switch;
}
v if v == 2 => {
__v if __v == 2 => {
(*r.borrow_mut()) = 2;
break 'switch;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/out/refcount/switch_default_middle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ pub fn default_middle_0(x: i32) -> i32 {
'switch: {
let __match_cond = (*x.borrow());
match __match_cond {
v if v == 1 => {
__v if __v == 1 => {
(*r.borrow_mut()) = 1;
break 'switch;
}
v if v == 2 => {
__v if __v == 2 => {
(*r.borrow_mut()) = 2;
break 'switch;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/out/refcount/switch_default_then_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ pub fn default_then_case_0(x: i32) -> i32 {
'switch: {
let __match_cond = (*x.borrow());
match __match_cond {
v if v == 1 => {
__v if __v == 1 => {
(*r.borrow_mut()) = 1;
break 'switch;
}
v if v == 3 => {
__v if __v == 3 => {
(*r.borrow_mut()) = 3;
break 'switch;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/out/refcount/switch_empty_case_with_break.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ pub fn empty_case_with_break_0(x: i32) -> i32 {
'switch: {
let __match_cond = (*x.borrow());
match __match_cond {
v if v == 1 => {
__v if __v == 1 => {
break 'switch;
}
v if v == 2 => {
__v if __v == 2 => {
(*r.borrow_mut()) = 2;
break 'switch;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/out/refcount/switch_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ pub fn switch_enum_0(c: Color) -> i32 {
'switch: {
let __match_cond = ((*c.borrow()) as i32);
match __match_cond {
v if v == (Color::kRed as i32) => {
__v if __v == (Color::kRed as i32) => {
return 10;
}
v if v == (Color::kGreen as i32) => {
__v if __v == (Color::kGreen as i32) => {
return 20;
}
v if v == (Color::kBlue as i32) => {
__v if __v == (Color::kBlue as i32) => {
return 30;
}
_ => {}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/out/refcount/switch_fallthrough_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ pub fn fallthrough_chain_0(x: i32) -> i32 {
let x: Value<i32> = Rc::new(RefCell::new(x));
let r: Value<i32> = Rc::new(RefCell::new(0));
switch!(match (*x.borrow()) {
v if v == 1 => {
__v if __v == 1 => {
(*r.borrow_mut()) += 1;
}
v if v == 2 => {
__v if __v == 2 => {
(*r.borrow_mut()) += 2;
}
v if v == 3 => {
__v if __v == 3 => {
(*r.borrow_mut()) += 4;
}
v if v == 4 => {
__v if __v == 4 => {
(*r.borrow_mut()) += 8;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/out/refcount/switch_fallthrough_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn fallthrough_default_0(x: i32, flag: i32) -> i32 {
let flag: Value<i32> = Rc::new(RefCell::new(flag));
let r: Value<i32> = Rc::new(RefCell::new(0));
switch!(match (*x.borrow()) {
v if v == 7 => {
__v if __v == 7 => {
if ((*flag.borrow()) != 0) {
(*r.borrow_mut()) = 100;
break;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/out/refcount/switch_fallthrough_into_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ pub fn fallthrough_into_block_0(x: i32) -> i32 {
let x: Value<i32> = Rc::new(RefCell::new(x));
let r: Value<i32> = Rc::new(RefCell::new(0));
switch!(match (*x.borrow()) {
v if v == 1 => {
__v if __v == 1 => {
(*r.borrow_mut()) += 1;
}
v if v == 2 => {
__v if __v == 2 => {
let tmp: Value<i32> = Rc::new(RefCell::new(((*r.borrow()) * 10)));
(*r.borrow_mut()) = ((*tmp.borrow()) + 5);
break;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/out/refcount/switch_fallthrough_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ pub fn fallthrough_one_0(x: i32) -> i32 {
let x: Value<i32> = Rc::new(RefCell::new(x));
let r: Value<i32> = Rc::new(RefCell::new(0));
switch!(match (*x.borrow()) {
v if v == 1 => {
__v if __v == 1 => {
(*r.borrow_mut()) += 10;
}
v if v == 2 => {
__v if __v == 2 => {
(*r.borrow_mut()) += 20;
break;
}
Expand Down
Loading
Loading