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
master
Andrzej Kotulski 9 years ago committed by Facebook Github Bot 0
parent a5041d3f8e
commit e495a81942

@ -25,7 +25,7 @@ let compute_icfg tenv ast =
Printing.log_out "\n Start creating icfg\n"; Printing.log_out "\n Start creating icfg\n";
let cg = Cg.create () in let cg = Cg.create () in
let cfg = Cfg.Node.create_cfg () 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"; Printing.log_out "\n Finished creating icfg\n";
(cg, cfg) (cg, cfg)
| _ -> assert false (* NOTE: Assumes that an AST alsways starts with a TranslationUnitDecl *) | _ -> assert false (* NOTE: Assumes that an AST alsways starts with a TranslationUnitDecl *)

@ -18,7 +18,7 @@ module type CFrontend_decl = sig
CModule_type.block_data option -> unit CModule_type.block_data option -> unit
val translate_one_declaration : 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 end
module CFrontend_decl_funct(T: CModule_type.CTranslation) : CFrontend_decl = module CFrontend_decl_funct(T: CModule_type.CTranslation) : CFrontend_decl =
@ -127,7 +127,7 @@ struct
translate_location || always_translate_decl translate_location || always_translate_decl
(* Translate one global declaration *) (* 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 let open Clang_ast_t in
(* Run the frontend checkers on this declaration *) (* Run the frontend checkers on this declaration *)
CFrontend_errors.run_frontend_checkers_on_decl tenv cg cfg dec; CFrontend_errors.run_frontend_checkers_on_decl tenv cg cfg dec;
@ -175,12 +175,11 @@ struct
| CXXConversionDecl (decl_info, _, _, _, _) | CXXConversionDecl (decl_info, _, _, _, _)
| CXXDestructorDecl (decl_info, _, _, _, _) -> | CXXDestructorDecl (decl_info, _, _, _, _) ->
(* di_parent_pointer has pointer to lexical context such as class.*) (* 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 let class_decl = match decl_info.Clang_ast_t.di_parent_pointer with
| Some ptr -> | Some ptr ->
Ast_utils.get_decl ptr Ast_utils.get_decl ptr
| None -> | None ->
Some parent_dec in assert false in
(match class_decl with (match class_decl with
| Some (CXXRecordDecl _ as d) | Some (CXXRecordDecl _ as d)
| Some (ClassTemplateSpecializationDecl _ as d) -> | Some (ClassTemplateSpecializationDecl _ as d) ->
@ -203,19 +202,19 @@ struct
true true
| _ -> false in | _ -> false in
let method_decls, no_method_decls = IList.partition is_method_decl decl_list 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); 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) | EnumDecl _ -> ignore (CEnum_decl.enum_decl dec)
| LinkageSpecDecl (_, decl_list, _) -> | LinkageSpecDecl (_, decl_list, _) ->
Printing.log_out "ADDING: LinkageSpecDecl decl list\n"; 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, _, _) -> | 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) | ClassTemplateDecl (_, _, template_decl_info)
| FunctionTemplateDecl (_, _, template_decl_info) -> | FunctionTemplateDecl (_, _, template_decl_info) ->
let decl_list = template_decl_info.Clang_ast_t.tdi_specializations in 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 end

@ -14,7 +14,7 @@ module type CFrontend_decl = sig
CModule_type.block_data option -> unit CModule_type.block_data option -> unit
val translate_one_declaration : Tenv.t -> Cg.t -> Cfg.cfg -> 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 end
module CFrontend_decl_funct(T: CModule_type.CTranslation) : CFrontend_decl module CFrontend_decl_funct(T: CModule_type.CTranslation) : CFrontend_decl

@ -25,5 +25,5 @@ module type CFrontend = sig
block_data option -> unit block_data option -> unit
val translate_one_declaration : Tenv.t -> Cg.t -> Cfg.cfg -> 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 end

Loading…
Cancel
Save