Skip to content

Commit

Permalink
[Clang][AST] Print attributes of Obj-C interfaces
Browse files Browse the repository at this point in the history
When pretty printing an Objective-C interface declaration, Clang
previously didn't print any attributes that are applied to the
declaration.
  • Loading branch information
egorzhdan committed Mar 11, 2024
1 parent b4e0890 commit a8eb2f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clang/lib/AST/DeclPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,11 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
return;
}
bool eolnOut = false;
if (OID->hasAttrs()) {
prettyPrintAttributes(OID);
Out << "\n";
}

Out << "@interface " << I;

if (auto TypeParams = OID->getTypeParamListAsWritten()) {
Expand Down
8 changes: 8 additions & 0 deletions clang/test/AST/ast-print-objectivec.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ - (void)MethI __attribute__((availability(macosx,introduced=10.1.0,deprecated=10
- (void)methodWithArg:(int)x andAnotherOne:(int)y { }
@end

__attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2)))
@interface InterfaceWithAttribute
@end

// CHECK: @protocol P
// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)));
// CHECK: @end
Expand All @@ -45,6 +49,10 @@ - (void)methodWithArg:(int)x andAnotherOne:(int)y { }

// CHECK: @end

// CHECK: __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)))
// CHECK: @interface InterfaceWithAttribute
// CHECK: @end

@class C1;
struct __attribute__((objc_bridge_related(C1,,))) S1;

Expand Down

0 comments on commit a8eb2f0

Please sign in to comment.