@ -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