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
10 changes: 10 additions & 0 deletions rules/array/src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ template <typename T1, std::size_t T2>
std::array<T1, T2> &f5(std::array<T1, T2> &dst, std::array<T1, T2> &&src) {
return dst.operator=(std::move(src));
}

template <typename T1, std::size_t T2>
std::array<T1, T2> f6(const std::array<T1, T2> &o) {
return std::array<T1, T2>(o);
}

template <typename T1, std::size_t T2>
std::array<T1, T2> &f7(std::array<T1, T2> &dst, const std::array<T1, T2> &src) {
return dst.operator=(src);
}
4 changes: 4 additions & 0 deletions rules/array/tgt_refcount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ fn f3<T1>(a0: Ptr<T1>) -> Ptr<T1> {
fn f5<T1: ByteRepr + Clone>(a0: Ptr<Vec<T1>>, a1: &mut Vec<T1>) {
a0.write(std::mem::take(&mut *a1))
}

fn f7<T1: Clone + ByteRepr>(a0: Ptr<Vec<T1>>, a1: Vec<T1>) {
a0.write(a1.clone())
}
8 changes: 8 additions & 0 deletions rules/array/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ unsafe fn f4<T1>(a0: &mut Vec<T1>) -> Vec<T1> {
unsafe fn f5<T1>(a0: &mut Vec<T1>, a1: &mut Vec<T1>) {
*a0 = std::mem::take(&mut *a1)
}

unsafe fn f6<T1: Clone>(a0: Vec<T1>) -> Vec<T1> {
a0.clone()
}

unsafe fn f7<T1: Clone>(a0: &mut Vec<T1>, a1: Vec<T1>) {
*a0 = a1.clone()
}
6 changes: 6 additions & 0 deletions rules/builtin/src.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

#include <stddef.h>

#if defined(__linux__)
#include <byteswap.h>
#elif !defined(__APPLE__)
Expand All @@ -26,3 +28,7 @@ bool f10(long long a, long long b, long long *r) { return __builtin_mul_overflow
#if defined(__x86_64__) || defined(__i386__)
void f11(void) { return __builtin_ia32_pause(); }
#endif

void *f14(void *dst, const void *src, size_t n) {
return __builtin_memcpy(dst, src, n);
}
5 changes: 5 additions & 0 deletions rules/builtin/tgt_refcount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ fn f13(a0: i64, a1: i64, a2: Ptr<i64>) -> bool {
a2.write(val);
ovf
}

fn f14(a0: AnyPtr, a1: AnyPtr, a2: usize) -> AnyPtr {
a0.memcpy(&a1, a2 as usize);
a0.clone()
}
7 changes: 7 additions & 0 deletions rules/builtin/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ unsafe fn f13(a0: i64, a1: i64, a2: *mut i64) -> bool {
*a2 = val;
ovf
}

unsafe fn f14(a0: *mut u8, a1: *const u8, a2: usize) -> *mut u8 {
if a2 != 0 {
::std::ptr::copy_nonoverlapping(a1, a0, a2 as usize)
}
a0
}
18 changes: 18 additions & 0 deletions rules/deque/src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@ template <typename T1>
void f7(std::deque<std::vector<T1>> &o, const std::vector<T1> &value) {
return o.push_back(value);
}

template <typename T1> std::deque<T1> f8(const std::deque<T1> &o) {
return std::deque<T1>(o);
}

template <typename T1> std::deque<T1> f9(std::deque<T1> &&o) {
return std::deque<T1>(std::move(o));
}

template <typename T1>
std::deque<T1> &f10(std::deque<T1> &dst, const std::deque<T1> &src) {
return dst.operator=(src);
}

template <typename T1>
std::deque<T1> &f11(std::deque<T1> &dst, std::deque<T1> &&src) {
return dst.operator=(std::move(src));
}
8 changes: 8 additions & 0 deletions rules/deque/tgt_refcount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ fn f2<T1>(a0: Ptr<T1>) -> Ptr<T1> {
fn f7<T1: ByteRepr>(a0: Ptr<Vec<Value<Vec<T1>>>>, a1: Value<Vec<T1>>) {
a0.with_mut(|__v: &mut Vec<Value<Vec<T1>>>| __v.push(a1))
}

fn f10<T1: Clone + ByteRepr>(a0: Ptr<Vec<T1>>, a1: Vec<T1>) {
a0.write(a1.clone())
}

fn f11<T1: ByteRepr + Clone>(a0: Ptr<Vec<T1>>, a1: &mut Vec<T1>) {
a0.write(std::mem::take(&mut *a1))
}
16 changes: 16 additions & 0 deletions rules/deque/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,19 @@ unsafe fn f5<T1>(a0: &mut Vec<T1>) -> T1 {
unsafe fn f7<T1>(a0: &mut Vec<Vec<T1>>, a1: Vec<T1>) {
a0.push(a1)
}

unsafe fn f8<T1: Clone>(a0: Vec<T1>) -> Vec<T1> {
a0.clone()
}

unsafe fn f9<T1>(a0: &mut Vec<T1>) -> Vec<T1> {
std::mem::take(&mut *a0)
}

unsafe fn f10<T1: Clone>(a0: &mut Vec<T1>, a1: Vec<T1>) {
*a0 = a1.clone()
}

unsafe fn f11<T1>(a0: &mut Vec<T1>, a1: &mut Vec<T1>) {
*a0 = std::mem::take(&mut *a1)
}
5 changes: 5 additions & 0 deletions rules/map/src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,8 @@ template <typename T1, typename T2>
std::map<T1, T2> &f25(std::map<T1, T2> &dst, std::map<T1, T2> &&src) {
return dst.operator=(std::move(src));
}

template <typename T1, typename T2>
std::map<T1, T2> &f26(std::map<T1, T2> &dst, const std::map<T1, T2> &src) {
return dst.operator=(src);
}
11 changes: 11 additions & 0 deletions rules/map/tgt_refcount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,14 @@ fn f25<T1: 'static, T2: 'static>(
let __src = a1.with_mut(|__v: &mut BTreeMap<T1, Value<T2>>| std::mem::take(__v));
a0.write(__src)
}

fn f26<T1: Ord + Clone + 'static, T2: Clone + 'static>(
a0: Ptr<BTreeMap<T1, Value<T2>>>,
a1: BTreeMap<T1, Value<T2>>,
) {
a0.write(
a1.iter()
.map(|(k, v)| (k.clone(), Rc::new(RefCell::new(v.borrow().clone()))))
.collect(),
)
}
4 changes: 4 additions & 0 deletions rules/map/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ unsafe fn f24<T1, T2>(a0: &mut BTreeMap<T1, Box<T2>>) -> BTreeMap<T1, Box<T2>> {
unsafe fn f25<T1, T2>(a0: &mut BTreeMap<T1, Box<T2>>, a1: &mut BTreeMap<T1, Box<T2>>) {
*a0 = std::mem::take(&mut *a1)
}

unsafe fn f26<T1: Clone, T2: Clone>(a0: &mut BTreeMap<T1, Box<T2>>, a1: BTreeMap<T1, Box<T2>>) {
*a0 = a1.clone()
}
15 changes: 15 additions & 0 deletions rules/pair/src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,18 @@ template <class T1, class T2> auto f10(T1 &&a0, T2 &&a1) {
template <typename T1, typename T2> T1 &f11(std::pair<T1, T2> &a0) {
return a0.first;
}

template <typename T1, typename T2>
std::pair<T1, T2> f12(std::pair<T1, T2> &&a0) {
return std::pair<T1, T2>(std::move(a0));
}

template <typename T1, typename T2>
std::pair<T1, T2> &f13(std::pair<T1, T2> &dst, const std::pair<T1, T2> &src) {
return dst.operator=(src);
}

template <typename T1, typename T2>
std::pair<T1, T2> &f14(std::pair<T1, T2> &dst, std::pair<T1, T2> &&src) {
return dst.operator=(std::move(src));
}
21 changes: 21 additions & 0 deletions rules/pair/tgt_refcount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,24 @@ fn f10<T1, T2>(a0: T1, a1: T2) -> (Value<T1>, Value<T2>) {
fn f11<T1, T2>(a0: (Value<T1>, Value<T2>)) -> Value<T1> {
a0.0
}

fn f12<T1: Default, T2: Default>(a0: &mut (Value<T1>, Value<T2>)) -> (Value<T1>, Value<T2>) {
std::mem::take(&mut *a0)
}

fn f13<T1: Clone + ByteRepr, T2: Clone + ByteRepr>(
a0: Ptr<(Value<T1>, Value<T2>)>,
a1: (Value<T1>, Value<T2>),
) {
a0.write((
Rc::new(RefCell::new(a1.0.borrow().clone())),
Rc::new(RefCell::new(a1.1.borrow().clone())),
))
}

fn f14<T1: Default + ByteRepr, T2: Default + ByteRepr>(
a0: Ptr<(Value<T1>, Value<T2>)>,
a1: &mut (Value<T1>, Value<T2>),
) {
a0.write(std::mem::take(&mut *a1))
}
12 changes: 12 additions & 0 deletions rules/pair/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ unsafe fn f10<T1, T2>(a0: T1, a1: T2) -> (T1, T2) {
unsafe fn f11<T1, T2>(a0: (T1, T2)) -> T1 {
a0.0
}

unsafe fn f12<T1: Default, T2: Default>(a0: &mut (T1, T2)) -> (T1, T2) {
std::mem::take(&mut *a0)
}

unsafe fn f13<T1: Clone, T2: Clone>(a0: &mut (T1, T2), a1: (T1, T2)) {
*a0 = a1.clone()
}

unsafe fn f14<T1: Default, T2: Default>(a0: &mut (T1, T2), a1: &mut (T1, T2)) {
*a0 = std::mem::take(&mut *a1)
}
12 changes: 12 additions & 0 deletions rules/string/src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,15 @@ void f24(std::string &o) { return o.clear(); }
void f25(std::string &o) { return o.shrink_to_fit(); }

char &f26(std::string &o, std::size_t idx) { return o.at(idx); }

std::string f27(const std::string &o) { return std::string(o); }

std::string f28(std::string &&o) { return std::string(std::move(o)); }

std::string &f29(std::string &dst, const std::string &src) {
return dst.operator=(src);
}

std::string &f30(std::string &dst, std::string &&src) {
return dst.operator=(std::move(src));
}
16 changes: 16 additions & 0 deletions rules/string/tgt_refcount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,19 @@ fn f24(a0: &mut Vec<u8>) {
fn f25(a0: &mut Vec<u8>) {
a0.shrink_to_fit()
}

fn f27(a0: Vec<u8>) -> Vec<u8> {
a0.clone()
}

fn f28(a0: &mut Vec<u8>) -> Vec<u8> {
std::mem::take(&mut *a0)
}

fn f29(a0: Ptr<Vec<u8>>, a1: Vec<u8>) {
a0.write(a1.clone())
}

fn f30(a0: Ptr<Vec<u8>>, a1: &mut Vec<u8>) {
a0.write(std::mem::take(&mut *a1))
}
16 changes: 16 additions & 0 deletions rules/string/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,19 @@ unsafe fn f26(a0: &mut Vec<libc::c_char>, a1: usize) -> *mut libc::c_char {
&mut a0[a1 as usize]
}
}

unsafe fn f27(a0: Vec<libc::c_char>) -> Vec<libc::c_char> {
a0.clone()
}

unsafe fn f28(a0: &mut Vec<libc::c_char>) -> Vec<libc::c_char> {
std::mem::take(&mut *a0)
}

unsafe fn f29(a0: &mut Vec<libc::c_char>, a1: Vec<libc::c_char>) {
*a0 = a1.clone()
}

unsafe fn f30(a0: &mut Vec<libc::c_char>, a1: &mut Vec<libc::c_char>) {
*a0 = std::mem::take(&mut *a1)
}
9 changes: 9 additions & 0 deletions rules/vector/src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,12 @@ template <typename T1, typename T2 = std::allocator<T1>>
std::vector<T1, T2> f108(std::vector<T1, T2> &&o) {
return std::vector<T1, T2>(std::move(o));
}

template <typename T1> std::vector<T1> f109(const std::vector<T1> &o) {
return std::vector<T1>(o);
}

template <typename T1, typename T2 = std::allocator<T1>>
std::vector<T1, T2> f110(const std::vector<T1, T2> &o) {
return std::vector<T1, T2>(o);
}
8 changes: 8 additions & 0 deletions rules/vector/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,11 @@ unsafe fn f107<T1>(a0: &mut Vec<T1>) -> Vec<T1> {
unsafe fn f108<T1>(a0: &mut Vec<T1>) -> Vec<T1> {
std::mem::take(&mut *a0)
}

unsafe fn f109<T1: Clone>(a0: Vec<T1>) -> Vec<T1> {
a0.clone()
}

unsafe fn f110<T1: Clone>(a0: Vec<T1>) -> Vec<T1> {
a0.clone()
}
Loading