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
22 changes: 12 additions & 10 deletions rules/stdio/ir_refcount.json
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@
"f5": {
"body": [
{
"text": "libcc2rs::fread_refcount("
"text": "let __a0 = "
},
{
"placeholder": {
Expand All @@ -440,7 +440,7 @@
}
},
{
"text": ", "
"text": ";\n let __a1 = "
},
{
"placeholder": {
Expand All @@ -449,7 +449,7 @@
}
},
{
"text": ", "
"text": ";\n let __a2 = "
},
{
"placeholder": {
Expand All @@ -458,7 +458,7 @@
}
},
{
"text": ", "
"text": ";\n let __a3 = "
},
{
"method_call": {
Expand All @@ -478,9 +478,10 @@
}
},
{
"text": ")"
"text": ";\n libcc2rs::fread_refcount(__a0, __a1, __a2, __a3)"
}
],
"multi_statement": true,
"params": {
"a0": {
"type": "AnyPtr"
Expand All @@ -503,7 +504,7 @@
"f6": {
"body": [
{
"text": "libcc2rs::fwrite_refcount("
"text": "let __a0 = "
},
{
"placeholder": {
Expand All @@ -512,7 +513,7 @@
}
},
{
"text": ", "
"text": ";\n let __a1 = "
},
{
"placeholder": {
Expand All @@ -521,7 +522,7 @@
}
},
{
"text": ", "
"text": ";\n let __a2 = "
},
{
"placeholder": {
Expand All @@ -530,7 +531,7 @@
}
},
{
"text": ", "
"text": ";\n let __a3 = "
},
{
"method_call": {
Expand All @@ -550,9 +551,10 @@
}
},
{
"text": ")"
"text": ";\n libcc2rs::fwrite_refcount(__a0, __a1, __a2, __a3)"
}
],
"multi_statement": true,
"params": {
"a0": {
"type": "AnyPtr"
Expand Down
22 changes: 12 additions & 10 deletions rules/stdio/ir_unsafe.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@
"f5": {
"body": [
{
"text": "libcc2rs::fread_unsafe("
"text": "let __a0 = "
},
{
"placeholder": {
Expand All @@ -497,7 +497,7 @@
}
},
{
"text": " as *mut ::std::ffi::c_void, "
"text": " as *mut ::std::ffi::c_void;\n let __a1 = "
},
{
"placeholder": {
Expand All @@ -506,7 +506,7 @@
}
},
{
"text": ", "
"text": ";\n let __a2 = "
},
{
"placeholder": {
Expand All @@ -515,7 +515,7 @@
}
},
{
"text": ", "
"text": ";\n let __a3 = "
},
{
"placeholder": {
Expand All @@ -524,9 +524,10 @@
}
},
{
"text": ")"
"text": ";\n libcc2rs::fread_unsafe(__a0, __a1, __a2, __a3)"
}
],
"multi_statement": true,
"params": {
"a0": {
"type": "*mut ::libc::c_void",
Expand All @@ -550,7 +551,7 @@
"f6": {
"body": [
{
"text": "libcc2rs::fwrite_unsafe("
"text": "let __a0 = "
},
{
"placeholder": {
Expand All @@ -559,7 +560,7 @@
}
},
{
"text": " as *const ::std::ffi::c_void, "
"text": " as *const ::std::ffi::c_void;\n let __a1 = "
},
{
"placeholder": {
Expand All @@ -568,7 +569,7 @@
}
},
{
"text": ", "
"text": ";\n let __a2 = "
},
{
"placeholder": {
Expand All @@ -577,7 +578,7 @@
}
},
{
"text": ", "
"text": ";\n let __a3 = "
},
{
"placeholder": {
Expand All @@ -586,9 +587,10 @@
}
},
{
"text": ")"
"text": ";\n libcc2rs::fwrite_unsafe(__a0, __a1, __a2, __a3)"
}
],
"multi_statement": true,
"params": {
"a0": {
"type": "*const ::libc::c_void",
Expand Down
12 changes: 10 additions & 2 deletions rules/stdio/tgt_refcount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@ fn f4(a0: &mut ::std::fs::File, a1: i64, a2: i32) -> i32 {
}

fn f5(a0: AnyPtr, a1: u64, a2: u64, a3: Ptr<::std::fs::File>) -> u64 {
libcc2rs::fread_refcount(a0, a1, a2, a3.clone())
let __a0 = a0;
let __a1 = a1;
let __a2 = a2;
let __a3 = a3.clone();
libcc2rs::fread_refcount(__a0, __a1, __a2, __a3)
}

fn f6(a0: AnyPtr, a1: u64, a2: u64, a3: Ptr<::std::fs::File>) -> u64 {
libcc2rs::fwrite_refcount(a0, a1, a2, a3.clone())
let __a0 = a0;
let __a1 = a1;
let __a2 = a2;
let __a3 = a3.clone();
libcc2rs::fwrite_refcount(__a0, __a1, __a2, __a3)
}

fn f7(a0: Ptr<::std::fs::File>) -> i32 {
Expand Down
12 changes: 10 additions & 2 deletions rules/stdio/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ unsafe fn f4(a0: *mut ::std::fs::File, a1: i64, a2: i32) -> i32 {
}

unsafe fn f5(a0: *mut ::libc::c_void, a1: u64, a2: u64, a3: *mut ::std::fs::File) -> u64 {
libcc2rs::fread_unsafe(a0 as *mut ::std::ffi::c_void, a1, a2, a3)
let __a0 = a0 as *mut ::std::ffi::c_void;
let __a1 = a1;
let __a2 = a2;
let __a3 = a3;
libcc2rs::fread_unsafe(__a0, __a1, __a2, __a3)
}

unsafe fn f6(a0: *const ::libc::c_void, a1: u64, a2: u64, a3: *mut ::std::fs::File) -> u64 {
libcc2rs::fwrite_unsafe(a0 as *const ::std::ffi::c_void, a1, a2, a3)
let __a0 = a0 as *const ::std::ffi::c_void;
let __a1 = a1;
let __a2 = a2;
let __a3 = a3;
libcc2rs::fwrite_unsafe(__a0, __a1, __a2, __a3)
}

unsafe fn f7(a0: *mut ::std::fs::File) -> i32 {
Expand Down
26 changes: 14 additions & 12 deletions tests/unit/out/refcount/fn_ptr_stdlib_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ fn main_0() -> i32 {
);
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().clone()
};
let n: Value<u64> = Rc::new(RefCell::new(libcc2rs::fread_refcount(
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any(),
1_u64,
10_u64,
(*stream.borrow()).clone(),
)));
let n: Value<u64> = Rc::new(RefCell::new({
let __a0 = ((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any();
let __a1 = 1_u64;
let __a2 = 10_u64;
let __a3 = (*stream.borrow()).clone();
libcc2rs::fread_refcount(__a0, __a1, __a2, __a3)
}));
assert!(((*n.borrow()) == 10_u64));
let i: Value<i32> = Rc::new(RefCell::new(0));
'loop_: while ((*i.borrow()) < 10) {
Expand Down Expand Up @@ -267,12 +268,13 @@ fn main_0() -> i32 {
);
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().clone()
};
let n: Value<u64> = Rc::new(RefCell::new(libcc2rs::fwrite_refcount(
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any(),
1_u64,
10_u64,
(*stream.borrow()).clone(),
)));
let n: Value<u64> = Rc::new(RefCell::new({
let __a0 = ((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any();
let __a1 = 1_u64;
let __a2 = 10_u64;
let __a3 = (*stream.borrow()).clone();
libcc2rs::fwrite_refcount(__a0, __a1, __a2, __a3)
}));
assert!(((*n.borrow()) == 10_u64));
{
(*stream.borrow()).delete();
Expand Down
28 changes: 16 additions & 12 deletions tests/unit/out/unsafe/fn_ptr_stdlib_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ unsafe fn main_0() -> i32 {
}
(buf.as_mut_ptr() as *mut u8 as *mut ::libc::c_void)
};
let mut n: u64 = libcc2rs::fread_unsafe(
(buf.as_mut_ptr() as *mut u8 as *mut ::libc::c_void) as *mut ::std::ffi::c_void,
1_u64,
10_u64,
stream,
);
let mut n: u64 = {
let __a0 =
(buf.as_mut_ptr() as *mut u8 as *mut ::libc::c_void) as *mut ::std::ffi::c_void;
let __a1 = 1_u64;
let __a2 = 10_u64;
let __a3 = stream;
libcc2rs::fread_unsafe(__a0, __a1, __a2, __a3)
};
assert!(((n) == (10_u64)));
let mut i: i32 = 0;
'loop_: while ((i) < (10)) {
Expand Down Expand Up @@ -250,12 +252,14 @@ unsafe fn main_0() -> i32 {
}
(buf.as_mut_ptr() as *mut u8 as *mut ::libc::c_void)
};
let mut n: u64 = libcc2rs::fwrite_unsafe(
(buf.as_mut_ptr() as *const u8 as *const ::libc::c_void) as *const ::std::ffi::c_void,
1_u64,
10_u64,
stream,
);
let mut n: u64 = {
let __a0 = (buf.as_mut_ptr() as *const u8 as *const ::libc::c_void)
as *const ::std::ffi::c_void;
let __a1 = 1_u64;
let __a2 = 10_u64;
let __a3 = stream;
libcc2rs::fwrite_unsafe(__a0, __a1, __a2, __a3)
};
assert!(((n) == (10_u64)));
{
Box::from_raw(stream);
Expand Down
Loading