From 65123bc74501294fb348974f35a9898369b00277 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 16 Oct 2026 13:30:43 +0100 Subject: [PATCH 01/33] Delete iterator rules --- rules/algorithm/src.cpp | 15 ------ rules/algorithm/tgt_refcount.rs | 32 ------------- rules/algorithm/tgt_unsafe.rs | 28 ----------- rules/common/traits.h | 58 ----------------------- rules/map/src.cpp | 69 --------------------------- rules/map/tgt_refcount.rs | 66 -------------------------- rules/map/tgt_unsafe.rs | 52 --------------------- rules/vector/src.cpp | 82 --------------------------------- rules/vector/tgt_refcount.rs | 57 ----------------------- rules/vector/tgt_unsafe.rs | 52 --------------------- 10 files changed, 511 deletions(-) delete mode 100644 rules/common/traits.h diff --git a/rules/algorithm/src.cpp b/rules/algorithm/src.cpp index 40b020c3f..1d80ba2bc 100644 --- a/rules/algorithm/src.cpp +++ b/rules/algorithm/src.cpp @@ -9,7 +9,6 @@ #include #include -#include "../common/traits.h" template void f1(T1 first, T1 last) { return std::sort(first, last); @@ -33,20 +32,6 @@ template T1 *f8(T1 *first, T1 *last) { template void f9(T1 &a0, T1 &a1) { return std::swap(a0, a1); } -template , - typename T2 = AllocatorOf>, - typename = SameAs::iterator>> -typename std::vector::iterator f10(It a0, It a1) { - return std::unique(a0, a1); -} - -template , - typename T3 = AllocatorOf>, - typename = SameAs::iterator>> -void f12(It a0, It a1, const T2 &a2) { - return std::fill(a0, a1, a2); -} - std::ostream_iterator f13(std::string::iterator a0, std::string::iterator a1, std::ostream_iterator a2) { diff --git a/rules/algorithm/tgt_refcount.rs b/rules/algorithm/tgt_refcount.rs index 52a96393e..2b4e2ac7a 100644 --- a/rules/algorithm/tgt_refcount.rs +++ b/rules/algorithm/tgt_refcount.rs @@ -63,38 +63,6 @@ fn f9(a0: Ptr, a1: Ptr) { a1.write(tmp); } -fn f10(a0: Ptr, a1: Ptr) -> Ptr { - let count = a1.get_offset() - a0.get_offset(); - if count <= 1 { - a1 - } else { - let mut iter = PtrValueIter::new(&a0, count); - let mut write_ptr = a0; - let mut last_unique = iter.next().unwrap(); - - // the first unique value is already in place - write_ptr += 1; - - for current_val in iter { - if current_val != last_unique { - write_ptr.write(current_val.clone()); - last_unique = current_val; - write_ptr += 1; - } - } - write_ptr - } -} - -fn f12(a0: Ptr, a1: Ptr, a2: T1) { - let mut __a0 = a0; - while __a0 != a1 { - let v = a2.clone(); - __a0.write(v); - __a0 += 1; - } -} - fn f13(a0: Ptr, a1: Ptr, a2: &mut ::std::fs::File) -> ::std::fs::File { a0.with_slice(a1.get_offset() - a0.get_offset(), |__s| { CChar::with_u8_slice(__s, |__b| a2.write_all(__b)) diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 6257589a5..ef8cf4c2f 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -62,34 +62,6 @@ unsafe fn f9(a0: &mut T1, a1: &mut T1) { std::mem::swap(&mut *a0, &mut *a1) } -unsafe fn f10(a0: *mut T1, a1: *mut T1) -> *mut T1 { - if a0 == a1 { - a0 - } else { - let mut write = a0; - let mut prev = a0; - let mut it = a0; - it = it.add(1); - - while it != a1 { - if *prev != *it { - write = write.add(1); - *write = (*it).clone(); - prev = write; - } - it = it.add(1); - } - - write = write.add(1); - write - } -} - -unsafe fn f12(a0: *mut T1, a1: *mut T1, a2: T1) { - let count = a1.offset_from(a0) as usize; - std::slice::from_raw_parts_mut(a0, count).fill(a2) -} - unsafe fn f13( a0: *const libc::c_char, a1: *const libc::c_char, diff --git a/rules/common/traits.h b/rules/common/traits.h deleted file mode 100644 index 6e50a69e8..000000000 --- a/rules/common/traits.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2022-present INESC-ID. -// Distributed under the MIT license that can be found in the LICENSE file. - -template struct EnableIf {}; - -template struct EnableIf { - using type = T; -}; - -template struct IsSame { - static constexpr bool value = false; -}; - -template struct IsSame { - static constexpr bool value = true; -}; - -template struct RemoveConst { - using type = T; -}; - -template struct RemoveConst { - using type = T; -}; - -template struct FindAlloc { - using type = D; -}; - -template class C, - typename A, typename... Args> -struct FindAlloc, Args...> { - using type = A; -}; - -template -struct FindAlloc : FindAlloc {}; - -template struct AllocOf { - using type = D; -}; - -template