annotate clang/test/Index/annotate-comments-objc.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // Run lines are sensitive to line numbers and come below the code.
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 #ifndef HEADER
anatofuz
parents:
diff changeset
4 #define HEADER
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 /// Comment for 'functionBeforeImports'.
anatofuz
parents:
diff changeset
7 void functionBeforeImports(void);
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 #import <DocCommentsA/DocCommentsA.h>
anatofuz
parents:
diff changeset
10 #import <DocCommentsB/DocCommentsB.h>
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 @class NSString;
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 //===---
anatofuz
parents:
diff changeset
15 // rdar://14258334
anatofuz
parents:
diff changeset
16 // Check that we attach comments to properties correctly.
anatofuz
parents:
diff changeset
17 //===---
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 @interface MyClass {
anatofuz
parents:
diff changeset
20 }
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 /// property1_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
23 @property (nonatomic, copy, readwrite) NSString *property1_isdoxy1;
anatofuz
parents:
diff changeset
24 @property (nonatomic, copy, readwrite) NSString *property1_isdoxy2; ///< property1_isdoxy2 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
25 @property (nonatomic, copy, readwrite) NSString *property1_isdoxy3; /**< property1_isdoxy3 IS_DOXYGEN_SINGLE */
anatofuz
parents:
diff changeset
26 @property (nonatomic, copy, readwrite) NSString *property1_isdoxy4; /*!< property1_isdoxy4 IS_DOXYGEN_SINGLE */
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 /// method1_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
29 - (void)method1_isdoxy1;
anatofuz
parents:
diff changeset
30 - (void)method1_isdoxy2; ///< method1_isdoxy2 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
31 - (void)method1_isdoxy3; /**< method1_isdoxy3 IS_DOXYGEN_SINGLE */
anatofuz
parents:
diff changeset
32 - (void)method1_isdoxy4; /*!< method1_isdoxy4 IS_DOXYGEN_SINGLE */
anatofuz
parents:
diff changeset
33 @end
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 //===---
anatofuz
parents:
diff changeset
36 // rdar://14348912
anatofuz
parents:
diff changeset
37 // Check that we attach comments to enums declared using the NS_ENUM macro.
anatofuz
parents:
diff changeset
38 //===---
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 /// An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
43 typedef NS_ENUM(int, An_NS_ENUM_isdoxy1) { Red, Green, Blue };
anatofuz
parents:
diff changeset
44
anatofuz
parents:
diff changeset
45 // In the implementation of attaching comments to enums declared using the
anatofuz
parents:
diff changeset
46 // NS_ENUM macro, it is tempting to use the fact that enum decl is embedded in
anatofuz
parents:
diff changeset
47 // the typedef. Make sure that the heuristic is strong enough that it does not
anatofuz
parents:
diff changeset
48 // attach unrelated comments in the following cases where tag decls are
anatofuz
parents:
diff changeset
49 // embedded in declarators.
anatofuz
parents:
diff changeset
50
anatofuz
parents:
diff changeset
51 #define DECLARE_FUNCTION() \
anatofuz
parents:
diff changeset
52 void functionFromMacro() { \
anatofuz
parents:
diff changeset
53 typedef struct Struct_notdoxy Struct_notdoxy; \
anatofuz
parents:
diff changeset
54 }
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 /// IS_DOXYGEN_NOT_ATTACHED
anatofuz
parents:
diff changeset
57 DECLARE_FUNCTION()
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 /// typedef_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
60 typedef struct Struct_notdoxy *typedef_isdoxy1;
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 #endif
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 // RUN: rm -rf %t
anatofuz
parents:
diff changeset
65 // RUN: mkdir %t
anatofuz
parents:
diff changeset
66 // RUN: mkdir %t/module-cache
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 // Check that we serialize comment source locations properly.
anatofuz
parents:
diff changeset
69 // RUN: %clang_cc1 -emit-pch -o %t/out.pch -F %S/Inputs/Frameworks %s
anatofuz
parents:
diff changeset
70 // RUN: %clang_cc1 -include-pch %t/out.pch -F %S/Inputs/Frameworks -fsyntax-only %s
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 // RUN: c-index-test -write-pch %t/out.pch -F %S/Inputs/Frameworks %s
anatofuz
parents:
diff changeset
73 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -F %S/Inputs/Frameworks > %t/out.c-index-direct
anatofuz
parents:
diff changeset
74 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -F %S/Inputs/Frameworks -fmodules -fmodules-cache-path=%t/module-cache > %t/out.c-index-modules
anatofuz
parents:
diff changeset
75 // RUN: c-index-test -test-load-tu %t/out.pch all -F %S/Inputs/Frameworks > %t/out.c-index-pch
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct
anatofuz
parents:
diff changeset
78 // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-modules
anatofuz
parents:
diff changeset
79 // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-pch
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 // Declarations without Doxygen comments should not pick up some Doxygen comments.
anatofuz
parents:
diff changeset
82 // WRONG-NOT: notdoxy{{.*}}Comment=
anatofuz
parents:
diff changeset
83 // WRONG-NOT: test{{.*}}Comment=
anatofuz
parents:
diff changeset
84
anatofuz
parents:
diff changeset
85 // Non-Doxygen comments should not be attached to anything.
anatofuz
parents:
diff changeset
86 // WRONG-NOT: NOT_DOXYGEN
anatofuz
parents:
diff changeset
87
anatofuz
parents:
diff changeset
88 // Some Doxygen comments are not attached to anything.
anatofuz
parents:
diff changeset
89 // WRONG-NOT: IS_DOXYGEN_NOT_ATTACHED
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 // Ensure we don't pick up extra comments.
anatofuz
parents:
diff changeset
92 // WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START{{.*}}BriefComment=
anatofuz
parents:
diff changeset
93 // WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END{{.*}}BriefComment=
anatofuz
parents:
diff changeset
94 //
anatofuz
parents:
diff changeset
95 // Ensure that XML is not invalid
anatofuz
parents:
diff changeset
96 // WRONG-NOT: CommentXMLInvalid
anatofuz
parents:
diff changeset
97
anatofuz
parents:
diff changeset
98 // RUN: FileCheck %s < %t/out.c-index-direct
anatofuz
parents:
diff changeset
99 // RUN: FileCheck %s < %t/out.c-index-modules
anatofuz
parents:
diff changeset
100 // RUN: FileCheck %s < %t/out.c-index-pch
anatofuz
parents:
diff changeset
101
anatofuz
parents:
diff changeset
102 // These CHECK lines are not located near the code on purpose. This test
anatofuz
parents:
diff changeset
103 // checks that documentation comments are attached to declarations correctly.
anatofuz
parents:
diff changeset
104 // Adding a non-documentation comment with CHECK line between every two
anatofuz
parents:
diff changeset
105 // documentation comments will only test a single code path.
anatofuz
parents:
diff changeset
106 //
anatofuz
parents:
diff changeset
107 // CHECK-DAG: annotate-comments-objc.m:7:6: FunctionDecl=functionBeforeImports:{{.*}} BriefComment=[Comment for 'functionBeforeImports'.]
anatofuz
parents:
diff changeset
108 // CHECK-DAG: DocCommentsA.h:2:6: FunctionDecl=functionFromDocCommentsA1:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsA1'.]
anatofuz
parents:
diff changeset
109 // CHECK-DAG: DocCommentsA.h:7:6: FunctionDecl=functionFromDocCommentsA2:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsA2'.]
anatofuz
parents:
diff changeset
110 // CHECK-DAG: DocCommentsB.h:2:6: FunctionDecl=functionFromDocCommentsB1:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsB1'.]
anatofuz
parents:
diff changeset
111 // CHECK-DAG: DocCommentsB.h:7:6: FunctionDecl=functionFromDocCommentsB2:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsB2'.]
anatofuz
parents:
diff changeset
112 // CHECK-DAG: DocCommentsC.h:2:6: FunctionDecl=functionFromDocCommentsC:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsC'.]
anatofuz
parents:
diff changeset
113 // CHECK: annotate-comments-objc.m:23:50: ObjCPropertyDecl=property1_isdoxy1:{{.*}} property1_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
114 // CHECK: annotate-comments-objc.m:24:50: ObjCPropertyDecl=property1_isdoxy2:{{.*}} property1_isdoxy2 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
115 // CHECK: annotate-comments-objc.m:25:50: ObjCPropertyDecl=property1_isdoxy3:{{.*}} property1_isdoxy3 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
116 // CHECK: annotate-comments-objc.m:26:50: ObjCPropertyDecl=property1_isdoxy4:{{.*}} property1_isdoxy4 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
117 // CHECK: annotate-comments-objc.m:29:9: ObjCInstanceMethodDecl=method1_isdoxy1:{{.*}} method1_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
118 // CHECK: annotate-comments-objc.m:30:9: ObjCInstanceMethodDecl=method1_isdoxy2:{{.*}} method1_isdoxy2 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
119 // CHECK: annotate-comments-objc.m:31:9: ObjCInstanceMethodDecl=method1_isdoxy3:{{.*}} method1_isdoxy3 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
120 // CHECK: annotate-comments-objc.m:32:9: ObjCInstanceMethodDecl=method1_isdoxy4:{{.*}} method1_isdoxy4 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
121 // CHECK: annotate-comments-objc.m:43:22: EnumDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
122 // CHECK: annotate-comments-objc.m:43:22: TypedefDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
123 // CHECK: annotate-comments-objc.m:43:22: EnumDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
124 // CHECK: annotate-comments-objc.m:60:32: TypedefDecl=typedef_isdoxy1:{{.*}} typedef_isdoxy1 IS_DOXYGEN_SINGLE
anatofuz
parents:
diff changeset
125