@@ -2125,12 +2125,26 @@ def get_field_offsetof(self):
21252125
21262126 def is_anonymous (self ):
21272127 """
2128- Check if the record is anonymous.
2128+ Check whether this is a record type without a name, or a field where
2129+ the type is a record type without a name.
2130+
2131+ Use is_anonymous_record_decl to check whether a record is an
2132+ "anonymous union" as defined in the C/C++ standard.
21292133 """
21302134 if self .kind == CursorKind .FIELD_DECL :
21312135 return self .type .get_declaration ().is_anonymous ()
21322136 return conf .lib .clang_Cursor_isAnonymous (self ) # type: ignore [no-any-return]
21332137
2138+ def is_anonymous_record_decl (self ):
2139+ """
2140+ Check if the record is an anonymous union as defined in the C/C++ standard
2141+ (or an "anonymous struct", the corresponding non-standard extension for
2142+ structs).
2143+ """
2144+ if self .kind == CursorKind .FIELD_DECL :
2145+ return self .type .get_declaration ().is_anonymous_record_decl ()
2146+ return conf .lib .clang_Cursor_isAnonymousRecordDecl (self ) # type: ignore [no-any-return]
2147+
21342148 def is_bitfield (self ):
21352149 """
21362150 Check if the field is a bitfield.
@@ -3902,12 +3916,13 @@ def write_main_file_to_stdout(self):
39023916 ("clang_Cursor_getTemplateArgumentType" , [Cursor , c_uint ], Type ),
39033917 ("clang_Cursor_getTemplateArgumentValue" , [Cursor , c_uint ], c_longlong ),
39043918 ("clang_Cursor_getTemplateArgumentUnsignedValue" , [Cursor , c_uint ], c_ulonglong ),
3905- ("clang_Cursor_isAnonymous" , [Cursor ], bool ),
3906- ("clang_Cursor_isBitField" , [Cursor ], bool ),
39073919 ("clang_Cursor_getBinaryOpcode" , [Cursor ], c_int ),
39083920 ("clang_Cursor_getBriefCommentText" , [Cursor ], _CXString ),
39093921 ("clang_Cursor_getRawCommentText" , [Cursor ], _CXString ),
39103922 ("clang_Cursor_getOffsetOfField" , [Cursor ], c_longlong ),
3923+ ("clang_Cursor_isAnonymous" , [Cursor ], bool ),
3924+ ("clang_Cursor_isAnonymousRecordDecl" , [Cursor ], bool ),
3925+ ("clang_Cursor_isBitField" , [Cursor ], bool ),
39113926 ("clang_Location_isInSystemHeader" , [SourceLocation ], bool ),
39123927 ("clang_Type_getAlignOf" , [Type ], c_longlong ),
39133928 ("clang_Type_getClassType" , [Type ], Type ),
0 commit comments