Skip to content

Commit

Permalink
[ocamlformat] Upgrade base and ocamlformat
Browse files Browse the repository at this point in the history
Summary:
Upgrade ocamlformat to 0.3, and (necessarily) base to v0.10.0.

- Fix accumulated mis-formatting
- Update opam.lock to unbreak clean build
- Update to base v0.10.0
- Update opam.lock for base
- Update offline opam repo
- Everyone should already have removed their ocamlformat pin
- ocamlformat 0.3 supports output to stdout natively
- bump version of ocamlformat

Reviewed By: jeremydubreil

Differential Revision: D6636741

fbshipit-source-id: 41a56a8
  • Loading branch information
jvillard committed Feb 2, 2018
1 parent ddda04c commit 527398b
Show file tree
Hide file tree
Showing 272 changed files with 24,186 additions and 20,014 deletions.
1 change: 1 addition & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
margin 100
sparse true
version 0.3
2 changes: 2 additions & 0 deletions infer/src/IR/Annot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ module Item = struct
let pp fmt (a, _) = pp fmt a in
F.fprintf fmt "<%a>" (Pp.seq pp) ann


let to_string ann =
let pp fmt = pp fmt ann in
F.asprintf "%t" pp


(** Empty item annotation. *)
let empty = []

Expand Down
28 changes: 20 additions & 8 deletions infer/src/IR/Attributes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ let int64_of_attributes_kind =
let int64_two = Int64.of_int 2 in
function ProcUndefined -> Int64.zero | ProcObjCAccessor -> Int64.one | ProcDefined -> int64_two


let proc_kind_of_attr (proc_attributes: ProcAttributes.t) =
if proc_attributes.is_defined then ProcDefined
else if Option.is_some proc_attributes.objc_accessor then ProcObjCAccessor
else ProcUndefined


module type Data = sig
val of_pname : Typ.Procname.t -> Sqlite3.Data.t

Expand All @@ -38,6 +40,7 @@ module Data : Data = struct
let default () = Sqlite3.Data.TEXT (Typ.Procname.to_filename pname) in
Base.Hashtbl.find_or_add pname_to_key pname ~default


let of_source_file file = Sqlite3.Data.TEXT (SourceFile.to_string file)

let to_proc_attr = function[@warning "-8"] Sqlite3.Data.BLOB b -> Marshal.from_string b 0
Expand Down Expand Up @@ -76,6 +79,7 @@ FROM (
WHERE attr_kind < :akind
OR (attr_kind = :akind AND source_file < :sfile) )|}


let replace pname_blob akind loc_file attr_blob =
let replace_stmt = get_replace_statement () in
Sqlite3.bind replace_stmt 1 (* :pname *) pname_blob
Expand All @@ -88,6 +92,7 @@ let replace pname_blob akind loc_file attr_blob =
|> SqliteUtils.check_sqlite_error ~log:"replace bind proc attributes" ;
SqliteUtils.sqlite_unit_step ~finalize:false ~log:"Attributes.replace" replace_stmt


let get_find_more_defined_statement =
ResultsDir.register_statement
{|
Expand All @@ -97,6 +102,7 @@ WHERE proc_name = :pname
AND attr_kind > :akind
|}


let should_try_to_update pname_blob akind =
let find_stmt = get_find_more_defined_statement () in
Sqlite3.bind find_stmt 1 (* :pname *) pname_blob
Expand All @@ -106,21 +112,25 @@ let should_try_to_update pname_blob akind =
SqliteUtils.sqlite_result_step ~finalize:false ~log:"Attributes.replace" find_stmt
|> (* there is no entry with a strictly larger "definedness" for that proc name *) Option.is_none


let get_select_statement =
ResultsDir.register_statement "SELECT proc_attributes FROM attributes WHERE proc_name = :k"


let get_select_defined_statement =
ResultsDir.register_statement
"SELECT proc_attributes FROM attributes WHERE proc_name = :k AND attr_kind = %Ld"
(int64_of_attributes_kind ProcDefined)


let find ~defined pname_blob =
let select_stmt = if defined then get_select_defined_statement () else get_select_statement () in
Sqlite3.bind select_stmt 1 pname_blob
|> SqliteUtils.check_sqlite_error ~log:"find bind proc name" ;
SqliteUtils.sqlite_result_step ~finalize:false ~log:"Attributes.find" select_stmt
|> Option.map ~f:Data.to_proc_attr


let load pname = Data.of_pname pname |> find ~defined:false

let store (attr: ProcAttributes.t) =
Expand All @@ -129,6 +139,7 @@ let store (attr: ProcAttributes.t) =
if should_try_to_update key pkind then
replace key pkind (Data.of_source_file attr.loc.Location.file) (Data.of_proc_attr attr)


let load_defined pname = Data.of_pname pname |> find ~defined:true

let get_correct_type_from_objc_class_name type_name =
Expand All @@ -139,21 +150,22 @@ let get_correct_type_from_objc_class_name type_name =
*)
Some (Typ.mk (Tstruct type_name))


let find_file_capturing_procedure pname =
match load pname with
| None
-> None
| Some proc_attributes
-> let source_file = proc_attributes.ProcAttributes.source_file_captured in
| None ->
None
| Some proc_attributes ->
let source_file = proc_attributes.ProcAttributes.source_file_captured in
let source_dir = DB.source_dir_from_source_file source_file in
let origin =
(* Procedure coming from include files if it has different location
than the file where it was captured. *)
match SourceFile.compare source_file proc_attributes.ProcAttributes.loc.file <> 0 with
| true
-> `Include
| false
-> `Source
| true ->
`Include
| false ->
`Source
in
let cfg_fname = DB.source_dir_get_internal_file source_dir ".cfg" in
let cfg_fname_exists =
Expand Down
134 changes: 68 additions & 66 deletions infer/src/IR/Binop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,83 +52,85 @@ let invertible = function PlusA | PlusPI | MinusA | MinusPI -> true | _ -> false
If the [binop] operation is not invertible, the function raises Assert_failure. *)
let invert bop =
match bop with
| PlusA
-> MinusA
| PlusPI
-> MinusPI
| MinusA
-> PlusA
| MinusPI
-> PlusPI
| _
-> assert false
| PlusA ->
MinusA
| PlusPI ->
MinusPI
| MinusA ->
PlusA
| MinusPI ->
PlusPI
| _ ->
assert false


(** This function returns true if 0 is the right unit of [binop].
The return value false means "don't know". *)
let is_zero_runit = function PlusA | PlusPI | MinusA | MinusPI | MinusPP -> true | _ -> false

let text = function
| PlusA
-> "+"
| PlusPI
-> "+"
| MinusA | MinusPP
-> "-"
| MinusPI
-> "-"
| Mult
-> "*"
| Div
-> "/"
| Mod
-> "%"
| Shiftlt
-> "<<"
| Shiftrt
-> ">>"
| Lt
-> "<"
| Gt
-> ">"
| Le
-> "<="
| Ge
-> ">="
| Eq
-> "=="
| Ne
-> "!="
| BAnd
-> "&"
| BXor
-> "^"
| BOr
-> "|"
| LAnd
-> "&&"
| LOr
-> "||"
| PlusA ->
"+"
| PlusPI ->
"+"
| MinusA | MinusPP ->
"-"
| MinusPI ->
"-"
| Mult ->
"*"
| Div ->
"/"
| Mod ->
"%"
| Shiftlt ->
"<<"
| Shiftrt ->
">>"
| Lt ->
"<"
| Gt ->
">"
| Le ->
"<="
| Ge ->
">="
| Eq ->
"=="
| Ne ->
"!="
| BAnd ->
"&"
| BXor ->
"^"
| BOr ->
"|"
| LAnd ->
"&&"
| LOr ->
"||"


(** Pretty print a binary operator. *)
let str pe binop =
match pe.Pp.kind with
| HTML -> (
match binop with
| Ge
-> " &gt;= "
| Le
-> " &lt;= "
| Gt
-> " &gt; "
| Lt
-> " &lt; "
| Shiftlt
-> " &lt;&lt; "
| Shiftrt
-> " &gt;&gt; "
| _
-> text binop )
| Ge ->
" &gt;= "
| Le ->
" &lt;= "
| Gt ->
" &gt; "
| Lt ->
" &lt; "
| Shiftlt ->
" &lt;&lt; "
| Shiftrt ->
" &gt;&gt; "
| _ ->
text binop )
| LATEX -> (
match binop with Ge -> " \\geq " | Le -> " \\leq " | _ -> text binop )
| _
-> text binop
| _ ->
text binop
3 changes: 3 additions & 0 deletions infer/src/IR/BuiltinDecl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let create_procname name =
let pname = Typ.Procname.from_string_c_fun name in
register pname ; pname


let create_objc_class_method class_name method_name =
let method_kind = Typ.Procname.ObjCClassMethod in
let tname = Typ.Name.Objc.from_string class_name in
Expand All @@ -28,6 +29,7 @@ let create_objc_class_method class_name method_name =
in
register pname ; pname


let is_declared pname = Typ.Procname.Set.mem pname !builtin_decls

let __array_access = create_procname "__array_access"
Expand Down Expand Up @@ -83,6 +85,7 @@ let __objc_cast = create_procname "__objc_cast"
let __objc_dictionary_literal =
create_objc_class_method "NSDictionary" "dictionaryWithObjects:forKeys:count:"


let __objc_release = create_procname "__objc_release"

let __objc_release_autorelease_pool = create_procname "__objc_release_autorelease_pool"
Expand Down
1 change: 1 addition & 0 deletions infer/src/IR/CallFlags.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let pp f cf =
if cf.cf_virtual then F.fprintf f " virtual" ;
if cf.cf_noreturn then F.fprintf f " noreturn"


let default =
{ cf_virtual= false
; cf_interface= false
Expand Down
Loading

0 comments on commit 527398b

Please sign in to comment.