From e495a819427fc23d26b82cdcd5c24d040b09c51d Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Mon, 11 Apr 2016 07:46:33 -0700 Subject: [PATCH] Remove parent_dec from translate_one_decl Summary:public This information is no longer needed - ASTExporter always exports pointer to parent for C++/objC methods. This code is from time it was not true. Reviewed By: jvillard Differential Revision: D3162455 fb-gh-sync-id: 35570da fbshipit-source-id: 35570da --- infer/src/clang/cFrontend.ml | 2 +- infer/src/clang/cFrontend_decl.ml | 17 ++++++++--------- infer/src/clang/cFrontend_decl.mli | 2 +- infer/src/clang/cModule_type.ml | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index 2b74ad92b..4d6112b8b 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -25,7 +25,7 @@ let compute_icfg tenv ast = Printing.log_out "\n Start creating icfg\n"; let cg = Cg.create () in let cfg = Cfg.Node.create_cfg () in - IList.iter (CFrontend_declImpl.translate_one_declaration tenv cg cfg ast) decl_list; + IList.iter (CFrontend_declImpl.translate_one_declaration tenv cg cfg) decl_list; Printing.log_out "\n Finished creating icfg\n"; (cg, cfg) | _ -> assert false (* NOTE: Assumes that an AST alsways starts with a TranslationUnitDecl *) diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 8695ba64f..f1f7d6631 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -18,7 +18,7 @@ module type CFrontend_decl = sig CModule_type.block_data option -> unit val translate_one_declaration : - Tenv.t -> Cg.t -> Cfg.cfg -> Clang_ast_t.decl -> Clang_ast_t.decl -> unit + Tenv.t -> Cg.t -> Cfg.cfg -> Clang_ast_t.decl -> unit end module CFrontend_decl_funct(T: CModule_type.CTranslation) : CFrontend_decl = @@ -127,7 +127,7 @@ struct translate_location || always_translate_decl (* Translate one global declaration *) - let rec translate_one_declaration tenv cg cfg parent_dec dec = + let rec translate_one_declaration tenv cg cfg dec = let open Clang_ast_t in (* Run the frontend checkers on this declaration *) CFrontend_errors.run_frontend_checkers_on_decl tenv cg cfg dec; @@ -175,12 +175,11 @@ struct | CXXConversionDecl (decl_info, _, _, _, _) | CXXDestructorDecl (decl_info, _, _, _, _) -> (* di_parent_pointer has pointer to lexical context such as class.*) - (* If it's not defined, then it's the same as parent in AST *) let class_decl = match decl_info.Clang_ast_t.di_parent_pointer with | Some ptr -> Ast_utils.get_decl ptr | None -> - Some parent_dec in + assert false in (match class_decl with | Some (CXXRecordDecl _ as d) | Some (ClassTemplateSpecializationDecl _ as d) -> @@ -203,19 +202,19 @@ struct true | _ -> false in let method_decls, no_method_decls = IList.partition is_method_decl decl_list in - IList.iter (translate_one_declaration tenv cg cfg dec) no_method_decls; + IList.iter (translate_one_declaration tenv cg cfg) no_method_decls; ignore (CTypes_decl.add_types_from_decl_to_tenv tenv dec); - IList.iter (translate_one_declaration tenv cg cfg dec) method_decls + IList.iter (translate_one_declaration tenv cg cfg) method_decls | EnumDecl _ -> ignore (CEnum_decl.enum_decl dec) | LinkageSpecDecl (_, decl_list, _) -> Printing.log_out "ADDING: LinkageSpecDecl decl list\n"; - IList.iter (translate_one_declaration tenv cg cfg dec) decl_list + IList.iter (translate_one_declaration tenv cg cfg) decl_list | NamespaceDecl (_, _, decl_list, _, _) -> - IList.iter (translate_one_declaration tenv cg cfg dec) decl_list + IList.iter (translate_one_declaration tenv cg cfg) decl_list | ClassTemplateDecl (_, _, template_decl_info) | FunctionTemplateDecl (_, _, template_decl_info) -> let decl_list = template_decl_info.Clang_ast_t.tdi_specializations in - IList.iter (translate_one_declaration tenv cg cfg dec) decl_list + IList.iter (translate_one_declaration tenv cg cfg) decl_list | _ -> () end diff --git a/infer/src/clang/cFrontend_decl.mli b/infer/src/clang/cFrontend_decl.mli index 1ffaa9104..4c0f86aac 100644 --- a/infer/src/clang/cFrontend_decl.mli +++ b/infer/src/clang/cFrontend_decl.mli @@ -14,7 +14,7 @@ module type CFrontend_decl = sig CModule_type.block_data option -> unit val translate_one_declaration : Tenv.t -> Cg.t -> Cfg.cfg -> - Clang_ast_t.decl -> Clang_ast_t.decl -> unit + Clang_ast_t.decl -> unit end module CFrontend_decl_funct(T: CModule_type.CTranslation) : CFrontend_decl diff --git a/infer/src/clang/cModule_type.ml b/infer/src/clang/cModule_type.ml index c30c6423e..d6ad2a957 100644 --- a/infer/src/clang/cModule_type.ml +++ b/infer/src/clang/cModule_type.ml @@ -25,5 +25,5 @@ module type CFrontend = sig block_data option -> unit val translate_one_declaration : Tenv.t -> Cg.t -> Cfg.cfg -> - Clang_ast_t.decl -> Clang_ast_t.decl -> unit + Clang_ast_t.decl -> unit end