[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / AST / pragma-attribute-objc-subject-match-rules.m
blobef5e6bf783c6c52956e1a9c809195fa0f58461e5
1 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump "-DSUBJECT=objc_interface" %s | FileCheck --check-prefix=CHECK-OBJC_INTERFACE %s
2 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump -ast-dump-filter test "-DSUBJECT=objc_protocol" %s | FileCheck --check-prefix=CHECK-OBJC_PROTOCOL %s
3 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump "-DSUBJECT=objc_category" %s | FileCheck --check-prefix=CHECK-OBJC_CATEGORY %s
4 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump -ast-dump-filter test "-DSUBJECT=objc_method" %s | FileCheck --check-prefix=CHECK-OBJC_METHOD %s
5 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump -ast-dump-filter test "-DSUBJECT=objc_method(is_instance)" %s | FileCheck --check-prefix=CHECK-OBJC_METHOD_IS_INSTANCE %s
6 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump -ast-dump-filter test "-DSUBJECT=field" %s | FileCheck --check-prefix=CHECK-FIELD %s
7 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump -ast-dump-filter test "-DSUBJECT=objc_property" %s | FileCheck --check-prefix=CHECK-OBJC_PROPERTY %s
8 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump -ast-dump-filter test "-DSUBJECT=block" %s | FileCheck --check-prefix=CHECK-BLOCK %s
9 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wno-objc-root-class -ast-dump -ast-dump-filter test "-DSUBJECT=hasType(functionType)" %s | FileCheck --check-prefix=CHECK-HAS_TYPE_FUNCTION_TYPE %s
11 #pragma clang attribute push (__attribute__((annotate("test"))), apply_to = any(SUBJECT))
13 @interface testInterface
14 @end
15 // CHECK-OBJC_INTERFACE: ObjCInterfaceDecl{{.*}} testInterface
16 // CHECK-OBJC_INTERFACE-NEXT: AnnotateAttr{{.*}} "test"
18 @interface testInterface ()
19 @end
20 // CHECK-OBJC_INTERFACE: ObjCCategoryDecl
21 // CHECK-OBJC_INTERFACE-NOT: AnnotateAttr{{.*}} "test"
22 // CHECK-OBJC_CATEGORY: ObjCCategoryDecl
23 // CHECK-OBJC_CATEGORY-NEXT: ObjCInterface
24 // CHECK-OBJC_CATEGORY-NEXT: AnnotateAttr{{.*}} "test"
26 @interface testInterface (testCategory)
27 @end
28 // CHECK-OBJC_INTERFACE: ObjCCategoryDecl{{.*}} testCategory
29 // CHECK-OBJC_INTERFACE-NOT: AnnotateAttr{{.*}} "test"
30 // CHECK-OBJC_CATEGORY: ObjCCategoryDecl{{.*}} testCategory
31 // CHECK-OBJC_CATEGORY-NEXT: ObjCInterface
32 // CHECK-OBJC_CATEGORY-NEXT: AnnotateAttr{{.*}} "test"
34 // CHECK-OBJC_INTERFACE-LABEL: ObjCProtocolDecl
35 @protocol testProtocol
36 @end
37 // CHECK-OBJC_PROTOCOL: ObjCProtocolDecl{{.*}} testProtocol
38 // CHECK-OBJC_PROTOCOL-NEXT: AnnotateAttr{{.*}} "test"
40 @interface methodContainer
41 - (void) testInstanceMethod;
42 + (void) testClassMethod;
43 @end
44 // CHECK-OBJC_METHOD: ObjCMethodDecl{{.*}} testInstanceMethod
45 // CHECK-OBJC_METHOD-NEXT: AnnotateAttr{{.*}} "test"
46 // CHECK-OBJC_METHOD: ObjCMethodDecl{{.*}} testClassMethod
47 // CHECK-OBJC_METHOD-NEXT: AnnotateAttr{{.*}} "test"
48 // CHECK-OBJC_METHOD_IS_INSTANCE: ObjCMethodDecl{{.*}} testInstanceMethod
49 // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: AnnotateAttr{{.*}} "test"
50 // CHECK-OBJC_METHOD_IS_INSTANCE-LABEL: ObjCMethodDecl{{.*}} testClassMethod
51 // CHECK-OBJC_METHOD_IS_INSTANCE-NOT: AnnotateAttr{{.*}} "test"
52 // CHECK-HAS_TYPE_FUNCTION_TYPE-LABEL: ObjCMethodDecl{{.*}} testInstanceMethod
53 // CHECK-HAS_TYPE_FUNCTION_TYPE-NOT: AnnotateAttr{{.*}} "test"
54 // CHECK-HAS_TYPE_FUNCTION_TYPE-LABEL: ObjCMethodDecl{{.*}} testClassMethod
55 // CHECK-HAS_TYPE_FUNCTION_TYPE-NOT: AnnotateAttr{{.*}} "test"
57 @implementation methodContainer
58 - (void) testInstanceMethod { }
59 + (void) testClassMethod { }
60 @end
61 // CHECK-OBJC_METHOD: ObjCMethodDecl{{.*}} testInstanceMethod
62 // CHECK-OBJC_METHOD-NEXT: ImplicitParamDecl
63 // CHECK-OBJC_METHOD-NEXT: ImplicitParamDecl
64 // CHECK-OBJC_METHOD-NEXT: CompoundStmt
65 // CHECK-OBJC_METHOD-NEXT: AnnotateAttr{{.*}} "test"
66 // CHECK-OBJC_METHOD: ObjCMethodDecl{{.*}} testClassMethod
67 // CHECK-OBJC_METHOD-NEXT: ImplicitParamDecl
68 // CHECK-OBJC_METHOD-NEXT: ImplicitParamDecl
69 // CHECK-OBJC_METHOD-NEXT: CompoundStmt
70 // CHECK-OBJC_METHOD-NEXT: AnnotateAttr{{.*}} "test"
71 // CHECK-OBJC_METHOD_IS_INSTANCE-LABEL: ObjCMethodDecl{{.*}} testInstanceMethod
72 // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: ImplicitParamDecl
73 // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: ImplicitParamDecl
74 // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: CompoundStmt
75 // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: AnnotateAttr{{.*}} "test"
76 // CHECK-OBJC_METHOD_IS_INSTANCE: ObjCMethodDecl{{.*}} testClassMethod
77 // CHECK-OBJC_METHOD_IS_INSTANCE-NOT: AnnotateAttr{{.*}} "test"
79 // CHECK-HAS_TYPE_FUNCTION_TYPE-LABEL: ObjCMethodDecl{{.*}} testInstanceMethod
80 // CHECK-HAS_TYPE_FUNCTION_TYPE-NOT: AnnotateAttr{{.*}} "test"
81 // CHECK-HAS_TYPE_FUNCTION_TYPE-LABEL: ObjCMethodDecl{{.*}} testClassMethod
82 // CHECK-HAS_TYPE_FUNCTION_TYPE-NOT: AnnotateAttr{{.*}} "test"
83 @interface propertyContainer {
84   int testIvar;
85 // CHECK-FIELD: ObjCIvarDecl{{.*}} testIvar
86 // CHECK-FIELD-NEXT: AnnotateAttr{{.*}} "test"
89 @property int testProperty;
90 // CHECK-OBJC_PROPERTY: ObjCPropertyDecl{{.*}} testProperty
91 // CHECK-OBJC_PROPERTY-NEXT: AnnotateAttr{{.*}} "test"
93 @end
95 void (^testBlockVar)(void);
96 // CHECK-BLOCK: VarDecl{{.*}} testBlockVar
97 // CHECK-BLOCK-NOT: AnnotateAttr{{.*}} "test"
99 void testBlock(void) {
100   (void)(^ { });
102 // CHECK-BLOCK-LABEL: BlockDecl
103 // CHECK-BLOCK-NEXT: CompoundStmt
104 // CHECK-BLOCK-NEXT: AnnotateAttr{{.*}} "test"
105 // CHECK-HAS_TYPE_FUNCTION_TYPE-LABEL: FunctionDecl{{.*}} testBlock
106 // CHECK-HAS_TYPE_FUNCTION_TYPE: BlockDecl
107 // CHECK-HAS_TYPE_FUNCTION_TYPE-NEXT: CompoundStmt
108 // The attribute applies to function, but not to block:
109 // CHECK-HAS_TYPE_FUNCTION_TYPE-NEXT: AnnotateAttr{{.*}} "test"
110 // CHECK-HAS_TYPE_FUNCTION_TYPE-NOT: AnnotateAttr{{.*}} "test"
113 #pragma clang attribute pop