diff --git a/infer/src/IR/Attributes.ml b/infer/src/IR/Attributes.ml index 88775d11f..bc20d27f8 100644 --- a/infer/src/IR/Attributes.ml +++ b/infer/src/IR/Attributes.ml @@ -55,7 +55,7 @@ let replace_statement = ResultsDatabase.register_statement {| INSERT OR REPLACE INTO procedures -SELECT :pname, :akind, :sfile, :pattr +SELECT :pname, :proc_name_hum, :akind, :sfile, :pattr FROM ( SELECT NULL FROM ( @@ -67,15 +67,18 @@ FROM ( OR (attr_kind = :akind AND source_file < :sfile) )|} -let replace pname_blob akind loc_file attr_blob = +let replace pname pname_blob akind loc_file attr_blob = ResultsDatabase.with_registered_statement replace_statement ~f:(fun db replace_stmt -> Sqlite3.bind replace_stmt 1 (* :pname *) pname_blob |> SqliteUtils.check_sqlite_error db ~log:"replace bind pname" ; - Sqlite3.bind replace_stmt 2 (* :akind *) (Sqlite3.Data.INT (int64_of_attributes_kind akind)) + Sqlite3.bind replace_stmt 2 + (* :proc_name_hum *) (Sqlite3.Data.TEXT (Typ.Procname.to_string pname)) + |> SqliteUtils.check_sqlite_error db ~log:"replace bind proc_name_hum" ; + Sqlite3.bind replace_stmt 3 (* :akind *) (Sqlite3.Data.INT (int64_of_attributes_kind akind)) |> SqliteUtils.check_sqlite_error db ~log:"replace bind attribute kind" ; - Sqlite3.bind replace_stmt 3 (* :sfile *) loc_file + Sqlite3.bind replace_stmt 4 (* :sfile *) loc_file |> SqliteUtils.check_sqlite_error db ~log:"replace bind source file" ; - Sqlite3.bind replace_stmt 4 (* :pattr *) attr_blob + Sqlite3.bind replace_stmt 5 (* :pattr *) attr_blob |> SqliteUtils.check_sqlite_error db ~log:"replace bind proc attributes" ; SqliteUtils.sqlite_unit_step db ~finalize:false ~log:"Attributes.replace" replace_stmt ) @@ -126,7 +129,7 @@ let store (attr: ProcAttributes.t) = let pkind = proc_kind_of_attr attr in let key = Typ.Procname.SQLite.serialize attr.proc_name in if should_try_to_update key pkind then - replace key pkind + replace attr.proc_name key pkind (SourceFile.SQLite.serialize attr.loc.Location.file) (ProcAttributes.SQLite.serialize attr) diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index 125b73dd7..afe3db9fa 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -1156,7 +1156,7 @@ module Procname = struct let serialize pname = - let default () = Sqlite3.Data.TEXT (to_filename pname) in + let default () = Sqlite3.Data.BLOB (Marshal.to_string pname []) in Base.Hashtbl.find_or_add pname_to_key pname ~default diff --git a/infer/src/backend/Procedures.ml b/infer/src/backend/Procedures.ml index 1c184d9ea..76c97e13a 100644 --- a/infer/src/backend/Procedures.ml +++ b/infer/src/backend/Procedures.ml @@ -12,27 +12,27 @@ module L = Logging let select_all_procedures_like_statement = ResultsDatabase.register_statement - "SELECT * FROM procedures WHERE proc_name LIKE :pname_like AND source_file LIKE \ + "SELECT * FROM procedures WHERE proc_name_hum LIKE :proc_name_like AND source_file LIKE \ :source_file_like" let pp_all ?filter ~proc_name ~attr_kind ~source_file ~proc_attributes fmt () = - let source_file_like, pname_like = + let source_file_like, proc_name_like = match filter with | None -> let wildcard = Sqlite3.Data.TEXT "%" in (wildcard, wildcard) | Some filter_string -> match String.lsplit2 ~on:':' filter_string with - | Some (source_file_like, pname_like) -> - (Sqlite3.Data.TEXT source_file_like, Sqlite3.Data.TEXT pname_like) + | Some (source_file_like, proc_name_like) -> + (Sqlite3.Data.TEXT source_file_like, Sqlite3.Data.TEXT proc_name_like) | None -> L.die UserError "Invalid filter for procedures. Please see the documentation for --procedures-filter \ in `infer explore --help`." in ResultsDatabase.with_registered_statement select_all_procedures_like_statement ~f:(fun db stmt -> - Sqlite3.bind stmt 1 (* :pname_like *) pname_like + Sqlite3.bind stmt 1 (* :proc_name_like *) proc_name_like |> SqliteUtils.check_sqlite_error db ~log:"procedures filter pname bind" ; Sqlite3.bind stmt 2 (* :source_file_like *) source_file_like |> SqliteUtils.check_sqlite_error db ~log:"procedures filter source file bind" ; @@ -45,19 +45,18 @@ let pp_all ?filter ~proc_name ~attr_kind ~source_file ~proc_attributes fmt () = match Sqlite3.step stmt with | Sqlite3.Rc.ROW -> let proc_name_hum = - (* same as proc_name for now, will change later *) - match[@warning "-8"] Sqlite3.column stmt 0 with Sqlite3.Data.TEXT s -> s + match[@warning "-8"] Sqlite3.column stmt 1 with Sqlite3.Data.TEXT s -> s in Format.fprintf fmt "@[