[FCP] linting facebook-clang-plugin files [4/N]

Summary:
arc lint run on all facebook-clang-plugins files

```
$ arc lint
$ make clang_plugin_test_replace
```

Reviewed By: jvillard

Differential Revision: D23597477

fbshipit-source-id: 746b5ed76
master
Martin Trojer 4 years ago committed by Facebook GitHub Bot
parent d519c8330a
commit 83c368f8a7

@ -1,4 +1,4 @@
# Copyright (c) 2014-present, Facebook, Inc.
# 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.
@ -26,17 +26,3 @@ fmt_all:
find libtooling \
\( -name '*'.cpp -or -name '*'.h -or -name '*'.c -or -name '*'.m -or -name '*'.mm \) \
-exec ./clang/install/bin/clang-format -verbose -i \{\} \+
CHECKCOPYRIGHT=../infer/bin/checkCopyright
.PHONY: copyright
copyright:
@[ -x $(CHECKCOPYRIGHT) ] || { \
echo "only works when this repo is checked out as a git submodule inside the infer repo" >&2; \
echo "make sure this is the case and that `make checkCopyright` has been run from within infer" >&2; \
exit 1; \
}
git ls-files \
| grep -e '\(\.\(atd\|c\|cpp\|h\|m\|ml\|mli\|mm\|py\|sh\)\(\|\.p\)$$\|^\(.*/\|\)Makefile\)' \
| grep -v 'libtooling/ASTExporter\.\(cpp\|h\)' \
| xargs $(CHECKCOPYRIGHT) -i

@ -1,4 +1,4 @@
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,4 +1,4 @@
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,4 +1,4 @@
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,4 +1,4 @@
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
(*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.
@ -8,7 +8,7 @@
module PointerOrd = struct
type t = int
let compare (i: int) (j: int) = i - j
let compare (i : int) (j : int) = i - j
end
module PointerMap = Map.Make (PointerOrd)
@ -24,8 +24,8 @@ let ivarToPropertyMap = ref PointerMap.empty
let empty_v = Clang_ast_visit.empty_visitor
(* This function is not thread-safe *)
let visit_ast ?(visit_decl= empty_v) ?(visit_stmt= empty_v) ?(visit_type= empty_v)
?(visit_src_loc= empty_v) top_decl =
let visit_ast ?(visit_decl = empty_v) ?(visit_stmt = empty_v) ?(visit_type = empty_v)
?(visit_src_loc = empty_v) top_decl =
Clang_ast_visit.decl_visitor := visit_decl ;
Clang_ast_visit.stmt_visitor := visit_stmt ;
Clang_ast_visit.type_visitor := visit_type ;
@ -113,4 +113,5 @@ let index_node_pointers top_decl =
visit_ast ~visit_decl:process_decl ~visit_stmt:add_stmt_to_cache ~visit_type:add_type_to_cache
~visit_src_loc:complete_source_location top_decl ;
let result = (!declMap, !stmtMap, !typeMap, !ivarToPropertyMap) in
reset_cache () ; result
reset_cache () ;
result

@ -1,5 +1,5 @@
(*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.
@ -20,7 +20,9 @@ let validate_type_ptr key_ptr c_type = validate_ptr key_ptr (`TypeNode c_type)
let print_node path kind_str =
let indent = String.make (List.length path) ' ' in
prerr_string indent ; prerr_string kind_str ; prerr_newline ()
prerr_string indent ;
prerr_string kind_str ;
prerr_newline ()
let sloc_to_str sloc =
@ -65,9 +67,15 @@ let check_decl_cache_from_file fname =
let main =
let v = Sys.argv in
try for i = 1 to Array.length v - 1 do check_decl_cache_from_file v.(i) done with
try
for i = 1 to Array.length v - 1 do
check_decl_cache_from_file v.(i)
done
with
| PointerMismatch ->
prerr_string "Pointer in cache doesn't match" ;
exit 1
| Yojson.Json_error s | Atdgen_runtime.Oj_run.Error s ->
prerr_string s ; prerr_newline () ; exit 1
prerr_string s ;
prerr_newline () ;
exit 1

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -29,6 +29,8 @@ let print_named_decl_from_file fname =
let main =
try Array.iteri (fun i arg -> if i <> 0 then print_named_decl_from_file arg) Sys.argv with
| Yojson.Json_error s | Atdgen_runtime.Oj_run.Error s ->
prerr_string s ; prerr_newline () ; exit 1
try Array.iteri (fun i arg -> if i <> 0 then print_named_decl_from_file arg) Sys.argv
with Yojson.Json_error s | Atdgen_runtime.Oj_run.Error s ->
prerr_string s ;
prerr_newline () ;
exit 1

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -33,11 +33,10 @@ let name_info name = {ni_name= name; ni_qual_name= [name]}
let append_name_info info suffix =
{ni_name= info.ni_name ^ suffix; ni_qual_name= List.map (fun x -> x ^ suffix) info.ni_qual_name}
let qual_type ptr =
{ qt_type_ptr= ptr
; qt_is_const= false
; qt_is_restrict= false
; qt_is_volatile= false }
{qt_type_ptr= ptr; qt_is_const= false; qt_is_restrict= false; qt_is_volatile= false}
let var_decl_info ~is_global =
{ vdi_is_global= is_global
@ -49,16 +48,16 @@ let var_decl_info ~is_global =
; vdi_is_init_expr_cxx11_constant= false
; vdi_init_expr= None
; vdi_parm_index_in_function= None
; vdi_is_static = false}
; vdi_is_static= false }
let stmt_info pointer =
{ si_pointer= pointer
; si_source_range= (empty_source_location, empty_source_location) }
{si_pointer= pointer; si_source_range= (empty_source_location, empty_source_location)}
let expr_info qual_type =
{ ei_qual_type= qual_type
; ei_value_kind= `RValue
; ei_object_kind= `Ordinary }
{ei_qual_type= qual_type; ei_value_kind= `RValue; ei_object_kind= `Ordinary}
let cxx_construct_expr_info decl_ref is_copy_constructor =
{ xcei_decl_ref= decl_ref
@ -84,39 +83,41 @@ let () =
let di2 = decl_info (source_location ~file:"bla" ()) (source_location ~file:"bleh" ()) in
let decl3 = update_decl_tuple (fun _ -> di2) decl in
assert_equal "update_decl_tuple" (get_decl_tuple decl3) di2 ;
assert_equal "get_var_decl_tuple_none" (get_var_decl_tuple decl) None ;
let vdi = var_decl_info ~is_global:true in
let qt = qual_type (Clang_ast_types.TypePtr.wrap 0) in
let var_decl = ParmVarDecl(di, name_info "fooey", qt, vdi) in
let var_decl = ParmVarDecl (di, name_info "fooey", qt, vdi) in
assert_equal "get_var_decl_tuple" (get_var_decl_tuple var_decl)
(Some (di, name_info "fooey", qt, vdi)) ;
let updated_var_decl = update_var_decl_tuple
(fun (di, ni, qt, vdi) ->
(di, append_name_info ni "-mod", qt, var_decl_info ~is_global:false))
var_decl in
assert_equal "update_var_decl_tuple" (get_var_decl_tuple updated_var_decl)
let updated_var_decl =
update_var_decl_tuple
(fun (di, ni, qt, vdi) -> (di, append_name_info ni "-mod", qt, var_decl_info ~is_global:false))
var_decl
in
assert_equal "update_var_decl_tuple"
(get_var_decl_tuple updated_var_decl)
(Some (di, name_info "fooey-mod", qt, var_decl_info ~is_global:false)) ;
let stmt = DoStmt(stmt_info 0, []) in
assert_equal "get_cxx_construct_expr_tuple_from_stmt"
(get_cxx_construct_expr_tuple stmt) None ;
let stmt = DoStmt (stmt_info 0, []) in
assert_equal "get_cxx_construct_expr_tuple_from_stmt" (get_cxx_construct_expr_tuple stmt) None ;
let ei = expr_info qt in
let dr = { dr_kind= `CXXConstructor
; dr_decl_pointer= 0
; dr_name= None
; dr_is_hidden= false
; dr_qual_type= None } in
let dr =
{ dr_kind= `CXXConstructor
; dr_decl_pointer= 0
; dr_name= None
; dr_is_hidden= false
; dr_qual_type= None }
in
let xcei = cxx_construct_expr_info dr true in
let xcei2 = cxx_construct_expr_info dr false in
let cxx_ctor_expr = CXXConstructExpr(stmt_info 1, [], ei, xcei) in
let cxx_ctor_expr = CXXConstructExpr (stmt_info 1, [], ei, xcei) in
assert_equal "get_cxx_construct_expr_tuple"
(get_cxx_construct_expr_tuple cxx_ctor_expr)
(Some (stmt_info 1, [], ei, xcei)) ;
let updated_cxx_ctor_expr = update_cxx_construct_expr_tuple
(fun (si, sl, ei, xcei) ->
(stmt_info (si.si_pointer + 1)), sl, ei, xcei2)
cxx_ctor_expr in
let updated_cxx_ctor_expr =
update_cxx_construct_expr_tuple
(fun (si, sl, ei, xcei) -> (stmt_info (si.si_pointer + 1), sl, ei, xcei2))
cxx_ctor_expr
in
assert_equal "update_cxx_construct_expr_tuple"
(get_cxx_construct_expr_tuple updated_cxx_ctor_expr)
(Some (stmt_info 2, [], ei, xcei2)) ;
(Some (stmt_info 2, [], ei, xcei2))

@ -1,5 +1,5 @@
(*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
(*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -50,20 +50,42 @@ let gzip ic oc =
let ocz = Gzip.open_out_chan oc in
let buffer = Bytes.create buffer_size in
let rec loop () =
match input ic buffer 0 buffer_size with 0 -> () | r -> Gzip.output ocz buffer 0 r ; loop ()
match input ic buffer 0 buffer_size with
| 0 ->
()
| r ->
Gzip.output ocz buffer 0 r ;
loop ()
in
let success =
try
loop () ;
true
with Gzip.Error _ -> false
in
let success = try loop () ; true with Gzip.Error _ -> false in
Gzip.close_out ocz ; success
Gzip.close_out ocz ;
success
let gunzip ic oc =
let icz = Gzip.open_in_chan ic in
let buffer = Bytes.create buffer_size in
let rec loop () =
match Gzip.input icz buffer 0 buffer_size with 0 -> () | r -> output oc buffer 0 r ; loop ()
match Gzip.input icz buffer 0 buffer_size with
| 0 ->
()
| r ->
output oc buffer 0 r ;
loop ()
in
let success =
try
loop () ;
true
with Gzip.Error _ -> false
in
let success = try loop () ; true with Gzip.Error _ -> false in
Gzip.close_in icz ; success
Gzip.close_in icz ;
success
let copy ic oc = tee ic [oc]
@ -91,21 +113,29 @@ let diff file1 file2 oc = exec [|"diff"; file1; file2|] stdin oc stderr
let fork f =
let fd_in, fd_out = U.pipe () in
match U.fork () with
| 0
-> (
| 0 -> (
U.close fd_in ;
try if f (U.out_channel_of_descr fd_out) then exit 0 else ( close fd_out ; exit 1 )
with _ -> close fd_out ; exit 2 )
try
if f (U.out_channel_of_descr fd_out) then exit 0
else (
close fd_out ;
exit 1 )
with _ ->
close fd_out ;
exit 2 )
| pid ->
if pid < 0 then failwith "fork error"
else ( U.close fd_out ; (pid, U.in_channel_of_descr fd_in) )
else (
U.close fd_out ;
(pid, U.in_channel_of_descr fd_in) )
let compose f g ic oc =
let pid, ic1 = fork (f ic) in
let r1 = g ic1 oc in
let r2 = wait pid in
close_in ic1 ; r1 && r2
close_in ic1 ;
r1 && r2
let diff_on_same_input f1 f2 ic oc =
@ -122,4 +152,7 @@ let diff_on_same_input f1 f2 ic oc =
close_out ofile1 ;
close_out ofile2 ;
let success = if r1 && r2 then diff file1 file2 oc else false in
U.unlink file ; U.unlink file1 ; U.unlink file2 ; success
U.unlink file ;
U.unlink file1 ;
U.unlink file2 ;
success

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -30,9 +30,15 @@ val gunzip : in_channel -> out_channel -> bool
val fork : (out_channel -> bool) -> int * in_channel
val compose :
(in_channel -> out_channel -> bool) -> (in_channel -> out_channel -> bool) -> in_channel
-> out_channel -> bool
(in_channel -> out_channel -> bool)
-> (in_channel -> out_channel -> bool)
-> in_channel
-> out_channel
-> bool
val diff_on_same_input :
(in_channel -> out_channel -> bool) -> (in_channel -> out_channel -> bool) -> in_channel
-> out_channel -> bool
(in_channel -> out_channel -> bool)
-> (in_channel -> out_channel -> bool)
-> in_channel
-> out_channel
-> bool

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -14,6 +14,12 @@ let main =
true )
in
let zipunzip = compose gzip gunzip in
ignore (diff_on_same_input (fun ic oc -> copy ic oc ; flush_all () ; true) zipunzip ic stderr) ;
ignore
(diff_on_same_input
(fun ic oc ->
copy ic oc ;
flush_all () ;
true )
zipunzip ic stderr) ;
close_in ic ;
ignore (wait pid)

@ -1712,15 +1712,15 @@ TranslationUnitDecl None:None:None None:None:None
ParmVarDecl tests/FoundationStub.h:52:13 tests/FoundationStub.h:52:13
FunctionDecl tests/FoundationStub.h:52:1 tests/FoundationStub.h:52:34
ParmVarDecl tests/FoundationStub.h:52:19 tests/FoundationStub.h:52:28
RecordDecl tests/ObjCBridgeTransferTest.m:3:9 tests/ObjCBridgeTransferTest.m:4:1
TypedefDecl tests/ObjCBridgeTransferTest.m:3:1 tests/ObjCBridgeTransferTest.m:4:3
ObjCInterfaceDecl tests/ObjCBridgeTransferTest.m:6:1 tests/ObjCBridgeTransferTest.m:7:2
FunctionDecl tests/ObjCBridgeTransferTest.m:9:1 tests/ObjCBridgeTransferTest.m:9:27
ObjCInterfaceDecl tests/ObjCBridgeTransferTest.m:11:1 tests/ObjCBridgeTransferTest.m:12:2
ObjCImplementationDecl tests/ObjCBridgeTransferTest.m:14:1 tests/ObjCBridgeTransferTest.m:20:1
ObjCMethodDecl tests/ObjCBridgeTransferTest.m:16:1 tests/ObjCBridgeTransferTest.m:18:1
ImplicitParamDecl tests/ObjCBridgeTransferTest.m:18:1 tests/ObjCBridgeTransferTest.m:18:1
ImplicitParamDecl tests/ObjCBridgeTransferTest.m:18:1 tests/ObjCBridgeTransferTest.m:18:1
RecordDecl tests/ObjCBridgeTransferTest.m:10:9 tests/ObjCBridgeTransferTest.m:11:1
TypedefDecl tests/ObjCBridgeTransferTest.m:10:1 tests/ObjCBridgeTransferTest.m:11:3
ObjCInterfaceDecl tests/ObjCBridgeTransferTest.m:13:1 tests/ObjCBridgeTransferTest.m:14:2
FunctionDecl tests/ObjCBridgeTransferTest.m:16:1 tests/ObjCBridgeTransferTest.m:16:27
ObjCInterfaceDecl tests/ObjCBridgeTransferTest.m:18:1 tests/ObjCBridgeTransferTest.m:19:2
ObjCImplementationDecl tests/ObjCBridgeTransferTest.m:21:1 tests/ObjCBridgeTransferTest.m:27:1
ObjCMethodDecl tests/ObjCBridgeTransferTest.m:23:1 tests/ObjCBridgeTransferTest.m:25:1
ImplicitParamDecl tests/ObjCBridgeTransferTest.m:25:1 tests/ObjCBridgeTransferTest.m:25:1
ImplicitParamDecl tests/ObjCBridgeTransferTest.m:25:1 tests/ObjCBridgeTransferTest.m:25:1
CompoundStmt
DeclStmt
ExprWithCleanups
@ -1729,14 +1729,14 @@ TranslationUnitDecl None:None:None None:None:None
CallExpr
ImplicitCastExpr
DeclRefExpr
VarDecl tests/ObjCBridgeTransferTest.m:17:3 tests/ObjCBridgeTransferTest.m:17:65
VarDecl tests/ObjCBridgeTransferTest.m:24:3 tests/ObjCBridgeTransferTest.m:24:65
ExprWithCleanups
ImplicitCastExpr
ObjCBridgedCastExpr
CallExpr
ImplicitCastExpr
DeclRefExpr
TypedefDecl tests/ObjCBridgeTransferTest.m:17:51 tests/ObjCBridgeTransferTest.m:17:51
TypedefDecl tests/ObjCBridgeTransferTest.m:24:51 tests/ObjCBridgeTransferTest.m:24:51
12 0 84
TranslationUnitDecl None:None:None None:None:None
TypedefDecl None:None:None None:None:None

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -17,10 +17,12 @@ let open_out name = if name = "-" then stdout else Pervasives.open_out name
let make_cached f =
let h = H.create 10 in
function
| x ->
try H.find h x with Not_found ->
let y = f x in
H.add h x y ; y
| x -> (
try H.find h x
with Not_found ->
let y = f x in
H.add h x y ;
y )
(* missing string API *)
@ -87,7 +89,8 @@ let stream_concat streams =
current_stream := Some stream ;
stream
in
try Some (Stream.next stream) with Stream.Failure ->
try Some (Stream.next stream)
with Stream.Failure ->
current_stream := None ;
next i
with Stream.Failure -> None
@ -149,9 +152,11 @@ module DisjointSet = struct
let create () = Hashtbl.create 10
let bucket t x =
try Hashtbl.find t x with Not_found ->
try Hashtbl.find t x
with Not_found ->
let b = {parent= x; rank= 0} in
Hashtbl.add t x b ; b
Hashtbl.add t x b ;
b
let rec find_bucket t x =

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -39,7 +39,11 @@ let () =
let () =
let pid, ic = Process.fork (fun oc -> output_string oc "foo\nbar\n" ; true) in
let pid, ic =
Process.fork (fun oc ->
output_string oc "foo\nbar\n" ;
true )
in
let lines = stream_to_list (line_stream_of_channel ic) in
assert_true "line_stream_of_channel::wait" (Process.wait pid) ;
assert_equal "line_stream_of_channel::result" lines ["foo"; "bar"]

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -11,10 +11,8 @@ module P = Process
(* Needed as a (pointer-stable) default value for atd specs. *)
let empty_string = ""
let ydump ?(compact_json= false) ?(std_json= false) ic oc =
let cmd =
["ydump"] @ (if compact_json then ["-c"] else []) @ if std_json then ["-std"] else []
in
let ydump ?(compact_json = false) ?(std_json = false) ic oc =
let cmd = ["ydump"] @ (if compact_json then ["-c"] else []) @ if std_json then ["-std"] else [] in
P.exec (Array.of_list cmd) ic oc stderr
@ -35,18 +33,28 @@ let read_data_from_file reader fname =
else if U.string_ends_with fname ".value" then Marshal.from_channel ic
else Atdgen_runtime.Util.Json.from_channel ~fname reader ic
in
close_in ic ; data
close_in ic ;
data
let write_data_to_file ?(pretty= false) ?(compact_json= false) ?(std_json= false) writer fname data =
let write_data_to_file ?(pretty = false) ?(compact_json = false) ?(std_json = false) writer fname
data =
let output_gzipped write_data oc data =
let pid, icz = P.fork (fun ocz -> write_data ocz data ; true) in
let pid, icz =
P.fork (fun ocz ->
write_data ocz data ;
true )
in
let r1 = P.gzip icz oc and r2 = P.wait pid in
P.close_in icz ;
if not (r1 && r2) then failwith "write_data_to_file (gzip)" else ()
and output_pretty write_data oc data =
(* TODO(mathieubaudet): find out how to write directly pretty json? *)
let pid, icp = P.fork (fun ocp -> write_data ocp data ; true) in
let pid, icp =
P.fork (fun ocp ->
write_data ocp data ;
true )
in
let r1 = ydump ~compact_json ~std_json icp oc and r2 = P.wait pid in
P.close_in icp ;
if not (r1 && r2) then failwith "write_data_to_file (pretty)" else ()
@ -64,20 +72,17 @@ let write_data_to_file ?(pretty= false) ?(compact_json= false) ?(std_json= false
close_out oc
let convert ?(pretty= false) ?(compact_json= false) ?(std_json= false) reader writer fin fout =
let convert ?(pretty = false) ?(compact_json = false) ?(std_json = false) reader writer fin fout =
try
read_data_from_file reader fin
|> write_data_to_file writer ~pretty ~compact_json ~std_json fout
with
| Yojson.Json_error s | Atdgen_runtime.Oj_run.Error s ->
prerr_string s ; prerr_newline () ; exit 1
read_data_from_file reader fin |> write_data_to_file writer ~pretty ~compact_json ~std_json fout
with Yojson.Json_error s | Atdgen_runtime.Oj_run.Error s ->
prerr_string s ;
prerr_newline () ;
exit 1
let run_converter_tool reader writer =
let pretty = ref false
and std_json = ref false
and compact_json = ref false
and files = ref [] in
let pretty = ref false and std_json = ref false and compact_json = ref false and files = ref [] in
let add_files x = files := x :: !files
and usage_msg =
"Usage: " ^ Sys.argv.(0) ^ "[OPTIONS] INPUT_FILE [OUTPUT_FILE]\n"
@ -89,7 +94,8 @@ let run_converter_tool reader writer =
[ ("--pretty", Arg.Set pretty, " Pretty print outputs.")
; ("--std", Arg.Set std_json, " Use standard json for outputs.")
; ("--compact", Arg.Set compact_json, " Use compact json for outputs.")
; ("--", Arg.Rest add_files, " Mark the end of options.") ] usage_msg
; ("--", Arg.Rest add_files, " Mark the end of options.") ]
usage_msg
in
(* Parse the command line. *)
Arg.parse spec add_files usage_msg ;
@ -100,7 +106,7 @@ let run_converter_tool reader writer =
| [input; output] ->
(input, output)
| _ ->
prerr_string usage_msg ; exit 1
prerr_string usage_msg ;
exit 1
in
convert ~pretty:!pretty ~std_json:!std_json ~compact_json:!compact_json reader writer input
output
convert ~pretty:!pretty ~std_json:!std_json ~compact_json:!compact_json reader writer input output

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -8,8 +8,13 @@
val read_data_from_file : 'a Atdgen_runtime.Util.Json.reader -> string -> 'a
val write_data_to_file :
?pretty:bool -> ?compact_json:bool -> ?std_json:bool -> 'a Atdgen_runtime.Util.Json.writer
-> string -> 'a -> unit
?pretty:bool
-> ?compact_json:bool
-> ?std_json:bool
-> 'a Atdgen_runtime.Util.Json.writer
-> string
-> 'a
-> unit
val ydump : ?compact_json:bool -> ?std_json:bool -> in_channel -> out_channel -> bool

@ -1,5 +1,5 @@
(*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2014-present, Facebook, Inc.
# 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.
@ -174,9 +174,9 @@ if [ "$SEQUENTIAL_LINK" = "yes" ]; then
fi
# For Ninja, the compile jobs is the number of CPUs *not* $JOBS
CMAKE_ARGS+=(
-DCMAKE_JOB_POOLS:STRING="compile=$NCPUS;link=1"
-DCMAKE_JOB_POOL_COMPILE:STRING="compile"
-DCMAKE_JOB_POOL_LINK:STRING="link"
-DCMAKE_JOB_POOLS:STRING="compile=$NCPUS;link=1"
-DCMAKE_JOB_POOL_COMPILE:STRING="compile"
-DCMAKE_JOB_POOL_LINK:STRING="link"
)
fi

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,4 +1,4 @@
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
@ -160,8 +160,8 @@ class SimplePluginASTActionBase : public clang::PluginASTAction {
case clang::InputKind::Unknown:
case clang::InputKind::Asm:
case clang::InputKind::LLVM_IR:
// We can't do anything with these - they may trigger errors when running
// clang frontend
// We can't do anything with these - they may trigger errors when
// running clang frontend
return false;
default:
// run the consumer for IK_AST and all others

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,4 +1,4 @@
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,6 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,6 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2015-present, Facebook, Inc.
# 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,3 +1,9 @@
(*
* 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.
*)
type @ObjCExpression@ = {}
type x@@yz = {

@ -1,5 +1,5 @@
#/bin/bash
# Copyright (c) 2015-present, Facebook, Inc.
# 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
#/bin/bash
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
#/bin/bash
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-present, Facebook, Inc.
* 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.

@ -1,4 +1,4 @@
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

Loading…
Cancel
Save