File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1153,6 +1153,14 @@ impl TypedAstContext {
11531153 }
11541154 }
11551155
1156+ // If a typedef names an anonymous decl, and that decl is wanted,
1157+ // then the typedef is also wanted.
1158+ for ( & decl_id, & subdecl_id) in & self . prenamed_decls {
1159+ if wanted. contains ( & subdecl_id) {
1160+ wanted. insert ( decl_id) ;
1161+ }
1162+ }
1163+
11561164 // Unset c_main if we are not retaining its declaration
11571165 if let Some ( main_id) = self . c_main {
11581166 if !wanted. contains ( & main_id) {
Original file line number Diff line number Diff line change @@ -708,6 +708,10 @@ pub fn translate(
708708 None
709709 } ;
710710
711+ // Identify typedefs that name unnamed types and collapse the two declarations
712+ // into a single name and declaration, eliminating the typedef altogether.
713+ t. ast_context . set_prenamed_decls ( ) ;
714+
711715 // Headers often pull in declarations that are unused;
712716 // we simplify the translator output by omitting those.
713717 t. ast_context
@@ -737,10 +741,6 @@ pub fn translate(
737741 prefix_names ( & mut t, prefix) ;
738742 }
739743
740- // Identify typedefs that name unnamed types and collapse the two declarations
741- // into a single name and declaration, eliminating the typedef altogether.
742- t. ast_context . set_prenamed_decls ( ) ;
743-
744744 for ( & decl_id, & subdecl_id) in & t. ast_context . prenamed_decls {
745745 if let CDeclKind :: Typedef { ref name, .. } = t. ast_context [ decl_id] . kind {
746746 t. type_converter
You can’t perform that action at this time.
0 commit comments