From 195afbff50fb8be7609d4fbf1467ab0d41343087 Mon Sep 17 00:00:00 2001
From: Valentin Perrelle <valentin.perrelle@cea.fr>
Date: Mon, 11 Mar 2019 14:47:29 +0100
Subject: [PATCH] [Dive] Fix temporary variables locations

---
 src/plugins/dive/build.ml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/plugins/dive/build.ml b/src/plugins/dive/build.ml
index 6885736b289..f8a9eee5dd8 100644
--- a/src/plugins/dive/build.ml
+++ b/src/plugins/dive/build.ml
@@ -128,8 +128,11 @@ let stmt_to_node_locality stmt =
 let build_node_locality kinstr kind =
   match Node_kind.get_base kind with
   | Some vi ->
-    let loc_function = Kernel_function.find_defining_kf vi
-    and loc_file = get_loc_filename vi.vdecl in
+    let loc_function = Kernel_function.find_defining_kf vi in
+    (* Use the location of the defining function if it exists, as some
+       temporary variables do not have proper location *)
+    let def_vi = Extlib.may_map Kernel_function.get_vi ~dft:vi loc_function in
+    let loc_file = get_loc_filename def_vi.vdecl in
     { loc_file ; loc_function }
   | None ->
     match kinstr with
-- 
GitLab