Use ints as clang pointers

Summary:
public
Get newest version of facebook-clang-plugin that replaces pointers from strings to ints.
Fix all compilation issues infer has

Reviewed By: jvillard

Differential Revision: D2815144

fb-gh-sync-id: e93d4b3
master
Andrzej Kotulski 9 years ago committed by facebook-github-bot-7
parent 2ff26d37fb
commit df192d06c3

@ -1 +1 @@
Subproject commit cc037603a78b7752f065d88d5aedb135bc4a2bd8
Subproject commit cb65aec893159e2cf4d74ce4dae68f0b3513f065

@ -32,7 +32,7 @@ let fresh_decl_info decl_info =
{ decl_info with Clang_ast_t.di_pointer = Ast_utils.get_fresh_pointer () }
let empty_decl_info = {
Clang_ast_t.di_pointer = "";
Clang_ast_t.di_pointer = Ast_utils.get_invalid_pointer ();
di_parent_pointer = None;
di_previous_decl = `None;
di_source_range = dummy_source_range ();

@ -74,7 +74,8 @@ val make_obj_c_message_expr_info_instance : string -> obj_c_message_expr_info
val translate_dispatch_function : string -> stmt_info -> stmt list -> expr_info -> int -> stmt * type_ptr
val translate_block_enumerate : string -> stmt_info -> stmt list -> expr_info -> stmt * (string * string* type_ptr) list
val translate_block_enumerate : string -> stmt_info -> stmt list -> expr_info ->
stmt * (string * Clang_ast_t.pointer * type_ptr) list
(* We translate the logical negation of an integer with a conditional*)
(* !x <=> x?0:1 *)

@ -110,7 +110,7 @@ struct
let string_of_decl decl =
let name = Clang_ast_proj.get_decl_kind_string decl in
let info = Clang_ast_proj.get_decl_tuple decl in
"<\"" ^ name ^ "\"> '" ^ info.Clang_ast_t.di_pointer ^ "'"
Printf.sprintf "<\"%s\"> '%d'" name info.Clang_ast_t.di_pointer
let string_of_unary_operator_kind = function
| `PostInc -> "PostInc"
@ -131,7 +131,7 @@ struct
let string_of_stmt stmt =
let name = Clang_ast_proj.get_stmt_kind_string stmt in
let info, _ = Clang_ast_proj.get_stmt_tuple stmt in
"<\"" ^ name ^ "\"> '" ^ info.Clang_ast_t.si_pointer ^ "'"
Printf.sprintf "<\"%s\"> '%d'" name info.Clang_ast_t.si_pointer
let get_stmts_from_stmt stmt =
let open Clang_ast_t in
@ -277,10 +277,10 @@ struct
let get_fresh_pointer () =
pointer_counter := !pointer_counter + 1;
let internal_pointer = -(!pointer_counter) in
string_of_int internal_pointer
internal_pointer
let get_invalid_pointer () =
string_of_int CFrontend_config.invalid_pointer
CFrontend_config.invalid_pointer
let type_from_unary_expr_or_type_trait_expr_info info =
match info.Clang_ast_t.uttei_type_ptr with
@ -290,7 +290,7 @@ struct
let get_decl decl_ptr =
try
Some (Clang_ast_main.PointerMap.find decl_ptr !CFrontend_config.pointer_decl_index)
with Not_found -> Printing.log_stats "decl with pointer %s not found\n" decl_ptr; None
with Not_found -> Printing.log_stats "decl with pointer %d not found\n" decl_ptr; None
let get_decl_opt decl_ptr_opt =
match decl_ptr_opt with
@ -329,7 +329,7 @@ struct
(let raw_ptr = Clang_ast_types.type_ptr_to_clang_pointer type_ptr in
try
Some (Clang_ast_main.PointerMap.find raw_ptr !CFrontend_config.pointer_type_index)
with Not_found -> Printing.log_stats "type with pointer %s not found\n" raw_ptr; None)
with Not_found -> Printing.log_stats "type with pointer %d not found\n" raw_ptr; None)
with Clang_ast_types.Not_Clang_Pointer ->
(* otherwise, function fails *)
let type_str = Clang_ast_types.type_ptr_to_string type_ptr in

@ -64,9 +64,9 @@ sig
val is_type_nullable : Clang_ast_t.type_ptr -> bool
val get_fresh_pointer : unit -> string
val get_fresh_pointer : unit -> Clang_ast_t.pointer
val get_invalid_pointer : unit -> string
val get_invalid_pointer : unit -> Clang_ast_t.pointer
val type_from_unary_expr_or_type_trait_expr_info :
Clang_ast_t.unary_expr_or_type_trait_expr_info -> Clang_ast_t.type_ptr option

@ -419,8 +419,9 @@ let get_method_for_frontend_checks cfg cg tenv class_name decl_info =
match Cfg.Procdesc.find_from_name cfg proc_name with
| Some pdesc -> pdesc
| None ->
let ms = CMethod_signature.make_ms proc_name [] (Clang_ast_types.pointer_to_type_ptr "-1")
[] source_range false CFrontend_config.OBJC None None in
let ms_type_ptr = Clang_ast_types.pointer_to_type_ptr (Ast_utils.get_invalid_pointer ()) in
let ms = CMethod_signature.make_ms proc_name [] ms_type_ptr [] source_range false
CFrontend_config.OBJC None None in
let body = [Clang_ast_t.CompoundStmt (stmt_info, [])] in
ignore (create_local_procdesc cfg tenv ms body [] false);
let pdesc = Option.get (Cfg.Procdesc.find_from_name cfg proc_name) in

@ -472,7 +472,7 @@ struct
| _ ->
let print_error decl_kind =
Printing.log_stats
"Warning: Decl ref expression %s with pointer %s still needs to be translated "
"Warning: Decl ref expression %s with pointer %d still needs to be translated "
(Clang_ast_j.string_of_decl_kind decl_kind)
decl_ref.Clang_ast_t.dr_decl_pointer in
print_error decl_kind; assert false
@ -1829,7 +1829,7 @@ struct
let stmt_kind = Clang_ast_proj.get_stmt_kind_string instr in
let stmt_info, _ = Clang_ast_proj.get_stmt_tuple instr in
let stmt_pointer = stmt_info.Clang_ast_t.si_pointer in
Printing.log_out "\nPassing from %s '%s' \n" stmt_kind stmt_pointer;
Printing.log_out "\nPassing from %s '%d' \n" stmt_kind stmt_pointer;
let open Clang_ast_t in
match instr with
| GotoStmt(stmt_info, _, { Clang_ast_t.gsi_label = label_name; _ }) ->

@ -127,7 +127,7 @@ let mk_cond_continuation cont =
type priority_node =
| Free
| Busy of string
| Busy of Clang_ast_t.pointer
(* A translation state. It provides the translation function with the info*)
(* it need to carry on the tranlsation. *)
@ -192,11 +192,12 @@ struct
let try_claim_priority_node trans_state stmt_info =
match trans_state.priority with
| Free ->
Printing.log_out "Priority is free. Locking priority node in %s\n@."
Printing.log_out "Priority is free. Locking priority node in %d\n@."
stmt_info.Clang_ast_t.si_pointer;
{ trans_state with priority = Busy stmt_info.Clang_ast_t.si_pointer }
| _ ->
Printing.log_out "Priority busy in %s. No claim possible\n@." stmt_info.Clang_ast_t.si_pointer;
Printing.log_out "Priority busy in %d. No claim possible\n@."
stmt_info.Clang_ast_t.si_pointer;
trans_state
let force_claim_priority_node trans_state stmt_info =

@ -17,7 +17,7 @@ type continuation = {
type priority_node =
| Free
| Busy of string
| Busy of Clang_ast_t.pointer
type trans_state = {
context: CContext.t;

@ -16,8 +16,7 @@ open CFrontend_utils
module L = Logging
let is_custom_var_pointer pointer =
let pointer_int = int_of_string pointer in
pointer_int <= 0
pointer <= 0
let is_captured procdesc vname =
IList.exists

@ -17,12 +17,12 @@
exception Not_Clang_Pointer
type t_ptr = [
| `TPtr of string
| `Prebuilt of string
| `TPtr of int
| `Prebuilt of int
| `PointerOf of t_ptr
| `ClassType of string
| `StructType of string
| `DeclPtr of string
| `DeclPtr of int
| `ErrorType]
module TypePointerOrd = struct
@ -33,12 +33,12 @@ end
module TypePointerMap = Map.Make(TypePointerOrd)
let rec type_ptr_to_string type_ptr = match type_ptr with
| `TPtr raw -> "clang_ptr_" ^ raw
| `Prebuilt raw -> "prebuilt_" ^ raw
| `TPtr raw -> "clang_ptr_" ^ (string_of_int raw)
| `Prebuilt raw -> "prebuilt_" ^ (string_of_int raw)
| `PointerOf typ -> "pointer_of_" ^ type_ptr_to_string typ
| `ClassType name -> "class_name_" ^ name
| `StructType name -> "struct_name_" ^ name
| `DeclPtr raw -> "decl_ptr_" ^ raw
| `DeclPtr raw -> "decl_ptr_" ^ (string_of_int raw)
| `ErrorType -> "error_type"
let type_ptr_to_clang_pointer type_ptr = match type_ptr with
@ -49,4 +49,4 @@ let pointer_to_type_ptr raw = `TPtr raw
let type_ptr_to_pointer type_ptr = match type_ptr with
| `TPtr raw -> raw
| _ -> "custom_type_" ^ (type_ptr_to_string type_ptr)
| _ -> 0 (* invalid pointer *)

Loading…
Cancel
Save