File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,12 @@ let nocil: int ref = ref (-1)
7575 *)
7676let alwaysGenerateVarDecl = false
7777
78+ (* * Add an attribute to all variables which are not declared at the top scope,
79+ so tools building on CIL can know which variables were pulled up.
80+ Should be disabled when printing CIL code, as compilers will warn about this attribute.
81+ *)
82+ let addNestedScopeAttr = ref false
83+
7884(* * Indicates whether we're allowed to duplicate small chunks. *)
7985let allowDuplication: bool ref = ref true
8086
@@ -557,9 +563,19 @@ let alphaConvertVarAndAddToEnv (addtoenv: bool) (vi: varinfo) : varinfo =
557563 in
558564 (* Store all locals in the slocals (in reversed order). We'll reverse them
559565 and take out the formals at the end of the function *)
560- if not vi.vglob then
561- ! currentFunctionFDEC.slocals < - newvi :: ! currentFunctionFDEC.slocals;
562-
566+ if not vi.vglob then (
567+ (if ! addNestedScopeAttr then
568+ (* two scopes implies top-level scope in the function, one is created for the FUNDEF (includes formals etc),
569+ one for the body which is a block *)
570+ match ! scopes with
571+ | _ ::_ ::_ ::_ ->
572+ (* i.e. List.length scopes > 2 *)
573+ newvi.vattr < - Attr (" goblint_cil_nested" , [] ) :: newvi.vattr
574+ | _ -> ()
575+ );
576+ ! currentFunctionFDEC.slocals < - newvi :: ! currentFunctionFDEC.slocals
577+ )
578+ ;
563579 (if addtoenv then
564580 if vi.vglob then
565581 addGlobalToEnv vi.vname (EnvVar newvi)
Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ val forceRLArgEval: bool ref
4545 -1 to disable *)
4646val nocil : int ref
4747
48+ (* * Add an attribute to all variables which are not declared at the top scope,
49+ so tools building on CIL can know which variables were pulled up.
50+ Should be disabled when printing CIL code, as compilers will warn about this attribute.
51+ *)
52+ val addNestedScopeAttr : bool ref
53+
4854(* * Indicates whether we're allowed to duplicate small chunks of code. *)
4955val allowDuplication : bool ref
5056
You can’t perform that action at this time.
0 commit comments