From a31a735e355aeb0cb28377c7b25583c4bd374e2e Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Thu, 25 Aug 2016 11:33:51 -0700 Subject: [PATCH] separate pretty-printer for pp_kind Reviewed By: jvillard Differential Revision: D3762892 fbshipit-source-id: 49dcf48 --- infer/src/quandary/JavaTrace.ml | 20 +++++++++++++------- infer/src/quandary/TraceElem.ml | 1 + infer/src/unit/TaintTests.ml | 1 + infer/src/unit/TraceTests.ml | 4 +++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/infer/src/quandary/JavaTrace.ml b/infer/src/quandary/JavaTrace.ml index 708f4e57e..3c5849334 100644 --- a/infer/src/quandary/JavaTrace.ml +++ b/infer/src/quandary/JavaTrace.ml @@ -82,10 +82,13 @@ module JavaSource = struct let equal t1 t2 = compare t1 t2 = 0 - let pp fmt s = match s.kind with - | SharedPreferences -> F.fprintf fmt "SharedPreferences(%a)" CallSite.pp s.site - | Footprint ap -> F.fprintf fmt "Footprint(%a)" AccessPath.pp ap - | Other -> F.fprintf fmt "Other(%a)" CallSite.pp s.site + let pp_kind fmt (kind : kind) = match kind with + | SharedPreferences -> F.fprintf fmt "SharedPreferences" + | SourceKind.Footprint ap -> F.fprintf fmt "Footprint[%a]" AccessPath.pp ap + | SourceKind.Other -> F.fprintf fmt "Other" + + let pp fmt s = + F.fprintf fmt "%a(%a)" pp_kind s.kind CallSite.pp s.site module Set = PrettyPrintable.MakePPSet(struct type nonrec t = t @@ -154,9 +157,12 @@ module JavaSink = struct let equal t1 t2 = compare t1 t2 = 0 - let pp fmt s = match s.kind with - | Logging -> F.fprintf fmt "Logging(%a)" CallSite.pp s.site - | Other -> F.fprintf fmt "%a" CallSite.pp s.site + let pp_kind fmt (kind : kind) = match kind with + | Logging -> F.fprintf fmt "Logging" + | Other -> F.fprintf fmt "Other" + + let pp fmt s = + F.fprintf fmt "%a(%a)" pp_kind s.kind CallSite.pp s.site module Set = PrettyPrintable.MakePPSet(struct type nonrec t = t diff --git a/infer/src/quandary/TraceElem.ml b/infer/src/quandary/TraceElem.ml index 38f141b2b..1e4952cba 100644 --- a/infer/src/quandary/TraceElem.ml +++ b/infer/src/quandary/TraceElem.ml @@ -20,6 +20,7 @@ module type S = sig val compare : t -> t -> int val equal : t -> t -> bool + val pp_kind : F.formatter -> kind -> unit val pp : F.formatter -> t -> unit module Set : PrettyPrintable.PPSet with type elt = t diff --git a/infer/src/unit/TaintTests.ml b/infer/src/unit/TaintTests.ml index 3679d3a97..6e7ab29cd 100644 --- a/infer/src/unit/TaintTests.ml +++ b/infer/src/unit/TaintTests.ml @@ -21,6 +21,7 @@ module MockTrace = Trace.Make(struct let compare = CallSite.compare let equal = CallSite.equal let pp = CallSite.pp + let pp_kind _ _ = assert false let to_callee t _ = t diff --git a/infer/src/unit/TraceTests.ml b/infer/src/unit/TraceTests.ml index a39b0a85e..cabc1a04d 100644 --- a/infer/src/unit/TraceTests.ml +++ b/infer/src/unit/TraceTests.ml @@ -35,10 +35,12 @@ module MockTraceElem = struct let equal t1 t2 = compare t1 t2 = 0 - let pp fmt = function + let pp_kind fmt = function | Kind1 -> F.fprintf fmt "Kind1" | Kind2 -> F.fprintf fmt "Kind2" + let pp = pp_kind + module Set = PrettyPrintable.MakePPSet(struct type nonrec t = t let compare = compare