Skip to content

Commit 3944ab4

Browse files
Merge pull request #135 from just-max/rename_rmtmps
Rename `Rmtmps` module to `RmUnused`
2 parents eb64242 + c2e97b9 commit 3944ab4

File tree

13 files changed

+35
-38
lines changed

13 files changed

+35
-38
lines changed

doc/cil.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ \subsection{Using CIL as a library}
630630
The \t{Mergecil.merge: Cil.file list -> string -> Cil.file} function merges
631631
multiple files. You can then invoke your analysis function on the resulting
632632
\t{Cil.file} data structure. You might want to call
633-
\t{Rmtmps.removeUnusedTemps} first to clean up the prototypes and variables
633+
\t{RmUnused.removeUnused} first to clean up the prototypes and variables
634634
that are not used. Then you can call the function \t{Cil.dumpFile:
635635
cilPrinter -> out\_channel -> Cil.file -> unit} to print the file to a
636636
given output channel. A good \t{cilPrinter} to use is

src/cil.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ and varinfo = {
518518

519519
mutable vreferenced: bool;
520520
(** True if this variable is ever referenced. This is computed by
521-
{!Rmtmps.removeUnusedTemps}. It is safe to just initialize this to False *)
521+
{!RmUnused.removeUnused}. It is safe to just initialize this to False *)
522522

523523
mutable vdescr: Pretty.doc;
524524
(** For most temporary variables, a description of what the var holds.

src/ciloptions.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,24 +330,24 @@ let options : (string * Arg.spec * string) list =
330330
is_default (not !Cil.useCaseRange));
331331

332332
"--keepunused",
333-
Arg.Set Rmtmps.keepUnused,
333+
Arg.Set RmUnused.keepUnused,
334334
(" Do not remove the unused variables and types" ^
335-
is_default !Rmtmps.keepUnused);
335+
is_default !RmUnused.keepUnused);
336336

337337
"--nokeepunused",
338-
Arg.Clear Rmtmps.keepUnused,
338+
Arg.Clear RmUnused.keepUnused,
339339
(" Remove unused variables and types" ^
340-
is_default (not !Rmtmps.keepUnused));
340+
is_default (not !RmUnused.keepUnused));
341341

342342
"--rmUnusedInlines",
343-
Arg.Set Rmtmps.rmUnusedInlines,
343+
Arg.Set RmUnused.rmUnusedInlines,
344344
(" Delete any unused inline functions" ^
345-
is_default !Rmtmps.rmUnusedInlines);
345+
is_default !RmUnused.rmUnusedInlines);
346346

347347
"--noRmUnusedInlines",
348-
Arg.Clear Rmtmps.rmUnusedInlines,
348+
Arg.Clear RmUnused.rmUnusedInlines,
349349
(" Do not delete any unused inline functions" ^
350-
is_default (not !Rmtmps.rmUnusedInlines));
350+
is_default (not !RmUnused.rmUnusedInlines));
351351

352352
(* Output Options *)
353353
"", Arg.Unit (fun () -> ()), " \n\t\tOutput Options\n";

src/cilutil.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let strictChecking= ref false (* If doCheck is true and warnings are found,
4242

4343
let printStats = ref false
4444

45-
(* when 'sliceGlobal' is set, then when 'rmtmps' runs, only globals*)
45+
(* when 'sliceGlobal' is set, then when 'rmUnused' runs, only globals*)
4646
(* marked with #pragma cilnoremove(whatever) are kept; when used with *)
4747
(* cilly.asm.exe, the effect is to slice the input on the noremove symbols *)
4848
let sliceGlobal = ref false

src/frontc/cparser.mly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,13 +958,13 @@ statement_no_null:
958958
{(* The only attribute that should appear here
959959
is "unused". For now, we drop this on the
960960
floor, since unused labels are usually
961-
removed anyways by Rmtmps. *)
961+
removed anyways by RmUnused. *)
962962
LABEL (fst $1, $5, joinLoc (snd $1) $4)}
963963
| IDENT COLON attribute_nocv_list location SEMICOLON
964964
{(* The only attribute that should appear here
965965
is "unused". For now, we drop this on the
966966
floor, since unused labels are usually
967-
removed anyways by Rmtmps. *)
967+
removed anyways by RmUnused. *)
968968
LABEL (fst $1, NOP ($5), joinLoc (snd $1) $4)}
969969
| CASE expression COLON statement location
970970
{CASE (fst $2, $4, joinLoc $1 $5, joinLoc $1 $3)}

src/goblintCil.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Formatcil = Formatcil
1919
module Machdep = Machdep
2020
module Machdepenv = Machdepenv
2121
module Mergecil = Mergecil
22-
module Rmtmps = Rmtmps
22+
module RmUnused = RmUnused
2323

2424
(** {1 FrontC modules} *)
2525

src/main.ml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,8 @@ let parseOneFile (fname: string) : C.file =
5959
if !Cilutil.printStages then ignore (E.log "Parsing %s\n" fname);
6060
let cil = F.parse fname () in
6161

62-
if (not (Feature.enabled "epicenter")) then (
63-
(* sm: remove unused temps to cut down on gcc warnings *)
64-
(* (Stats.time "usedVar" Rmtmps.removeUnusedTemps cil); *)
65-
(* (trace "sm" (dprintf "removing unused temporaries\n")); *)
66-
(Rmtmps.removeUnusedTemps cil)
67-
);
62+
(* remove unused temps and globals to cut down on gcc warnings *)
63+
RmUnused.removeUnused cil;
6864
cil
6965

7066
let processOneFile (cil: C.file) =

src/rmtmps.ml renamed to src/rmUnused.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
3737
*)
3838

39-
(* rmtmps.ml *)
40-
(* implementation for rmtmps.mli *)
39+
(* rmUnused.ml *)
40+
(* implementation for rmUnused.mli *)
41+
(* previously named Rmtmps, renamed to RmUnused to clarify that not only temporaries are removed *)
4142

4243
open Pretty
4344
open Cil
@@ -50,7 +51,7 @@ let keepUnused = ref false
5051
let rmUnusedInlines = ref false
5152

5253

53-
let trace = Trace.trace "rmtmps"
54+
let trace = Trace.trace "rmunused"
5455

5556

5657

@@ -637,7 +638,7 @@ class markUsedLabels (labelMap: (string, unit) H.t) = object
637638
Goto (dest, _) ->
638639
let (ln, _, _), _ = labelsToKeep !dest.labels in
639640
if ln = "" then
640-
E.s (E.bug "rmtmps: destination of statement does not have labels");
641+
E.s (E.bug "rmUnused: destination of statement does not have labels");
641642
(* Mark it as used *)
642643
H.replace labelMap ln ();
643644
DoChildren
@@ -648,7 +649,7 @@ class markUsedLabels (labelMap: (string, unit) H.t) = object
648649
| AddrOfLabel dest ->
649650
let (ln, _, _), _ = labelsToKeep !dest.labels in
650651
if ln = "" then
651-
E.s (E.bug "rmtmps: destination of address of label does not have labels");
652+
E.s (E.bug "rmUnused: destination of address of label does not have labels");
652653
(* Mark it as used *)
653654
H.replace labelMap ln ();
654655
SkipChildren
@@ -778,7 +779,7 @@ type rootsFilter = global -> bool
778779

779780
let isDefaultRoot = isExportedRoot
780781

781-
let removeUnusedTemps ?(isRoot : rootsFilter = isDefaultRoot) file =
782+
let removeUnused ?(isRoot : rootsFilter = isDefaultRoot) file =
782783
if !keepUnused || Trace.traceActive "disableTmpRemoval" then
783784
Trace.trace "disableTmpRemoval" (dprintf "temp removal disabled\n")
784785
else

src/rmtmps.mli renamed to src/rmUnused.mli

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
3737
*)
3838

39-
(* rmtmps.mli *)
39+
(* rmUnused.mli *)
4040
(* remove unused things from cil files: *)
4141
(* - local temporaries introduced but not used *)
4242
(* - global declarations that are not used *)
@@ -46,18 +46,18 @@
4646

4747
(* Some clients may wish to augment or replace the standard strategy
4848
for finding the initially reachable roots. The optional
49-
"isRoot" argument to Rmtmps.removeUnusedTemps grants this
49+
"isRoot" argument to RmUnused.removeUnused grants this
5050
flexibility. If given, it should name a function which will return
5151
true if a given global should be treated as a retained root.
5252
53-
Function Rmtmps.isDefaultRoot encapsulates the default root
53+
Function RmUnused.isDefaultRoot encapsulates the default root
5454
collection, which consists of those global variables and functions
5555
which are visible to the linker and runtime loader. A client's
5656
root filter can use this if the goal is to augment rather than
57-
replace the standard logic. Function Rmtmps.isExportedRoot is an
57+
replace the standard logic. Function RmUnused.isExportedRoot is an
5858
alternate name for this same function.
5959
60-
Function Rmtmps.isCompleteProgramRoot is an example of an alternate
60+
Function RmUnused.isCompleteProgramRoot is an example of an alternate
6161
root collection. This function assumes that it is operating on a
6262
complete program rather than just one object file. It treats
6363
"main()" as a root, as well as any function carrying the
@@ -75,8 +75,8 @@ val isExportedRoot : rootsFilter
7575
val isCompleteProgramRoot : rootsFilter
7676

7777
(* process a complete Cil file *)
78-
val removeUnusedTemps: ?isRoot:rootsFilter -> Cil.file -> unit
78+
val removeUnused : ?isRoot:rootsFilter -> Cil.file -> unit
7979

8080

81-
val keepUnused: bool ref (* Set this to true to turn off this module *)
82-
val rmUnusedInlines: bool ref (* Delete unused inline funcs in gcc mode? *)
81+
val keepUnused : bool ref (* Set this to true to turn off this module *)
82+
val rmUnusedInlines : bool ref (* Delete unused inline funcs in gcc mode? *)
File renamed without changes.

0 commit comments

Comments
 (0)