@@ -4526,7 +4526,7 @@ private bool HasVtbl(CXXRecordDecl cxxRecordDecl, out bool hasBaseVtbl)
45264526 return hasVtbl ;
45274527 }
45284528
4529- private bool IsEnumOperator ( FunctionDecl functionDecl , string name )
4529+ private static bool IsEnumOperator ( FunctionDecl functionDecl , string name )
45304530 {
45314531 if ( name . StartsWith ( "operator" , StringComparison . Ordinal ) && ( ( functionDecl . Parameters . Count == 1 ) || ( functionDecl . Parameters . Count == 2 ) ) )
45324532 {
@@ -4573,7 +4573,7 @@ private bool IsExcluded(Cursor cursor, out bool isExcludedByConflictingDefinitio
45734573 {
45744574 if ( ! _isExcluded . TryGetValue ( cursor , out var isExcludedValue ) )
45754575 {
4576- isExcludedValue |= ( ! IsAlwaysIncluded ( cursor ) && ( IsExcludedByConfig ( cursor ) || IsExcludedByFile ( cursor ) || IsExcludedByName ( cursor , ref isExcludedValue ) ) ) ? 0b01u : 0b00u ;
4576+ isExcludedValue |= ( ! IsAlwaysIncluded ( cursor ) && ( IsExcludedByConfig ( cursor ) || IsExcludedByFile ( cursor ) || IsExcludedByName ( cursor , ref isExcludedValue ) || IsExcludedByAttributes ( cursor ) ) ) ? 0b01u : 0b00u ;
45774577 _isExcluded . Add ( cursor , isExcludedValue ) ;
45784578 }
45794579 isExcludedByConflictingDefinition = ( isExcludedValue & 0b10 ) != 0 ;
@@ -5042,6 +5042,23 @@ bool IsEmptyRecord(RecordDecl recordDecl)
50425042
50435043 return ! TryGetUuid ( recordDecl , out _ ) ;
50445044 }
5045+
5046+ bool IsExcludedByAttributes ( Cursor cursor )
5047+ {
5048+ if ( cursor is NamedDecl namedDecl )
5049+ {
5050+ foreach ( var attr in GetAttributesFor ( namedDecl ) )
5051+ {
5052+ switch ( attr . Kind )
5053+ {
5054+ case CX_AttrKind_Builtin :
5055+ return true ;
5056+ }
5057+ }
5058+ }
5059+
5060+ return false ;
5061+ }
50455062 }
50465063
50475064 private bool IsBaseExcluded ( CXXRecordDecl cxxRecordDecl , CXXRecordDecl baseCxxRecordDecl , CXXBaseSpecifier cxxBaseSpecifier , out string baseFieldName )
@@ -5226,22 +5243,22 @@ private static bool IsStmtAsWritten(Stmt stmt, Stmt expectedStmt, bool removePar
52265243 return expr == expectedStmt ;
52275244 }
52285245
5229- private bool IsType < T > ( Expr expr )
5246+ private static bool IsType < T > ( Expr expr )
52305247 where T : Type => IsType < T > ( expr , out _ ) ;
52315248
5232- private bool IsType < T > ( Expr expr , [ MaybeNullWhen ( false ) ] out T value )
5249+ private static bool IsType < T > ( Expr expr , [ MaybeNullWhen ( false ) ] out T value )
52335250 where T : Type => IsType ( expr , expr . Type , out value ) ;
52345251
5235- private bool IsType < T > ( ValueDecl valueDecl )
5252+ private static bool IsType < T > ( ValueDecl valueDecl )
52365253 where T : Type => IsType < T > ( valueDecl , out _ ) ;
52375254
5238- private bool IsType < T > ( ValueDecl typeDecl , [ MaybeNullWhen ( false ) ] out T value )
5255+ private static bool IsType < T > ( ValueDecl typeDecl , [ MaybeNullWhen ( false ) ] out T value )
52395256 where T : Type => IsType ( typeDecl , typeDecl . Type , out value ) ;
52405257
5241- private bool IsType < T > ( Cursor ? cursor , Type type )
5258+ private static bool IsType < T > ( Cursor ? cursor , Type type )
52425259 where T : Type => IsType < T > ( cursor , type , out _ ) ;
52435260
5244- private bool IsType < T > ( Cursor ? cursor , Type type , [ MaybeNullWhen ( false ) ] out T value )
5261+ private static bool IsType < T > ( Cursor ? cursor , Type type , [ MaybeNullWhen ( false ) ] out T value )
52455262 where T : Type
52465263 {
52475264 if ( type is T t )
@@ -5325,36 +5342,36 @@ private bool IsType<T>(Cursor? cursor, Type type, [MaybeNullWhen(false)] out T v
53255342 return false ;
53265343 }
53275344
5328- private bool IsTypeConstantOrIncompleteArray ( Expr expr )
5345+ private static bool IsTypeConstantOrIncompleteArray ( Expr expr )
53295346 => IsTypeConstantOrIncompleteArray ( expr , out _ ) ;
53305347
5331- private bool IsTypeConstantOrIncompleteArray ( Expr expr , [ MaybeNullWhen ( false ) ] out ArrayType arrayType )
5348+ private static bool IsTypeConstantOrIncompleteArray ( Expr expr , [ MaybeNullWhen ( false ) ] out ArrayType arrayType )
53325349 => IsTypeConstantOrIncompleteArray ( expr , expr . Type , out arrayType ) ;
53335350
53345351 private bool IsTypeConstantOrIncompleteArray ( ValueDecl valueDecl )
53355352 => IsTypeConstantOrIncompleteArray ( valueDecl , out _ ) ;
53365353
5337- private bool IsTypeConstantOrIncompleteArray ( ValueDecl valueDecl , [ MaybeNullWhen ( false ) ] out ArrayType arrayType )
5354+ private static bool IsTypeConstantOrIncompleteArray ( ValueDecl valueDecl , [ MaybeNullWhen ( false ) ] out ArrayType arrayType )
53385355 => IsTypeConstantOrIncompleteArray ( valueDecl , valueDecl . Type , out arrayType ) ;
53395356
5340- private bool IsTypeConstantOrIncompleteArray ( Cursor ? cursor , Type type )
5357+ private static bool IsTypeConstantOrIncompleteArray ( Cursor ? cursor , Type type )
53415358 => IsTypeConstantOrIncompleteArray ( cursor , type , out _ ) ;
53425359
5343- private bool IsTypeConstantOrIncompleteArray ( Cursor ? cursor , Type type , [ MaybeNullWhen ( false ) ] out ArrayType arrayType )
5360+ private static bool IsTypeConstantOrIncompleteArray ( Cursor ? cursor , Type type , [ MaybeNullWhen ( false ) ] out ArrayType arrayType )
53445361 => IsType ( cursor , type , out arrayType )
53455362 && ( arrayType is ConstantArrayType or IncompleteArrayType ) ;
53465363
5347- private bool IsTypePointerOrReference ( Expr expr )
5364+ private static bool IsTypePointerOrReference ( Expr expr )
53485365 => IsTypePointerOrReference ( expr , expr . Type ) ;
53495366
5350- private bool IsTypePointerOrReference ( ValueDecl valueDecl )
5367+ private static bool IsTypePointerOrReference ( ValueDecl valueDecl )
53515368 => IsTypePointerOrReference ( valueDecl , valueDecl . Type ) ;
53525369
5353- private bool IsTypePointerOrReference ( Cursor ? cursor , Type type )
5370+ private static bool IsTypePointerOrReference ( Cursor ? cursor , Type type )
53545371 => IsType < PointerType > ( cursor , type )
53555372 || IsType < ReferenceType > ( cursor , type ) ;
53565373
5357- private bool IsTypeVoid ( Cursor ? cursor , Type type )
5374+ private static bool IsTypeVoid ( Cursor ? cursor , Type type )
53585375 => IsType < BuiltinType > ( cursor , type , out var builtinType )
53595376 && ( builtinType . Kind == CXType_Void ) ;
53605377
@@ -6597,6 +6614,32 @@ private void Visit(IEnumerable<Cursor> cursors)
65976614
65986615 private void Visit ( IEnumerable < Cursor > cursors , IEnumerable < Cursor > excludedCursors ) => Visit ( cursors . Except ( excludedCursors ) ) ;
65996616
6617+ private static IEnumerable < Attr > GetAttributesFor ( NamedDecl namedDecl )
6618+ {
6619+ var declAttrs = namedDecl . HasAttrs
6620+ ? namedDecl . Attrs
6621+ : Enumerable . Empty < Attr > ( ) ;
6622+
6623+ if ( namedDecl is FieldDecl fieldDecl )
6624+ {
6625+ if ( IsType < TypedefType > ( fieldDecl , out var typedefType ) )
6626+ {
6627+ declAttrs = declAttrs . Concat ( typedefType . Decl . Attrs ) ;
6628+ }
6629+ }
6630+ else if ( namedDecl is RecordDecl recordDecl )
6631+ {
6632+ var typedefName = recordDecl . TypedefNameForAnonDecl ;
6633+
6634+ if ( ( typedefName is not null ) && typedefName . HasAttrs )
6635+ {
6636+ declAttrs = declAttrs . Concat ( typedefName . Attrs ) ;
6637+ }
6638+ }
6639+
6640+ return declAttrs ;
6641+ }
6642+
66006643 private void WithAttributes ( NamedDecl namedDecl , bool onlySupportedOSPlatform = false , bool isTestOutput = false )
66016644 {
66026645 var outputBuilder = isTestOutput ? _testOutputBuilder : _outputBuilder ;
@@ -6612,30 +6655,9 @@ private void WithAttributes(NamedDecl namedDecl, bool onlySupportedOSPlatform =
66126655
66136656 if ( ! isTestOutput )
66146657 {
6615- var declAttrs = namedDecl . HasAttrs
6616- ? namedDecl . Attrs
6617- : Enumerable . Empty < Attr > ( ) ;
6618-
6619- if ( namedDecl is FieldDecl fieldDecl )
6620- {
6621- if ( IsType < TypedefType > ( fieldDecl , out var typedefType ) )
6622- {
6623- declAttrs = declAttrs . Concat ( typedefType . Decl . Attrs ) ;
6624- }
6625- }
6626- else if ( namedDecl is RecordDecl recordDecl )
6627- {
6628- var typedefName = recordDecl . TypedefNameForAnonDecl ;
6629-
6630- if ( ( typedefName is not null ) && typedefName . HasAttrs )
6631- {
6632- declAttrs = declAttrs . Concat ( typedefName . Attrs ) ;
6633- }
6634- }
6635-
66366658 var obsoleteEmitted = false ;
66376659
6638- foreach ( var attr in declAttrs )
6660+ foreach ( var attr in GetAttributesFor ( namedDecl ) )
66396661 {
66406662 switch ( attr . Kind )
66416663 {
0 commit comments