diff --git a/infer/src/clang/Makefile b/infer/src/clang/Makefile deleted file mode 100644 index edfffe515..000000000 --- a/infer/src/clang/Makefile +++ /dev/null @@ -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) diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index fd9148cfc..ea4295e8a 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -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 Cg.store_to_file cg_file call_graph; 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; Tenv.store_to_file tenv_file tenv; if Config.stats_mode then Cfg.check_cfg_connectedness cfg; diff --git a/infer/src/clang/cFrontend_checkers.ml b/infer/src/clang/cFrontend_checkers.ml index ad2c4bd78..4100814c2 100644 --- a/infer/src/clang/cFrontend_checkers.ml +++ b/infer/src/clang/cFrontend_checkers.ml @@ -70,7 +70,7 @@ let iphoneos_target_sdk_version _ = let available_ios_sdk an = match CTL.next_state_via_transition an (Some CTL.PointerToDecl) with | 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 | None -> "") | _ -> 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 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)) -> - Predicates.captured_variables_cxx_ref d + CPredicates.captured_variables_cxx_ref d | _ -> [] in let var_desc vars var_named_decl_info = vars ^ "'" ^ var_named_decl_info.Clang_ast_t.ni_name ^ "'" in diff --git a/infer/src/clang/predicates.ml b/infer/src/clang/cPredicates.ml similarity index 100% rename from infer/src/clang/predicates.ml rename to infer/src/clang/cPredicates.ml diff --git a/infer/src/clang/predicates.mli b/infer/src/clang/cPredicates.mli similarity index 100% rename from infer/src/clang/predicates.mli rename to infer/src/clang/cPredicates.mli diff --git a/infer/src/clang/cTL.ml b/infer/src/clang/cTL.ml index 371dbafc0..d451da288 100644 --- a/infer/src/clang/cTL.ml +++ b/infer/src/clang/cTL.ml @@ -30,7 +30,7 @@ type transitions = type t = (* A ctl formula *) | True | False (* not really necessary but it makes it evaluation faster *) - | Atomic of Predicates.t + | Atomic of CPredicates.t | Not of t | And of t * t | Or of t * t @@ -72,7 +72,7 @@ module Debug = struct match phi with | True -> Format.fprintf fmt "True" | 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 else Format.fprintf fmt "NOT(...)" | 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) *) let rec eval_Atomic pred_name args an lcxt = 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 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 *) | "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 - | "is_objc_extension", [], _ -> Predicates.is_objc_extension lcxt - | "is_global_var", [], Decl d -> Predicates.is_syntactically_global_var d + | "is_objc_extension", [], _ -> CPredicates.is_objc_extension lcxt + | "is_global_var", [], Decl d -> CPredicates.is_syntactically_global_var d | "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 - | "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 - | "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_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_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 - | "context_in_synchronized_block", [], _ -> Predicates.context_in_synchronized_block lcxt - | "is_ivar_atomic", [], Stmt st -> Predicates.is_ivar_atomic st + | "context_in_synchronized_block", [], _ -> CPredicates.context_in_synchronized_block lcxt + | "is_ivar_atomic", [], Stmt st -> CPredicates.is_ivar_atomic st | "is_ivar_atomic", _, Decl _ -> false | "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_objc_constructor", [], _ -> Predicates.is_objc_constructor lcxt - | "is_objc_dealloc", [], _ -> Predicates.is_objc_dealloc lcxt - | "captures_cxx_references", [], Decl d -> Predicates.captures_cxx_references d + | "is_objc_constructor", [], _ -> CPredicates.is_objc_constructor lcxt + | "is_objc_dealloc", [], _ -> CPredicates.is_objc_dealloc lcxt + | "captures_cxx_references", [], Decl d -> CPredicates.captures_cxx_references d | "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_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 - | "in_node", [nodename], Stmt st -> Predicates.is_stmt nodename st - | "in_node", [nodename], Decl d -> Predicates.is_decl nodename d - | "isa", [classname], Stmt st -> Predicates.isa classname st + | "in_node", [nodename], Stmt st -> CPredicates.is_stmt nodename st + | "in_node", [nodename], Decl d -> CPredicates.is_decl nodename d + | "isa", [classname], Stmt st -> CPredicates.isa classname st | "isa", _, Decl _ -> false | "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 | _ -> failwith ("ERROR: Undefined Predicate or wrong set of arguments: " ^ pred_name) diff --git a/infer/src/clang/cTL.mli b/infer/src/clang/cTL.mli index ef75252ae..3615e61fa 100644 --- a/infer/src/clang/cTL.mli +++ b/infer/src/clang/cTL.mli @@ -30,7 +30,7 @@ type transitions = type t = | True | False - | Atomic of Predicates.t (** Atomic formula *) + | Atomic of CPredicates.t (** Atomic formula *) | Not of t | And of t * t | Or of t * t diff --git a/infer/src/clang/printing.ml b/infer/src/clang/printing.ml deleted file mode 100644 index a80e241d6..000000000 --- a/infer/src/clang/printing.ml +++ /dev/null @@ -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 diff --git a/infer/src/clang/printing.mli b/infer/src/clang/printing.mli deleted file mode 100644 index 633bc141f..000000000 --- a/infer/src/clang/printing.mli +++ /dev/null @@ -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