@ -20,7 +20,7 @@ module type CFrontend_decl = sig
CModule_type . block_data option -> unit
val translate_one_declaration :
Tenv . t -> Cg . t -> Cfg . cfg -> C lang_ast_t. decl -> unit
Tenv . t -> Cg . t -> Cfg . cfg -> C Module_type. decl_trans_context -> C lang_ast_t. decl -> unit
end
module CFrontend_decl_funct ( T : CModule_type . CTranslation ) : CFrontend_decl =
@ -109,11 +109,11 @@ struct
let process_methods tenv cg cfg curr_class decl_list =
IList . iter ( process_one_method_decl tenv cg cfg curr_class ) decl_list
let should_translate_decl dec =
let should_translate_decl dec decl_trans_context =
let info = Clang_ast_proj . get_decl_tuple dec in
CLocation . update_curr_file info ;
let source_range = info . Clang_ast_t . di_source_range in
let translate_location = CLocation . should_translate_lib source_range in
let translate_location = CLocation . should_translate_lib source_range decl_trans_context in
let always_translate_decl = match dec with
| Clang_ast_t . FunctionDecl ( _ , name_info , _ , _ ) ->
(* named_decl_info.ni_name has name without template parameters. *)
@ -127,14 +127,15 @@ struct
translate_location | | always_translate_decl
(* Translate one global declaration *)
let rec translate_one_declaration tenv cg cfg dec =
let rec translate_one_declaration tenv cg cfg dec l_trans_context 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 ;
if decl_trans_context = ` DeclTraversal then
CFrontend_errors . run_frontend_checkers_on_decl tenv cg cfg dec ;
(* each procedure has different scope: start names from id 0 *)
Ident . NameGenerator . reset () ;
( if should_translate_decl dec then
( if should_translate_decl dec decl_trans_context then
match dec with
| FunctionDecl ( _ , _ , _ , _ ) ->
function_decl tenv cfg cg dec None
@ -202,19 +203,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 ) no_method_decls ;
IList . iter ( translate_one_declaration tenv cg cfg decl_trans_context ) no_method_decls ;
ignore ( CTypes_decl . add_types_from_decl_to_tenv tenv dec ) ;
IList . iter ( translate_one_declaration tenv cg cfg ) method_decls
IList . iter ( translate_one_declaration tenv cg cfg decl_trans_context ) 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 ) decl_list
IList . iter ( translate_one_declaration tenv cg cfg decl_trans_context ) decl_list
| NamespaceDecl ( _ , _ , decl_list , _ , _ ) ->
IList . iter ( translate_one_declaration tenv cg cfg ) decl_list
IList . iter ( translate_one_declaration tenv cg cfg decl_trans_context ) 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 ) decl_list
IList . iter ( translate_one_declaration tenv cg cfg decl_trans_context ) decl_list
| _ -> ()
end