[clang] Minor clang frontend cleanup: remove dead code and renaming

Summary: Removed unused files and renamed for consistency.

Reviewed By: jvillard

Differential Revision: D4397546

fbshipit-source-id: 85eb86d
master
Cristiano Calcagno 8 years ago committed by Facebook Github Bot
parent f605cb4b7e
commit af83d1eefe

@ -1,19 +0,0 @@
REMOVE = rm -vf
EXAMPLE_SOURCES = test.c
EXAMPLE_AST = test.ast
.PHONY: lib
all: $(EXAMPLE_AST)
lib:
ocamlbuild -I backend cMain.cma
$(EXAMPLE_AST): $(EXAMPLE_SOURCES)
clang -cc1 -ast-dump test.c > test.ast
clean:
ocamlbuild -clean
$(REMOVE) *~ $(EXAMPLE_AST)

@ -57,9 +57,6 @@ let do_source_file translation_unit_context ast =
let cg_file = DB.source_dir_get_internal_file source_dir ".cg" in let cg_file = DB.source_dir_get_internal_file source_dir ".cg" in
Cg.store_to_file cg_file call_graph; Cg.store_to_file cg_file call_graph;
Cfg.store_cfg_to_file ~source_file cfg_file cfg; Cfg.store_cfg_to_file ~source_file cfg_file cfg;
(*Logging.out "Tenv %a@." Sil.pp_tenv tenv;*)
(* Printing.print_tenv tenv; *)
(*Printing.print_procedures cfg; *)
CGeneral_utils.sort_fields_tenv tenv; CGeneral_utils.sort_fields_tenv tenv;
Tenv.store_to_file tenv_file tenv; Tenv.store_to_file tenv_file tenv;
if Config.stats_mode then Cfg.check_cfg_connectedness cfg; if Config.stats_mode then Cfg.check_cfg_connectedness cfg;

@ -70,7 +70,7 @@ let iphoneos_target_sdk_version _ =
let available_ios_sdk an = let available_ios_sdk an =
match CTL.next_state_via_transition an (Some CTL.PointerToDecl) with match CTL.next_state_via_transition an (Some CTL.PointerToDecl) with
| Some CTL.Decl decl -> | Some CTL.Decl decl ->
(match Predicates.get_available_attr_ios_sdk decl with (match CPredicates.get_available_attr_ios_sdk decl with
| Some version -> version | Some version -> version
| None -> "") | None -> "")
| _ -> failwith("available_ios_sdk must be called with a DeclRefExpr \ | _ -> failwith("available_ios_sdk must be called with a DeclRefExpr \
@ -90,9 +90,9 @@ let ivar_name an =
let cxx_ref_captured_in_block an = let cxx_ref_captured_in_block an =
let capt_refs = match an with let capt_refs = match an with
| CTL.Decl d -> Predicates.captured_variables_cxx_ref d | CTL.Decl d -> CPredicates.captured_variables_cxx_ref d
| CTL.Stmt (Clang_ast_t.BlockExpr(_, _, _, d)) -> | CTL.Stmt (Clang_ast_t.BlockExpr(_, _, _, d)) ->
Predicates.captured_variables_cxx_ref d CPredicates.captured_variables_cxx_ref d
| _ -> [] in | _ -> [] in
let var_desc vars var_named_decl_info = let var_desc vars var_named_decl_info =
vars ^ "'" ^ var_named_decl_info.Clang_ast_t.ni_name ^ "'" in vars ^ "'" ^ var_named_decl_info.Clang_ast_t.ni_name ^ "'" in

@ -30,7 +30,7 @@ type transitions =
type t = (* A ctl formula *) type t = (* A ctl formula *)
| True | True
| False (* not really necessary but it makes it evaluation faster *) | False (* not really necessary but it makes it evaluation faster *)
| Atomic of Predicates.t | Atomic of CPredicates.t
| Not of t | Not of t
| And of t * t | And of t * t
| Or of t * t | Or of t * t
@ -72,7 +72,7 @@ module Debug = struct
match phi with match phi with
| True -> Format.fprintf fmt "True" | True -> Format.fprintf fmt "True"
| False -> Format.fprintf fmt "False" | False -> Format.fprintf fmt "False"
| Atomic p -> Predicates.pp_predicate fmt p | Atomic p -> CPredicates.pp_predicate fmt p
| Not phi -> if full_print then Format.fprintf fmt "NOT(%a)" pp_formula phi | Not phi -> if full_print then Format.fprintf fmt "NOT(%a)" pp_formula phi
else Format.fprintf fmt "NOT(...)" else Format.fprintf fmt "NOT(...)"
| And (phi1, phi2) -> if full_print then | And (phi1, phi2) -> if full_print then
@ -375,46 +375,46 @@ let next_state_via_transition an trans =
linter context lcxt. That is: an, lcxt |= pred_name(params) *) linter context lcxt. That is: an, lcxt |= pred_name(params) *)
let rec eval_Atomic pred_name args an lcxt = let rec eval_Atomic pred_name args an lcxt =
match pred_name, args, an with match pred_name, args, an with
| "call_method", [m], Stmt st -> Predicates.call_method m st | "call_method", [m], Stmt st -> CPredicates.call_method m st
(* Note: I think it should be better to change all predicated to be (* Note: I think it should be better to change all predicated to be
evaluated in a node an. The predicate itself should decide if it's a evaluated in a node an. The predicate itself should decide if it's a
stmt or decl predicate and return false for an unappropriate node *) stmt or decl predicate and return false for an unappropriate node *)
| "call_method", _, Decl _ -> false | "call_method", _, Decl _ -> false
| "property_name_contains_word", [word], Decl d -> Predicates.property_name_contains_word word d | "property_name_contains_word", [word], Decl d -> CPredicates.property_name_contains_word word d
| "property_name_contains_word", _, Stmt _ -> false | "property_name_contains_word", _, Stmt _ -> false
| "is_objc_extension", [], _ -> Predicates.is_objc_extension lcxt | "is_objc_extension", [], _ -> CPredicates.is_objc_extension lcxt
| "is_global_var", [], Decl d -> Predicates.is_syntactically_global_var d | "is_global_var", [], Decl d -> CPredicates.is_syntactically_global_var d
| "is_global_var", _, Stmt _ -> false | "is_global_var", _, Stmt _ -> false
| "is_const_var", [], Decl d -> Predicates.is_const_expr_var d | "is_const_var", [], Decl d -> CPredicates.is_const_expr_var d
| "is_const_var", _, Stmt _ -> false | "is_const_var", _, Stmt _ -> false
| "call_function_named", args, Stmt st -> Predicates.call_function_named args st | "call_function_named", args, Stmt st -> CPredicates.call_function_named args st
| "call_function_named", _, Decl _ -> false | "call_function_named", _, Decl _ -> false
| "is_strong_property", [], Decl d -> Predicates.is_strong_property d | "is_strong_property", [], Decl d -> CPredicates.is_strong_property d
| "is_strong_property", _, Stmt _ -> false | "is_strong_property", _, Stmt _ -> false
| "is_assign_property", [], Decl d -> Predicates.is_assign_property d | "is_assign_property", [], Decl d -> CPredicates.is_assign_property d
| "is_assign_property", _, Stmt _ -> false | "is_assign_property", _, Stmt _ -> false
| "is_property_pointer_type", [], Decl d -> Predicates.is_property_pointer_type d | "is_property_pointer_type", [], Decl d -> CPredicates.is_property_pointer_type d
| "is_property_pointer_type", _, Stmt _ -> false | "is_property_pointer_type", _, Stmt _ -> false
| "context_in_synchronized_block", [], _ -> Predicates.context_in_synchronized_block lcxt | "context_in_synchronized_block", [], _ -> CPredicates.context_in_synchronized_block lcxt
| "is_ivar_atomic", [], Stmt st -> Predicates.is_ivar_atomic st | "is_ivar_atomic", [], Stmt st -> CPredicates.is_ivar_atomic st
| "is_ivar_atomic", _, Decl _ -> false | "is_ivar_atomic", _, Decl _ -> false
| "is_method_property_accessor_of_ivar", [], Stmt st -> | "is_method_property_accessor_of_ivar", [], Stmt st ->
Predicates.is_method_property_accessor_of_ivar st lcxt CPredicates.is_method_property_accessor_of_ivar st lcxt
| "is_method_property_accessor_of_ivar", _, Decl _ -> false | "is_method_property_accessor_of_ivar", _, Decl _ -> false
| "is_objc_constructor", [], _ -> Predicates.is_objc_constructor lcxt | "is_objc_constructor", [], _ -> CPredicates.is_objc_constructor lcxt
| "is_objc_dealloc", [], _ -> Predicates.is_objc_dealloc lcxt | "is_objc_dealloc", [], _ -> CPredicates.is_objc_dealloc lcxt
| "captures_cxx_references", [], Decl d -> Predicates.captures_cxx_references d | "captures_cxx_references", [], Decl d -> CPredicates.captures_cxx_references d
| "captures_cxx_references", _, Stmt _ -> false | "captures_cxx_references", _, Stmt _ -> false
| "is_binop_with_kind", [str_kind], Stmt st -> Predicates.is_binop_with_kind str_kind st | "is_binop_with_kind", [str_kind], Stmt st -> CPredicates.is_binop_with_kind str_kind st
| "is_binop_with_kind", _, Decl _ -> false | "is_binop_with_kind", _, Decl _ -> false
| "is_unop_with_kind", [str_kind], Stmt st -> Predicates.is_unop_with_kind str_kind st | "is_unop_with_kind", [str_kind], Stmt st -> CPredicates.is_unop_with_kind str_kind st
| "is_unop_with_kind", _, Decl _ -> false | "is_unop_with_kind", _, Decl _ -> false
| "in_node", [nodename], Stmt st -> Predicates.is_stmt nodename st | "in_node", [nodename], Stmt st -> CPredicates.is_stmt nodename st
| "in_node", [nodename], Decl d -> Predicates.is_decl nodename d | "in_node", [nodename], Decl d -> CPredicates.is_decl nodename d
| "isa", [classname], Stmt st -> Predicates.isa classname st | "isa", [classname], Stmt st -> CPredicates.isa classname st
| "isa", _, Decl _ -> false | "isa", _, Decl _ -> false
| "decl_unavailable_in_supported_ios_sdk", [], Decl decl -> | "decl_unavailable_in_supported_ios_sdk", [], Decl decl ->
Predicates.decl_unavailable_in_supported_ios_sdk decl CPredicates.decl_unavailable_in_supported_ios_sdk decl
| "decl_unavailable_in_supported_ios_sdk", _, Stmt _ -> false | "decl_unavailable_in_supported_ios_sdk", _, Stmt _ -> false
| _ -> failwith ("ERROR: Undefined Predicate or wrong set of arguments: " ^ pred_name) | _ -> failwith ("ERROR: Undefined Predicate or wrong set of arguments: " ^ pred_name)

@ -30,7 +30,7 @@ type transitions =
type t = type t =
| True | True
| False | False
| Atomic of Predicates.t (** Atomic formula *) | Atomic of CPredicates.t (** Atomic formula *)
| Not of t | Not of t
| And of t * t | And of t * t
| Or of t * t | Or of t * t

@ -1,71 +0,0 @@
(*
* Copyright (c) 2013 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*)
open! IStd
module L = Logging
module F = Format
let annotation_to_string ((annotation: Annot.t), _) =
"< " ^ annotation.class_name ^ " : " ^
(IList.to_string (fun x -> x) annotation.parameters) ^ " >"
let field_to_string (fieldname, typ, annotation) =
(Ident.fieldname_to_string fieldname) ^ " " ^
(Typ.to_string typ) ^ (IList.to_string annotation_to_string annotation)
let print_tenv tenv =
Tenv.iter (fun typname struct_t ->
match typname with
| Typename.TN_csu (Csu.Class _, _) | Typename.TN_csu (Csu.Protocol, _) ->
Logging.do_out "%s" (
(Typename.to_string typname) ^ " " ^
(Annot.Item.to_string struct_t.annots) ^ "\n" ^
"---> superclass and protocols " ^ (IList.to_string (fun tn ->
"\t" ^ (Typename.to_string tn) ^ "\n") struct_t.supers) ^
"---> methods " ^
(IList.to_string (fun x ->"\t" ^ (Procname.to_string x) ^ "\n") struct_t.methods)
^ " " ^
"\t---> fields " ^ (IList.to_string field_to_string struct_t.fields) ^ "\n")
| _ -> ()
) tenv
let print_tenv_struct_unions tenv =
Tenv.iter (fun typname struct_t ->
match typname with
| Typename.TN_csu (Csu.Struct, _) | Typename.TN_csu (Csu.Union, _) ->
Logging.do_out "%s" (
(Typename.to_string typname)^"\n"^
"\t---> fields "^(IList.to_string (fun (fieldname, typ, _) ->
match typ with
| Typ.Tstruct tname -> "tvar"^(Typename.to_string tname)
| _ ->
"\t struct "^(Ident.fieldname_to_string fieldname)^" "^
(Typ.to_string typ)^"\n") struct_t.fields
)
)
| _ -> ()
) tenv
let print_procedures cfg =
let procs = Cfg.get_all_procs cfg in
Logging.do_out "%s"
(IList.to_string (fun pdesc ->
let pname = Procdesc.get_proc_name pdesc in
"name> "^
(Procname.to_string pname) ^
" defined? " ^ (string_of_bool (Procdesc.is_defined pdesc)) ^ "\n")
procs)
let print_nodes nodes =
IList.iter (fun node -> Logging.do_out "%s" (Procdesc.Node.get_description Pp.text node)) nodes
let instrs_to_string instrs =
let pp fmt = Format.fprintf fmt "%a" (Sil.pp_instr_list Pp.text) instrs in
F.asprintf "%t" pp

@ -1,22 +0,0 @@
(*
* Copyright (c) 2013 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*)
open! IStd
val print_tenv : Tenv.t -> unit
val print_tenv_struct_unions : Tenv.t -> unit
val print_procedures : Cfg.cfg -> unit
val print_nodes : Procdesc.Node.t list -> unit
val instrs_to_string : Sil.instr list -> string
val field_to_string : Ident.fieldname * Typ.t * Annot.Item.t -> string
Loading…
Cancel
Save