diff --git a/infer/src/IR/Attributes.ml b/infer/src/IR/Attributes.ml index ae8f333b4..07b974a36 100644 --- a/infer/src/IR/Attributes.ml +++ b/infer/src/IR/Attributes.ml @@ -72,17 +72,16 @@ let store ~proc_desc (attr : ProcAttributes.t) = let proc_uid = Procname.to_unique_id pname in if should_try_to_update proc_uid akind then let proc_name = Procname.SQLite.serialize pname in - let proc_name_hum = Procname.to_string pname in let attr_kind = int64_of_attributes_kind akind in let cfg = Procdesc.SQLite.serialize proc_desc in let proc_attributes = ProcAttributes.SQLite.serialize attr in let source_file = SourceFile.SQLite.serialize attr.loc.Location.file in let callees = - Option.map proc_desc ~f:Procdesc.get_static_callees - |> Option.value ~default:[] |> Procname.SQLiteList.serialize + Option.value_map proc_desc ~f:Procdesc.get_static_callees ~default:[] + |> Procname.SQLiteList.serialize in - DBWriter.replace_attributes ~proc_uid ~proc_name ~proc_name_hum ~attr_kind ~source_file - ~proc_attributes ~cfg ~callees + DBWriter.replace_attributes ~proc_uid ~proc_name ~attr_kind ~source_file ~proc_attributes ~cfg + ~callees let find_file_capturing_procedure pname = diff --git a/infer/src/backend/Procedures.ml b/infer/src/backend/Procedures.ml index 636746806..6776b2310 100644 --- a/infer/src/backend/Procedures.ml +++ b/infer/src/backend/Procedures.ml @@ -65,7 +65,7 @@ let pp_all ~filter ~proc_name:proc_name_cond ~attr_kind ~source_file:source_file pp_if ?new_line condition title pp fmt (Sqlite3.column stmt column |> deserialize) in let pp_row stmt fmt source_file proc_name = - let[@warning "-8"] (Sqlite3.Data.TEXT proc_name_hum) = Sqlite3.column stmt 1 in + let[@warning "-8"] (Sqlite3.Data.TEXT proc_uid) = Sqlite3.column stmt 1 in let dump_cfg fmt cfg_opt = match cfg_opt with | None -> @@ -74,7 +74,7 @@ let pp_all ~filter ~proc_name:proc_name_cond ~attr_kind ~source_file:source_file let path = DotCfg.emit_proc_desc source_file cfg in F.fprintf fmt "'%s'" path in - Format.fprintf fmt "@[%s@,%a%a%a%a%a@]@\n" proc_name_hum + Format.fprintf fmt "@[%s@,%a%a%a%a%a@]@\n" proc_uid (pp_if source_file_cond "source_file" SourceFile.pp) source_file (pp_if proc_name_cond "proc_name" Procname.pp) @@ -92,7 +92,7 @@ let pp_all ~filter ~proc_name:proc_name_cond ~attr_kind ~source_file:source_file (* we could also register this statement but it's typically used only once per run so just prepare it inside the function *) Sqlite3.prepare db - "SELECT proc_name, proc_name_hum, attr_kind, source_file, proc_attributes, cfg FROM procedures" + "SELECT proc_name, proc_uid, attr_kind, source_file, proc_attributes, cfg FROM procedures" |> Container.iter ~fold:(SqliteUtils.result_fold_rows db ~log:"print all procedures") ~f:(fun stmt -> let proc_name = Sqlite3.column stmt 0 |> Procname.SQLite.deserialize in diff --git a/infer/src/base/DBWriter.ml b/infer/src/base/DBWriter.ml index 3c62cf567..2dba4d241 100644 --- a/infer/src/base/DBWriter.ml +++ b/infer/src/base/DBWriter.ml @@ -31,7 +31,7 @@ module Implementation = struct ResultsDatabase.register_statement {| INSERT OR REPLACE INTO procedures - SELECT :uid, :pname, :proc_name_hum, :akind, :sfile, :pattr, :cfg, :callees + SELECT :uid, :pname, :akind, :sfile, :pattr, :cfg, :callees FROM ( SELECT NULL FROM ( @@ -43,24 +43,22 @@ module Implementation = struct OR (attr_kind = :akind AND source_file <= :sfile) ) |} in - fun ~proc_uid ~proc_name ~proc_name_hum ~attr_kind ~source_file ~proc_attributes ~cfg ~callees -> + fun ~proc_uid ~proc_name ~attr_kind ~source_file ~proc_attributes ~cfg ~callees -> ResultsDatabase.with_registered_statement attribute_replace_statement ~f:(fun db replace_stmt -> Sqlite3.bind replace_stmt 1 (* :proc_uid *) (Sqlite3.Data.TEXT proc_uid) |> SqliteUtils.check_result_code db ~log:"replace bind proc_uid" ; Sqlite3.bind replace_stmt 2 (* :pname *) proc_name |> SqliteUtils.check_result_code db ~log:"replace bind proc_name" ; - Sqlite3.bind replace_stmt 3 (* :proc_name_hum *) (Sqlite3.Data.TEXT proc_name_hum) - |> SqliteUtils.check_result_code db ~log:"replace bind proc_name_hum" ; - Sqlite3.bind replace_stmt 4 (* :akind *) (Sqlite3.Data.INT attr_kind) + Sqlite3.bind replace_stmt 3 (* :akind *) (Sqlite3.Data.INT attr_kind) |> SqliteUtils.check_result_code db ~log:"replace bind attr_kind" ; - Sqlite3.bind replace_stmt 5 (* :sfile *) source_file + Sqlite3.bind replace_stmt 4 (* :sfile *) source_file |> SqliteUtils.check_result_code db ~log:"replace bind source source_file" ; - Sqlite3.bind replace_stmt 6 (* :pattr *) proc_attributes + Sqlite3.bind replace_stmt 5 (* :pattr *) proc_attributes |> SqliteUtils.check_result_code db ~log:"replace bind proc proc_attributes" ; - Sqlite3.bind replace_stmt 7 (* :cfg *) cfg + Sqlite3.bind replace_stmt 6 (* :cfg *) cfg |> SqliteUtils.check_result_code db ~log:"replace bind cfg" ; - Sqlite3.bind replace_stmt 8 (* :callees *) callees + Sqlite3.bind replace_stmt 7 (* :callees *) callees |> SqliteUtils.check_result_code db ~log:"replace bind callees" ; SqliteUtils.result_unit db ~finalize:false ~log:"replace_attributes" replace_stmt ) @@ -112,7 +110,6 @@ module Implementation = struct SELECT sub.proc_uid, sub.proc_name, - sub.proc_name_hum, sub.attr_kind, sub.source_file, sub.proc_attributes, @@ -237,7 +234,6 @@ module Command = struct | ReplaceAttributes of { proc_uid: string ; proc_name: Sqlite3.Data.t - ; proc_name_hum: string ; attr_kind: int64 ; source_file: Sqlite3.Data.t ; proc_attributes: Sqlite3.Data.t @@ -289,11 +285,10 @@ module Command = struct Implementation.merge infer_deps_file | StoreSpec {proc_uid; proc_name; analysis_summary; report_summary} -> Implementation.store_spec ~proc_uid ~proc_name ~analysis_summary ~report_summary - | ReplaceAttributes - {proc_uid; proc_name; proc_name_hum; attr_kind; source_file; proc_attributes; cfg; callees} + | ReplaceAttributes {proc_uid; proc_name; attr_kind; source_file; proc_attributes; cfg; callees} -> - Implementation.replace_attributes ~proc_uid ~proc_name ~proc_name_hum ~attr_kind - ~source_file ~proc_attributes ~cfg ~callees + Implementation.replace_attributes ~proc_uid ~proc_name ~attr_kind ~source_file + ~proc_attributes ~cfg ~callees | ResetCaptureTables -> Implementation.reset_capture_tables () | Terminate -> @@ -397,11 +392,9 @@ let start () = Server.start () let stop () = Server.send Command.Terminate -let replace_attributes ~proc_uid ~proc_name ~proc_name_hum ~attr_kind ~source_file ~proc_attributes - ~cfg ~callees = +let replace_attributes ~proc_uid ~proc_name ~attr_kind ~source_file ~proc_attributes ~cfg ~callees = perform - (ReplaceAttributes - {proc_uid; proc_name; proc_name_hum; attr_kind; source_file; proc_attributes; cfg; callees}) + (ReplaceAttributes {proc_uid; proc_name; attr_kind; source_file; proc_attributes; cfg; callees}) let add_source_file ~source_file ~tenv ~integer_type_widths ~proc_names = diff --git a/infer/src/base/DBWriter.mli b/infer/src/base/DBWriter.mli index e7ead64e6..905351f13 100644 --- a/infer/src/base/DBWriter.mli +++ b/infer/src/base/DBWriter.mli @@ -14,7 +14,6 @@ val use_daemon : bool val replace_attributes : proc_uid:string -> proc_name:Sqlite3.Data.t - -> proc_name_hum:string -> attr_kind:int64 -> source_file:Sqlite3.Data.t -> proc_attributes:Sqlite3.Data.t diff --git a/infer/src/base/ResultsDatabase.ml b/infer/src/base/ResultsDatabase.ml index 7739d9952..d390e026a 100644 --- a/infer/src/base/ResultsDatabase.ml +++ b/infer/src/base/ResultsDatabase.ml @@ -17,7 +17,6 @@ let procedures_schema prefix = CREATE TABLE IF NOT EXISTS %sprocedures ( proc_uid TEXT PRIMARY KEY NOT NULL , proc_name BLOB NOT NULL - , proc_name_hum TEXT , attr_kind INTEGER NOT NULL , source_file TEXT NOT NULL , proc_attributes BLOB NOT NULL