Skip to content

Commit

Permalink
Refactor: generalize repetitive function definition
Browse files Browse the repository at this point in the history
  • Loading branch information
karoliineh committed Oct 31, 2024
1 parent 506fb21 commit 2508f1a
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/autoTune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,16 @@ let focusOnTermination (spec: Svcomp.Specification.t) =
let focusOnTermination () =
List.iter focusOnTermination (Svcomp.Specification.of_option ())

let focusOnReachSafety (spec: Svcomp.Specification.t) = ()
let reachSafety (spec: Svcomp.Specification.t) = ()

let focusOnReachSafety () =
List.iter focusOnReachSafety (Svcomp.Specification.of_option ())

let focusOnConcurrencySafety (spec: Svcomp.Specification.t) =
let concurrencySafety (spec: Svcomp.Specification.t) =
match spec with
| NoDataRace -> (*enable all thread analyses*)
Logs.info "Specification: NoDataRace -> enabling thread analyses \"%s\"" (String.concat ", " notNeccessaryThreadAnalyses);
enableAnalyses notNeccessaryThreadAnalyses;
| _ -> ()

let focusOnConcurrencySafety () =
List.iter focusOnConcurrencySafety (Svcomp.Specification.of_option ())

let focusOnNoOverflows (spec: Svcomp.Specification.t) =
let noOverflows (spec: Svcomp.Specification.t) =
match spec with
| NoOverflow ->
(*We focus on integer analysis*)
Expand All @@ -276,8 +270,8 @@ let focusOnNoOverflows (spec: Svcomp.Specification.t) =
end
| _ -> ()

let focusOnNoOverflows () =
List.iter focusOnNoOverflows (Svcomp.Specification.of_option ())
let focusOn (f : SvcompSpec.t -> unit) =
List.iter f (Svcomp.Specification.of_option ())

(*Detect enumerations and enable the "ana.int.enums" option*)
exception EnumFound
Expand Down Expand Up @@ -544,14 +538,11 @@ let chooseConfig file =
if isActivated "mallocWrappers" then
findMallocWrappers ();

if isActivated "reachSafetySpecification" then
focusOnReachSafety ();
if isActivated "reachSafetySpecification" then focusOn reachSafety;

if isActivated "concurrencySafetySpecification" then
focusOnConcurrencySafety ();
if isActivated "concurrencySafetySpecification" then focusOn concurrencySafety;

if isActivated "noOverflows" then
focusOnNoOverflows ();
if isActivated "noOverflows" then focusOn noOverflows;

if isActivated "enums" && hasEnums file then
set_bool "ana.int.enums" true;
Expand Down

0 comments on commit 2508f1a

Please sign in to comment.