Skip to content

Commit

Permalink
[html] ensure proper enabling/disabling
Browse files Browse the repository at this point in the history
Summary: As per title. The clang frontend had an accidentally correct, but buggy, use of disabling html printing.

Reviewed By: davidpichardie

Differential Revision:
D68085267

Privacy Context Container: L1208441

fbshipit-source-id: cc0d714df126aced888070be0c87085939d80699
  • Loading branch information
ngorogiannis authored and facebook-github-bot committed Jan 13, 2025
1 parent 9dfabdb commit 749a49b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
6 changes: 6 additions & 0 deletions infer/src/backend/NodePrinter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ let with_session ?kind ~pp_name node ~f =
let enable_html_printing () = DLS.set print_html true

let disable_html_printing () = DLS.set print_html false

let with_html_printing_disabled_if ~f cond =
if cond then disable_html_printing () ;
let result = f () in
if cond then enable_html_printing () ;
result
4 changes: 1 addition & 3 deletions infer/src/backend/NodePrinter.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ val with_session :
-> 'a
(** Wraps [f] in an html debug session *)

val enable_html_printing : unit -> unit

val disable_html_printing : unit -> unit
val with_html_printing_disabled_if : f:(unit -> 'a) -> bool -> 'a
30 changes: 14 additions & 16 deletions infer/src/backend/preanal.ml
Original file line number Diff line number Diff line change
Expand Up @@ -556,19 +556,17 @@ module RemoveDeadNodes = struct
end

let do_preanalysis tenv pdesc =
if not Config.preanalysis_html then NodePrinter.disable_html_printing () ;
let proc_name = Procdesc.get_proc_name pdesc in
if Procname.is_java proc_name || Procname.is_csharp proc_name then
InlineJavaSyntheticMethods.process pdesc ;
(* NOTE: It is important that this preanalysis stays before Liveness *)
if not (Procname.is_java proc_name || Procname.is_csharp proc_name) then
(* Apply dynamic selection of copy and overriden methods *)
ReplaceObjCMethodCall.process tenv pdesc proc_name ;
if Procname.is_hack_constinit proc_name then InjectTraitInterfaceConstinit.process tenv pdesc ;
Liveness.process pdesc ;
AddAbstractionInstructions.process pdesc ;
if Procname.is_java proc_name then Devirtualizer.process pdesc tenv ;
NoReturn.process tenv pdesc ;
RemoveDeadNodes.process pdesc ;
NodePrinter.enable_html_printing () ;
()
NodePrinter.with_html_printing_disabled_if (not Config.preanalysis_html) ~f:(fun () ->
let proc_name = Procdesc.get_proc_name pdesc in
if Procname.is_java proc_name || Procname.is_csharp proc_name then
InlineJavaSyntheticMethods.process pdesc ;
(* NOTE: It is important that this preanalysis stays before Liveness *)
if not (Procname.is_java proc_name || Procname.is_csharp proc_name) then
(* Apply dynamic selection of copy and overriden methods *)
ReplaceObjCMethodCall.process tenv pdesc proc_name ;
if Procname.is_hack_constinit proc_name then InjectTraitInterfaceConstinit.process tenv pdesc ;
Liveness.process pdesc ;
AddAbstractionInstructions.process pdesc ;
if Procname.is_java proc_name then Devirtualizer.process pdesc tenv ;
NoReturn.process tenv pdesc ;
RemoveDeadNodes.process pdesc )
14 changes: 7 additions & 7 deletions infer/src/clang/cFrontend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ let do_objc_preanalyses cfg tenv =
CAddImplicitGettersSetters.process cfg tenv ;
CReplaceDynamicDispatch.process cfg ;
CViewControllerLifecycle.process cfg tenv ;
if Config.compute_captured_context then (
if not Config.preanalysis_html then NodePrinter.disable_html_printing () ;
Timer.time Preanalysis
~f:(fun () -> ComputeCapturedInfo.process cfg)
~on_timeout:(fun span ->
L.debug Capture Quiet "TIMEOUT in ComputeCapturedInfo.process after %fs of CPU time@\n" span )
)
if Config.compute_captured_context then
NodePrinter.with_html_printing_disabled_if (not Config.preanalysis_html) ~f:(fun () ->
Timer.time Preanalysis
~f:(fun () -> ComputeCapturedInfo.process cfg)
~on_timeout:(fun span ->
L.debug Capture Quiet "TIMEOUT in ComputeCapturedInfo.process after %fs of CPU time@\n"
span ) )


let do_cpp_preanalyses cfg = CppLambdaCalls.process cfg
Expand Down

0 comments on commit 749a49b

Please sign in to comment.