diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 3e15c385d..57117650d 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -1615,10 +1615,6 @@ INTERNAL OPTIONS Activates: [Purity]Consider unknown functions to be pure by default (Conversely: --no-pure-by-default) - --reactive-capture - Activates: Compile source files only when required by analyzer - (clang only) (Conversely: --no-reactive-capture) - --reanalyze Activates: Rerun the analysis. Not compatible with --incremental-analysis and --continue-analysis. (Conversely: diff --git a/infer/src/IR/Attributes.ml b/infer/src/IR/Attributes.ml index 500fd59a0..916855574 100644 --- a/infer/src/IR/Attributes.ml +++ b/infer/src/IR/Attributes.ml @@ -66,23 +66,15 @@ let select_statement = ResultsDatabase.register_statement "SELECT proc_attributes FROM procedures WHERE proc_name = :k" -let select_defined_statement = - ResultsDatabase.register_statement - "SELECT proc_attributes FROM procedures WHERE proc_name = :k AND attr_kind = %Ld" - (int64_of_attributes_kind ProcDefined) - +let find pname_blob = + ResultsDatabase.with_registered_statement select_statement ~f:(fun db select_stmt -> + Sqlite3.bind select_stmt 1 pname_blob + |> SqliteUtils.check_result_code db ~log:"find bind proc name" ; + SqliteUtils.result_single_column_option ~finalize:false ~log:"Attributes.find" db select_stmt + |> Option.map ~f:ProcAttributes.SQLite.deserialize ) -let find ~defined pname_blob = - (if defined then select_defined_statement else select_statement) - |> ResultsDatabase.with_registered_statement ~f:(fun db select_stmt -> - Sqlite3.bind select_stmt 1 pname_blob - |> SqliteUtils.check_result_code db ~log:"find bind proc name" ; - SqliteUtils.result_single_column_option ~finalize:false ~log:"Attributes.find" db - select_stmt - |> Option.map ~f:ProcAttributes.SQLite.deserialize ) - -let load pname = Procname.SQLite.serialize pname |> find ~defined:false +let load pname = find (Procname.SQLite.serialize pname) let store ~proc_desc (attr : ProcAttributes.t) = let pkind = proc_kind_of_attr attr in @@ -95,8 +87,6 @@ let store ~proc_desc (attr : ProcAttributes.t) = (Option.map proc_desc ~f:Procdesc.get_static_callees |> Option.value ~default:[]) -let load_defined pname = Procname.SQLite.serialize pname |> find ~defined:true - let find_file_capturing_procedure pname = Option.map (load pname) ~f:(fun proc_attributes -> let source_file = proc_attributes.ProcAttributes.translation_unit in diff --git a/infer/src/IR/Attributes.mli b/infer/src/IR/Attributes.mli index 232f5c528..7c3e50132 100644 --- a/infer/src/IR/Attributes.mli +++ b/infer/src/IR/Attributes.mli @@ -19,9 +19,6 @@ val store : proc_desc:Procdesc.t option -> ProcAttributes.t -> unit val load : Procname.t -> ProcAttributes.t option (** Load the attributes for the procedure from the attributes database. *) -val load_defined : Procname.t -> ProcAttributes.t option -(** Load attributes for the procedure but only if is_defined is true *) - val find_file_capturing_procedure : Procname.t -> (SourceFile.t * [`Include | `Source]) option (** Find the file where the procedure was captured, if a cfg for that file exists. Return also a boolean indicating whether the procedure is defined in an include file. *) diff --git a/infer/src/IR/SourceFiles.ml b/infer/src/IR/SourceFiles.ml index ed371231b..0b12503a0 100644 --- a/infer/src/IR/SourceFiles.ml +++ b/infer/src/IR/SourceFiles.ml @@ -93,21 +93,6 @@ let proc_names_of_source source = |> Option.value_map ~default:[] ~f:Procname.SQLiteList.deserialize ) -let exists_source_statement = - ResultsDatabase.register_statement "SELECT 1 FROM source_files WHERE source_file = :k" - - -let is_captured source = - ResultsDatabase.with_registered_statement exists_source_statement ~f:(fun db exists_stmt -> - SourceFile.SQLite.serialize source - |> Sqlite3.bind exists_stmt 1 - (* :k *) - |> SqliteUtils.check_result_code db ~log:"load captured source file" ; - SqliteUtils.result_single_column_option ~finalize:false ~log:"SourceFiles.is_captured" db - exists_stmt - |> Option.is_some ) - - let is_non_empty_statement = ResultsDatabase.register_statement "SELECT 1 FROM source_files LIMIT 1" let is_empty () = diff --git a/infer/src/IR/SourceFiles.mli b/infer/src/IR/SourceFiles.mli index b5a677fc3..209a1bdfa 100644 --- a/infer/src/IR/SourceFiles.mli +++ b/infer/src/IR/SourceFiles.mli @@ -16,9 +16,6 @@ val get_all : filter:Filtering.source_files_filter -> unit -> SourceFile.t list val proc_names_of_source : SourceFile.t -> Procname.t list (** list of all the proc names (declared and defined) found in a source file *) -val is_captured : SourceFile.t -> bool -(** has the source file been captured? *) - val is_empty : unit -> bool (** whether there exists at least one captured source file *) diff --git a/infer/src/backend/OndemandCapture.ml b/infer/src/backend/OndemandCapture.ml deleted file mode 100644 index 75ccaf100..000000000 --- a/infer/src/backend/OndemandCapture.ml +++ /dev/null @@ -1,58 +0,0 @@ -(* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - *) -open! IStd -module L = Logging - -let compilation_db = lazy (CompilationDatabase.from_json_files !Config.clang_compilation_dbs) - -(** Given proc_attributes try to produce proc_attributes' where proc_attributes'.is_defined = true - It may trigger capture of extra files to do so and when it does, it waits for frontend to finish - before returning *) -let try_capture (attributes : ProcAttributes.t) : ProcAttributes.t option = - let (lazy cdb) = compilation_db in - ( if Option.is_none (Attributes.load_defined attributes.proc_name) then - let decl_file = attributes.loc.file in - let definition_file_opt = SourceFile.of_header decl_file in - let try_compile definition_file = - (* Use the cfg as a proxy to find out whether definition_file was already captured. If it - was, there is no point in trying to capture it again. Treat existance of the cfg as a - barrier - if it exists it means that all attributes files have been created - write logic - is defined in Cfg.store *) - if not (SourceFiles.is_captured decl_file) then ( - L.(debug Capture Verbose) "Started capture of %a...@\n" SourceFile.pp definition_file ; - Timeout.suspend_existing_timeout ~keep_symop_total:true ; - protect - ~f:(fun () -> CaptureCompilationDatabase.capture_file_in_database cdb definition_file) - ~finally:Timeout.resume_previous_timeout ; - if Config.debug_mode && Option.is_none (Attributes.load_defined attributes.proc_name) then - (* peek at the results to know if capture succeeded, but only in debug mode *) - L.(debug Capture Verbose) - "Captured file %a to get procedure %a but it wasn't found there@\n" SourceFile.pp - definition_file Procname.pp attributes.proc_name ) - else - L.(debug Capture Verbose) - "Wanted to capture file %a to get procedure %a but file was already captured@\n" - SourceFile.pp definition_file Procname.pp attributes.proc_name - in - match definition_file_opt with - | None -> - L.(debug Capture Medium) - "Couldn't find source file for %a (declared in %a)@\n" Procname.pp attributes.proc_name - SourceFile.pp decl_file - | Some file -> - try_compile file ) ; - (* It's important to call load_defined_attributes again in all cases to make sure we try - reading from disk again no matter which condition happened. If previous call to - load_defined_attributes is None, it may mean couple of things: - - proc_name hasn't been captured yet, so it needs to get captured (most likely scenario) - - there was a race and proc_name got captured by the time we checked whether - cfg_filename exists. In this case it's important to refetch attributes from disk because - contents may have changed (attributes file for proc_name may be there now) - - Caveat: it's possible that procedure will be captured in some other unrelated file - later - infer may ignore it then. *) - Attributes.load_defined attributes.proc_name diff --git a/infer/src/backend/exe_env.ml b/infer/src/backend/exe_env.ml index 2d1ce29b6..b2c187fb1 100644 --- a/infer/src/backend/exe_env.ml +++ b/infer/src/backend/exe_env.ml @@ -49,9 +49,6 @@ let get_file_data exe_env pname = | None -> L.debug Analysis Medium "can't find attributes for %a@." Procname.pp pname ; None - | Some proc_attributes when Config.reactive_capture -> - let get_captured_file {ProcAttributes.translation_unit} = translation_unit in - OndemandCapture.try_capture proc_attributes |> Option.map ~f:get_captured_file | Some proc_attributes -> Some proc_attributes.ProcAttributes.translation_unit in diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 51d65d3de..660ed7547 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -81,10 +81,6 @@ let get_proc_attr proc_name = let procedure_should_be_analyzed proc_name = match get_proc_attr proc_name with - | Some proc_attributes when Config.reactive_capture && not proc_attributes.is_defined -> - (* try to capture procedure first *) - let defined_proc_attributes = OndemandCapture.try_capture proc_attributes in - Option.value_map ~f:should_be_analyzed ~default:false defined_proc_attributes | Some proc_attributes -> should_be_analyzed proc_attributes | None -> diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index e08062237..cd89946fc 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1843,11 +1843,6 @@ and reactive = started" -and reactive_capture = - CLOpt.mk_bool ~long:"reactive-capture" - "Compile source files only when required by analyzer (clang only)" - - and reanalyze = CLOpt.mk_bool ~long:"reanalyze" "Rerun the analysis. Not compatible with $(b,--incremental-analysis) and \ @@ -2882,8 +2877,6 @@ and racerd_guardedby = !racerd_guardedby and reactive_mode = !reactive -and reactive_capture = !reactive_capture - and reanalyze = !reanalyze and relative_path_backtrack = !relative_path_backtrack diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index fc10946c9..cc088809c 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -469,8 +469,6 @@ val quiet : bool val racerd_guardedby : bool -val reactive_capture : bool - val reactive_mode : bool val reanalyze : bool diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index af15236a5..c98727269 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -155,7 +155,3 @@ let capture_files_in_database ~changed_files compilation_database = fun source_file -> SourceFile.Set.mem source_file changed_files_set in run_compilation_database compilation_database filter_changed - - -let capture_file_in_database compilation_database source_file = - run_compilation_database compilation_database (SourceFile.equal source_file) diff --git a/infer/src/integration/CaptureCompilationDatabase.mli b/infer/src/integration/CaptureCompilationDatabase.mli index 0f990c783..255b17915 100644 --- a/infer/src/integration/CaptureCompilationDatabase.mli +++ b/infer/src/integration/CaptureCompilationDatabase.mli @@ -12,8 +12,6 @@ val capture_files_in_database : (** Run the capture of the files for which we have compilation commands in the database and in [changed_files], if specified. *) -val capture_file_in_database : CompilationDatabase.t -> SourceFile.t -> unit - val get_compilation_database_files_buck : BuckMode.clang_compilation_db_deps -> prog:string -> args:string list -> [> `Raw of string] list (** Get the compilation database files that contain the compilation given by the buck command. It diff --git a/infer/tests/build_systems/clang_compilation_db/Makefile b/infer/tests/build_systems/clang_compilation_db/Makefile index ad3a3a330..4b842287b 100644 --- a/infer/tests/build_systems/clang_compilation_db/Makefile +++ b/infer/tests/build_systems/clang_compilation_db/Makefile @@ -36,16 +36,9 @@ infer-out-no-index/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(CLANG $(QUIET)$(call silent_on_success,Testing Clang compilation database integration,\ $(INFER_BIN) $(INFER_OPTIONS) -o $(@D) --compilation-database $<) -infer-out-reactive-capture/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(CLANG_DEPS) $(SOURCES) - $(QUIET)$(call silent_on_success,Testing Clang compilation database reactive capture integration,\ - $(INFER_BIN) $(INFER_OPTIONS) -o $(@D) --reactive-capture \ - --changed-files-index $(CMAKE_DIR)/index.txt --compilation-database $<) - -issues.exp.test: infer-out-with-index/report.json infer-out-no-index/report.json infer-out-reactive-capture/report.json +issues.exp.test: infer-out-with-index/report.json infer-out-no-index/report.json $(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@.with-index \ -o infer-out-with-index $(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@.no-index \ -o infer-out-no-index - $(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@.reactive-capture \ - -o infer-out-reactive-capture - $(QUIET)cat $@.with-index $@.no-index $@.reactive-capture > $@ + $(QUIET)cat $@.with-index $@.no-index > $@ diff --git a/infer/tests/build_systems/clang_compilation_db/issues.exp b/infer/tests/build_systems/clang_compilation_db/issues.exp index 3678de777..a7902cb18 100644 --- a/infer/tests/build_systems/clang_compilation_db/issues.exp +++ b/infer/tests/build_systems/clang_compilation_db/issues.exp @@ -5,7 +5,3 @@ hello.cpp, test0, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure tes hello.cpp, test1, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test1(),start of procedure deref1()] hello.cpp, test2, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test2(),start of procedure deref2()] lib3.h, test, 0, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test(),start of procedure deref3()] -hello.cpp, test0, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test0()] -hello.cpp, test1, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test1(),start of procedure deref1()] -hello.cpp, test2, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test2(),start of procedure deref2()] -lib3.h, test, 0, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test(),start of procedure deref3()]