From 493d0028b73bf1f74bdc40d95ed91b8fa286e248 Mon Sep 17 00:00:00 2001
From: Allan Blanchard <allan.blanchard@cea.fr>
Date: Mon, 12 Sep 2022 17:07:04 +0200
Subject: [PATCH] [Extlib] removed mapi (List.mapi)

---
 bin/migration_scripts/manganese2iron.sh | 3 ++-
 src/kernel_internals/typing/cabs2cil.ml | 4 ++--
 src/libraries/stdlib/extlib.ml          | 5 -----
 src/libraries/stdlib/extlib.mli         | 5 -----
 4 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/bin/migration_scripts/manganese2iron.sh b/bin/migration_scripts/manganese2iron.sh
index 57295f6c7f7..ef3d566e127 100755
--- a/bin/migration_scripts/manganese2iron.sh
+++ b/bin/migration_scripts/manganese2iron.sh
@@ -88,7 +88,8 @@ process_file ()
    -e 's/Extlib\.id/Fun.id/g' \
    -e 's/Extlib\.swap/Fun.flip/g' \
    -e 's/Extlib\.xor/(<>)/g' \
-   -e 's/Extlib\.iteri/List.iteri/g'
+   -e 's/Extlib\.iteri/List.iteri/g' \
+   -e 's/Extlib\.iteri/List.mapi/g'
    # this line left empty on purpose
 }
 
diff --git a/src/kernel_internals/typing/cabs2cil.ml b/src/kernel_internals/typing/cabs2cil.ml
index 71228ea8e08..91658f0b820 100644
--- a/src/kernel_internals/typing/cabs2cil.ml
+++ b/src/kernel_internals/typing/cabs2cil.ml
@@ -4386,7 +4386,7 @@ let default_argument_promotion idx exp =
 (* Promote variadic arguments with standard argument promotions.*)
 let promote_variadic_arguments (chunk,args) =
   let args =
-    Extlib.mapi
+    List.mapi
       (fun i arg -> snd (default_argument_promotion i arg))
       args
   in
@@ -6934,7 +6934,7 @@ and doExp local_env
                warn_no_proto f;
                let (prm_types,args) =
                  List.split
-                   (Extlib.mapi default_argument_promotion args)
+                   (List.mapi default_argument_promotion args)
                in
                let typ = TFun (resType, Some prm_types, false,attrs) in
                Cil.update_var_type f typ;
diff --git a/src/libraries/stdlib/extlib.ml b/src/libraries/stdlib/extlib.ml
index 14d3703b43b..bd86414e623 100644
--- a/src/libraries/stdlib/extlib.ml
+++ b/src/libraries/stdlib/extlib.ml
@@ -165,11 +165,6 @@ let opt_of_list =
   | [a] -> Some a
   | _ -> raise (Invalid_argument "Extlib.opt_of_list")
 
-let mapi f l =
-  let res =
-    snd (List.fold_left (fun (i,acc) x -> (i+1,f i x :: acc)) (0,[]) l)
-  in List.rev res
-
 let subsets k l =
   let rec aux k l len =
     if k = 0 then [[]]
diff --git a/src/libraries/stdlib/extlib.mli b/src/libraries/stdlib/extlib.mli
index 5ae88674815..07b84919de5 100644
--- a/src/libraries/stdlib/extlib.mli
+++ b/src/libraries/stdlib/extlib.mli
@@ -139,11 +139,6 @@ val opt_of_list: 'a list -> 'a option
     @raise Invalid_argument on lists with more than one argument
     @since Oxygen-20120901 *)
 
-val mapi: (int -> 'a -> 'b) -> 'a list -> 'b list
-(** Same as map, but the function to be applied take also as argument the
-    index of the element (starting from 0). Tail-recursive
-    @since Oxygen-20120901 *)
-
 val subsets: int -> 'a list -> 'a list list
 (** [subsets k l] computes the combinations of [k] elements from list [l].
     E.g. subsets 2 [1;2;3;4] = [[1;2];[1;3];[1;4];[2;3];[2;4];[3;4]].
-- 
GitLab