From 4ef487928ccd17752cdc7343e35d1584f3712e43 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Wed, 31 May 2017 17:19:36 -0700 Subject: [PATCH] [quandary] make passthroughs optional Reviewed By: mbouaziz Differential Revision: D5155878 fbshipit-source-id: dedbebe --- infer/src/base/Config.ml | 6 ++++++ infer/src/base/Config.mli | 1 + infer/src/checkers/Trace.ml | 12 ++++++++---- infer/src/unit/TraceTests.ml | 9 ++------- infer/tests/codetoanalyze/cpp/quandary/Makefile | 2 +- infer/tests/codetoanalyze/java/quandary/Makefile | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 9a4081eb2..246c222d5 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1176,6 +1176,11 @@ and only_footprint = CLOpt.mk_bool ~deprecated:["only_footprint"] ~long:"only-footprint" "Skip the re-execution phase" +and passthroughs = + CLOpt.mk_bool ~long:"passthroughs" ~default:false + "In error traces, show intermediate steps that propagate data. When false, error traces are \ + shorter and show only direct flow via souces/sinks" + and patterns_modeled_expensive = let long = "modeled-expensive" in (long, @@ -1834,6 +1839,7 @@ and suggest_nullable = !suggest_nullable and no_translate_libs = not !headers and objc_memory_model_on = !objc_memory_model and only_footprint = !only_footprint +and passthroughs = !passthroughs and patterns_never_returning_null = match patterns_never_returning_null with (k,r) -> (k,!r) and patterns_skip_translation = match patterns_skip_translation with (k,r) -> (k,!r) and patterns_modeled_expensive = match patterns_modeled_expensive with (k,r) -> (k,!r) diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 1052578b6..775932f6e 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -121,6 +121,7 @@ val multicore_dir_name : string val ncpu : int val nsnotification_center_checker_backend : bool val os_type : os_type +val passthroughs : bool val patterns_modeled_expensive : string * Yojson.Basic.json val patterns_never_returning_null : string * Yojson.Basic.json val patterns_skip_translation : string * Yojson.Basic.json diff --git a/infer/src/checkers/Trace.ml b/infer/src/checkers/Trace.ml index b4eebedf7..15509a124 100644 --- a/infer/src/checkers/Trace.ml +++ b/infer/src/checkers/Trace.ml @@ -373,12 +373,16 @@ module Make (Spec : Spec) = struct |> Sinks.union caller_trace.sinks in let passthroughs = - if phys_equal sources caller_trace.sources && phys_equal sinks caller_trace.sinks + if Config.passthroughs then - (* this callee didn't add any new sources or any news sinks; it's just a passthrough *) - Passthroughs.add (Passthrough.make callee_site) caller_trace.passthroughs + if phys_equal sources caller_trace.sources && phys_equal sinks caller_trace.sinks + then + (* this callee didn't add any new sources or any news sinks; it's just a passthrough *) + Passthroughs.add (Passthrough.make callee_site) caller_trace.passthroughs + else + caller_trace.passthroughs else - caller_trace.passthroughs in + Passthroughs.empty in { sources; sinks; passthroughs; } diff --git a/infer/src/unit/TraceTests.ml b/infer/src/unit/TraceTests.ml index 8d977a487..a62c138a2 100644 --- a/infer/src/unit/TraceTests.ml +++ b/infer/src/unit/TraceTests.ml @@ -130,13 +130,8 @@ let tests = |> MockTrace.add_sink sink1 in assert_bool "Appended trace should contain source and sink" - (MockTrace.equal (MockTrace.append source_trace footprint_trace call_site) expected_trace); - - let appended_trace = MockTrace.append source_trace source_trace call_site in - assert_bool - "Appending a trace that doesn't add a new source/sink should add a passthrough" - (MockTrace.Passthroughs.mem - (Passthrough.make call_site) (MockTrace.passthroughs appended_trace)) in + (MockTrace.equal + (MockTrace.append source_trace footprint_trace call_site) expected_trace) in "append">::append_ in "trace_domain_suite">:::[get_reports; append] diff --git a/infer/tests/codetoanalyze/cpp/quandary/Makefile b/infer/tests/codetoanalyze/cpp/quandary/Makefile index 1e6af2e39..ff6f6776e 100644 --- a/infer/tests/codetoanalyze/cpp/quandary/Makefile +++ b/infer/tests/codetoanalyze/cpp/quandary/Makefile @@ -10,7 +10,7 @@ TESTS_DIR = ../../.. ANALYZER = checkers # see explanations in cpp/errors/Makefile for the custom isystem CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c -INFER_OPTIONS = --quandary --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed +INFER_OPTIONS = --quandary --passthroughs --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.cpp) diff --git a/infer/tests/codetoanalyze/java/quandary/Makefile b/infer/tests/codetoanalyze/java/quandary/Makefile index d0db989cc..27c39b864 100644 --- a/infer/tests/codetoanalyze/java/quandary/Makefile +++ b/infer/tests/codetoanalyze/java/quandary/Makefile @@ -8,7 +8,7 @@ TESTS_DIR = ../../.. ANALYZER = checkers -INFER_OPTIONS = --quandary --no-filtering --debug-exceptions +INFER_OPTIONS = --quandary --passthroughs --no-filtering --debug-exceptions INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.java)