aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Unblock.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-09-22 19:44:47 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-09-22 19:44:47 +0200
commitd7f75509c290d871cb8cd8aa11a0be2923c9ef17 (patch)
tree5e1cfd9366ae875a5da7286d1912b7fab7454ce0 /cparser/Unblock.ml
parent4b9b0e8f988cdfa1f848919b41bfe24c6e9a052a (diff)
downloadcompcert-kvx-d7f75509c290d871cb8cd8aa11a0be2923c9ef17.tar.gz
compcert-kvx-d7f75509c290d871cb8cd8aa11a0be2923c9ef17.zip
Record the scope structure during unblocking.
Instead of creating separate annotations for the local variables we call the Debug.add_lvar_scope and we construct a mapping from function id + scope id to scope information.
Diffstat (limited to 'cparser/Unblock.ml')
-rw-r--r--cparser/Unblock.ml20
1 files changed, 11 insertions, 9 deletions
diff --git a/cparser/Unblock.ml b/cparser/Unblock.ml
index b5f945d4..4f5056bb 100644
--- a/cparser/Unblock.ml
+++ b/cparser/Unblock.ml
@@ -217,8 +217,11 @@ let add_lineno ctx prev_loc this_loc s =
(* Variable declaration annotation:
__builtin_debug(6, var, scope) *)
+let curr_fun_id = ref 0
+
let debug_var_decl ctx id ty =
let scope = match ctx with [] -> 0 | sc :: _ -> sc in
+ Debug.add_lvar_scope !curr_fun_id id scope;
debug_annot 6L
[ {edesc = EVar id; etyp = ty}; integer_const scope ]
@@ -227,13 +230,6 @@ let add_var_decl ctx id ty s =
then sseq no_loc (debug_var_decl ctx id ty) s
else s
-let add_param_decls params body =
- if !Clflags.option_g then
- List.fold_right
- (fun (id, ty) s -> sseq no_loc (debug_var_decl [] id ty) s)
- params body
- else body
-
(* Generate fresh scope identifiers, for blocks that contain at least
one declaration *)
@@ -313,7 +309,10 @@ let rec unblock_stmt env ctx ploc s =
| Sblock sl ->
let ctx' =
if block_contains_decl sl
- then new_scope_id () :: ctx
+ then
+ let id = new_scope_id () in
+ Debug.enter_scope !curr_fun_id (List.hd ctx) id;
+ id:: ctx
else ctx in
unblock_block env ctx' ploc sl
| Sdecl d ->
@@ -342,8 +341,11 @@ and unblock_block env ctx ploc = function
let unblock_fundef env f =
local_variables := [];
next_scope_id := 0;
+ curr_fun_id := f.fd_name.stamp;
+ let id = new_scope_id () in
+ Debug.enter_function_scope f.fd_name id;
let body =
- add_param_decls f.fd_params (unblock_stmt env [] no_loc f.fd_body) in
+ (unblock_stmt env [id] no_loc f.fd_body) in
let decls = !local_variables in
local_variables := [];
{ f with fd_locals = f.fd_locals @ decls; fd_body = body }