[clang] get_struct_decls utility function

Summary: Extracting function from `get_struct_fields` and making it work for everything in the AST.

Reviewed By: jvillard

Differential Revision: D7813040

fbshipit-source-id: 082f087
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent 9b2ac3de6e
commit ff23aca725

@ -102,17 +102,89 @@ let get_record_definition decl =
decl
let get_struct_decls decl =
let open Clang_ast_t in
match decl with
| CapturedDecl (_, decl_list, _)
| ClassTemplateSpecializationDecl (_, _, _, decl_list, _, _, _, _, _, _)
| ClassTemplatePartialSpecializationDecl (_, _, _, decl_list, _, _, _, _, _, _)
| CXXRecordDecl (_, _, _, decl_list, _, _, _, _)
| EnumDecl (_, _, _, decl_list, _, _, _)
| LinkageSpecDecl (_, decl_list, _)
| NamespaceDecl (_, _, decl_list, _, _)
| ObjCCategoryDecl (_, _, decl_list, _, _)
| ObjCCategoryImplDecl (_, _, decl_list, _, _)
| ObjCImplementationDecl (_, _, decl_list, _, _)
| ObjCInterfaceDecl (_, _, decl_list, _, _)
| ObjCProtocolDecl (_, _, decl_list, _, _)
| RecordDecl (_, _, _, decl_list, _, _, _)
| TranslationUnitDecl (_, decl_list, _, _) ->
decl_list
| AccessSpecDecl _
| BlockDecl _
| ClassScopeFunctionSpecializationDecl _
| EmptyDecl _
| ExportDecl _
| ExternCContextDecl _
| FileScopeAsmDecl _
| FriendDecl _
| FriendTemplateDecl _
| ImportDecl _
| LabelDecl _
| NamespaceAliasDecl _
| ObjCCompatibleAliasDecl _
| ObjCMethodDecl _
| ObjCPropertyDecl _
| BuiltinTemplateDecl _
| ClassTemplateDecl _
| FunctionTemplateDecl _
| TypeAliasTemplateDecl _
| VarTemplateDecl _
| TemplateTemplateParmDecl _
| TemplateTypeParmDecl _
| ObjCTypeParamDecl _
| TypeAliasDecl _
| TypedefDecl _
| UnresolvedUsingTypenameDecl _
| UsingDecl _
| UsingDirectiveDecl _
| UsingPackDecl _
| UsingShadowDecl _
| ConstructorUsingShadowDecl _
| BindingDecl _
| FieldDecl _
| ObjCAtDefsFieldDecl _
| ObjCIvarDecl _
| FunctionDecl _
| CXXDeductionGuideDecl _
| CXXMethodDecl _
| CXXConstructorDecl _
| CXXConversionDecl _
| CXXDestructorDecl _
| MSPropertyDecl _
| NonTypeTemplateParmDecl _
| VarDecl _
| DecompositionDecl _
| ImplicitParamDecl _
| OMPCapturedExprDecl _
| ParmVarDecl _
| VarTemplateSpecializationDecl _
| VarTemplatePartialSpecializationDecl _
| EnumConstantDecl _
| IndirectFieldDecl _
| OMPDeclareReductionDecl _
| UnresolvedUsingValueDecl _
| OMPThreadPrivateDecl _
| ObjCPropertyImplDecl _
| PragmaCommentDecl _
| PragmaDetectMismatchDecl _
| StaticAssertDecl _ ->
[]
let rec get_struct_fields tenv decl =
let open Clang_ast_t in
let decl_list =
match decl with
| ClassTemplateSpecializationDecl (_, _, _, decl_list, _, _, _, _, _, _)
| CXXRecordDecl (_, _, _, decl_list, _, _, _, _)
| RecordDecl (_, _, _, decl_list, _, _, _) ->
decl_list
| _ ->
[]
in
let decl_list = get_struct_decls decl in
let class_tname = get_record_typename ~tenv decl in
let do_one_decl decl =
match decl with

Loading…
Cancel
Save