Skip to content

Commit a8eb2f0

Browse files
authored
[Clang][AST] Print attributes of Obj-C interfaces
When pretty printing an Objective-C interface declaration, Clang previously didn't print any attributes that are applied to the declaration.
1 parent b4e0890 commit a8eb2f0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/AST/DeclPrinter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,11 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
15171517
return;
15181518
}
15191519
bool eolnOut = false;
1520+
if (OID->hasAttrs()) {
1521+
prettyPrintAttributes(OID);
1522+
Out << "\n";
1523+
}
1524+
15201525
Out << "@interface " << I;
15211526

15221527
if (auto TypeParams = OID->getTypeParamListAsWritten()) {

clang/test/AST/ast-print-objectivec.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ - (void)MethI __attribute__((availability(macosx,introduced=10.1.0,deprecated=10
2121
- (void)methodWithArg:(int)x andAnotherOne:(int)y { }
2222
@end
2323

24+
__attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2)))
25+
@interface InterfaceWithAttribute
26+
@end
27+
2428
// CHECK: @protocol P
2529
// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)));
2630
// CHECK: @end
@@ -45,6 +49,10 @@ - (void)methodWithArg:(int)x andAnotherOne:(int)y { }
4549

4650
// CHECK: @end
4751

52+
// CHECK: __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)))
53+
// CHECK: @interface InterfaceWithAttribute
54+
// CHECK: @end
55+
4856
@class C1;
4957
struct __attribute__((objc_bridge_related(C1,,))) S1;
5058

0 commit comments

Comments
 (0)