[buck flavors] make `infer run ...` use #infer-capture-all

Summary:
Do not use the deprecated (and slower) `#infer` flavor. Instead, `infer-run`
runs capture with the `#infer-capture-all` flavor, followed by merging targets,
followed by the analysis.

Move the call to `MergeCapture` around to make this change easier.

Reviewed By: mbouaziz

Differential Revision: D5547199

fbshipit-source-id: 53c9996
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent c473f21f81
commit 766a73d80c

@ -38,7 +38,7 @@ DIRECT_TESTS += \
cpp_bufferoverrun cpp_errors cpp_frontend cpp_liveness cpp_quandary cpp_siof cpp_threadsafety \
ifneq ($(BUCK),no)
BUILD_SYSTEMS_TESTS += buck-clang-db buck_flavors buck_flavors_deterministic
BUILD_SYSTEMS_TESTS += buck-clang-db buck_flavors buck_flavors_run buck_flavors_deterministic
endif
ifneq ($(CMAKE),no)
BUILD_SYSTEMS_TESTS += clang_compilation_db cmake inferconfig

@ -124,7 +124,6 @@ let main ~changed_files ~makefile =
-> process_cluster_cmdline fname
| None
-> if Config.allow_specs_cleanup then DB.Results_dir.clean_specs_dir () ;
if Config.merge then MergeCapture.merge_captured_targets () ;
let all_clusters = DB.find_source_dirs () in
let clusters_to_analyze =
List.filter ~f:(cluster_should_be_analyzed ~changed_files) all_clusters

@ -12,8 +12,7 @@ open! IStd
(** Main module for the analysis after the capture phase *)
(** Given a name of the Makefile to use for multicore analysis, analyze the captured code *)
val main : changed_files:SourceFile.Set.t option -> makefile:string -> unit
(** Given a name of the Makefile to use for multicore analysis, analyze the captured code *)
val register_perf_stats_report : unit -> unit

@ -178,9 +178,10 @@ let process_merge_file deps_file =
| Error error
-> L.internal_error "Couldn't read deps file '%s': %s" deps_file error ) ;
create_multilinks () ;
L.progress "Captured results merged.@." ;
L.progress "Targets merged: %d@." stats.targets_merged ;
L.progress "Files linked: %d@." stats.files_linked ;
L.progress "Files multilinked: %d@." stats.files_multilinked
let merge_captured_targets () = process_merge_file (infer_deps ())
let merge_captured_targets () =
L.progress "Merging captured Buck targets...@\n%!" ;
process_merge_file (infer_deps ())

@ -48,10 +48,8 @@ let add_flavor_to_target target =
-> add "compilation-database"
| None, CompileOnly
-> target
| None, (Linters | CaptureOnly)
| None, (BiAbduction | CaptureOnly | Checkers | Linters)
-> add "infer-capture-all"
| None, (BiAbduction | Checkers)
-> add "infer"
| None, Crashcontext
-> failwithf "Analyzer %s is Java-only; not supported with Buck flavors"
(Config.string_of_analyzer Config.analyzer)

@ -407,9 +407,8 @@ let report () =
let analyze_and_report ~changed_files mode =
let should_analyze, should_report =
match (mode, Config.analyzer) with
| PythonCapture (BBuck, _), _
-> (* In Buck mode when compilation db is not used, analysis is invoked either from capture or
a separate Analyze invocation is necessary, depending on the buck flavor used. *)
| PythonCapture (BBuck, _), _ when not Config.flavors
-> (* In Buck mode when compilation db is not used, analysis is invoked from capture if buck flavors are not used *)
(false, false)
| _ when Config.maven
-> (* Called from Maven, only do capture. *)
@ -421,6 +420,15 @@ let analyze_and_report ~changed_files mode =
| _, Linters
-> (false, true)
in
let should_merge =
match mode with
| PythonCapture (BBuck, _) when Config.flavors && CLOpt.(equal_command Run) Config.command
-> (* if doing capture + analysis of buck with flavors, we always need to merge targets before the analysis phase *)
true
| _
-> (* else rely on the command line value *) Config.merge
in
if should_merge then MergeCapture.merge_captured_targets () ;
if (should_analyze || should_report)
&& (Sys.file_exists Config.captured_dir <> `Yes || check_captured_empty mode)
then L.user_error "There was nothing to analyze.@\n@."

@ -0,0 +1,33 @@
# Copyright (c) 2017 - present Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
TESTS_DIR = ../..
ROOT_DIR = $(TESTS_DIR)/../..
ANALYZER = infer
BUCK_TARGET = //src:hello
SOURCES = $(wildcard src/hello.c)
OBJECTS = buck-out/gen/src/hello\#compile-hello.c.o1f717d69,default/hello.c.o
INFER_OPTIONS = --report-custom-error --developer-mode --project-root $(TESTS_DIR) --no-keep-going
INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests
CLEAN_EXTRA = buck-out
include $(TESTS_DIR)/infer.make
# Buck passes -a capture to infer
export INFER_STRICT_MODE=0
$(OBJECTS): $(JAVA_SOURCE_FILES)
$(QUIET)$(call silent_on_success,Compiling Buck flavors tests,\
NO_BUCKD=1 $(BUCK) build --no-cache $(BUCK_TARGET))
infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST)
$(QUIET)$(REMOVE_DIR) buck-out && \
$(call silent_on_success,Testing infer-run Buck flavors integration,\
NO_BUCKD=1 \
$(INFER_BIN) $(INFER_OPTIONS) run --flavors --results-dir $(CURDIR)/infer-out -- \
$(BUCK) build --no-cache $(BUCK_TARGET))

@ -0,0 +1,2 @@
src/hello.c, test, 2, NULL_DEREFERENCE, [start of procedure test()]
src/hello2.c, test2, 2, NULL_DEREFERENCE, [start of procedure test2()]

@ -0,0 +1,6 @@
cxx_library(
name = 'hello',
srcs = [
'hello.c', 'hello2.c',
],
)

@ -0,0 +1,15 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <stdlib.h>
void test() {
int* s = NULL;
*s = 42;
}

@ -0,0 +1,15 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <stdlib.h>
void test2() {
int* s = NULL;
*s = 42;
}
Loading…
Cancel
Save