From 47ba53f548de483a5659428d6af8c86063c86ba9 Mon Sep 17 00:00:00 2001 From: Valentin Perrelle <valentin.perrelle@cea.fr> Date: Wed, 12 Oct 2022 13:56:45 +0200 Subject: [PATCH] [Dive] Reduce argument list to formals length instead of catching List.iter2 exception --- src/plugins/dive/build.ml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/plugins/dive/build.ml b/src/plugins/dive/build.ml index 9c984adfd1c..078d015efca 100644 --- a/src/plugins/dive/build.ml +++ b/src/plugins/dive/build.ml @@ -513,11 +513,10 @@ let build_node_reads context node = and build_args_deps callstack zone stmt args callee_kf = let callstack = Callstack.push (callee_kf,stmt) callstack in let formals = Kernel_function.get_formals callee_kf in - try - List.iter2 (build_arg_dep callstack stmt zone) args formals - (* Invalid_argument happens for Frama_C_show_each which does not have - any formal but can have any arguments. *) - with Invalid_argument _ -> () + (* For Frama_C_show_each and functions called through pointers, there may + be more arguments than formal parameters declared. *) + let used_args = Extlib.list_first_n (List.length formals) args in + List.iter2 (build_arg_dep callstack stmt zone) used_args formals and build_arg_dep callstack stmt zone arg formal = if exp_contains_read zone stmt arg then -- GitLab