Skip to content

Commit 4416d15

Browse files
committed
[c++-interop] Test that APINotes handles ObjCMethods while in C++-Interop
In a previous commit I taught APINotes to treat extern-c context as a toplevel file context, but this only makes sense when we are handling the decls handled in the block like VarDecls, FunctionDecls, ObjCInterfaceDecls, etc. But when the decl being handled for APINote is an ObjCMethod inside of a ObjCContainer then it is important to allow the subsequent code in the Sema::ProcessAPINotes function to handle things. This can be excercised by the following APINote: ``` --- Name: SomeModule Classes: - Name: NSSomeClass SwiftName: SomeClass Methods: - Selector: 'didMoveToParentViewController:' SwiftName: didMove(toParent:) MethodKind: Instance ``` This commit is now just a test case due to another commit that has already landed.
1 parent 6e60a3d commit 4416d15

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

clang/test/APINotes/Inputs/Frameworks/CXXInteropKit.framework/Headers/CXXInteropKit.apinotes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Name: CxxInterop
33
Classes:
44
- Name: NSSomeClass
55
SwiftName: SomeClass
6+
Methods:
7+
- Selector: 'didMoveToParentViewController:'
8+
SwiftName: didMove(toParent:)
9+
MethodKind: Instance
610
Enumerators:
711
- Name: SomeClassRed
812
SwiftName: red

clang/test/APINotes/Inputs/Frameworks/CXXInteropKit.framework/Headers/CXXInteropKit.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@
22
-(instancetype)init;
33
@end
44

5+
// Extension, inspired by UIKit UIViewController.h
6+
@interface NSSomeClass (UIContainerViewControllerCallbacks)
7+
8+
- (void)didMoveToParentViewController:(NSSomeClass *)parent;
9+
10+
@end
11+
512
// Named "SomeClassRed" for ast node filtering in the test.
613
enum ColorEnum { SomeClassRed, SomeClassGreen, SomeClassBlue };

clang/test/APINotes/objcxx-swift-name.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// CHECK-NEXT: ObjCInterfaceDecl {{.+}} imported in CxxInteropKit <undeserialized declarations> NSSomeClass
99
// CHECK-NEXT: SwiftNameAttr {{.+}} <<invalid sloc>> "SomeClass"
1010

11+
// CHECK: Dumping NSSomeClass::didMoveToParentViewController::
12+
// CHECK-NEXT: ObjCMethodDecl {{.+}} imported in CxxInteropKit - didMoveToParentViewController: 'void'
13+
// CHECK-NEXT: ParmVarDecl
14+
// CHECK-NEXT: SwiftNameAttr {{.+}} <<invalid sloc>> "didMove(toParent:)"
15+
1116
// CHECK: Dumping SomeClassRed:
1217
// CHECK-NEXT: EnumConstantDecl {{.+}} imported in CxxInteropKit SomeClassRed 'ColorEnum'
1318
// CHECK-NEXT: SwiftNameAttr {{.+}} <<invalid sloc>> "red"

0 commit comments

Comments
 (0)