blob: bd32445f895d22b834b2109af651389b4ff32a59 [file] [log] [blame]
Dmitri Gribenko46dd39e2013-08-19 07:10:13 +00001// Run lines are sensitive to line numbers and come below the code.
2
3#ifndef HEADER
4#define HEADER
5
Dmitri Gribenko9ee0e302014-03-27 15:40:39 +00006/// Comment for 'functionBeforeImports'.
7void functionBeforeImports(void);
8
9#import <DocCommentsA/DocCommentsA.h>
10#import <DocCommentsB/DocCommentsB.h>
11
Dmitri Gribenko46dd39e2013-08-19 07:10:13 +000012@class NSString;
13
14//===---
15// rdar://14258334
16// Check that we attach comments to properties correctly.
17//===---
18
19@interface MyClass {
20}
21
22/// property1_isdoxy1 IS_DOXYGEN_SINGLE
23@property (nonatomic, copy, readwrite) NSString *property1_isdoxy1;
24@property (nonatomic, copy, readwrite) NSString *property1_isdoxy2; ///< property1_isdoxy2 IS_DOXYGEN_SINGLE
25@property (nonatomic, copy, readwrite) NSString *property1_isdoxy3; /**< property1_isdoxy3 IS_DOXYGEN_SINGLE */
26@property (nonatomic, copy, readwrite) NSString *property1_isdoxy4; /*!< property1_isdoxy4 IS_DOXYGEN_SINGLE */
27
28/// method1_isdoxy1 IS_DOXYGEN_SINGLE
29- (void)method1_isdoxy1;
30- (void)method1_isdoxy2; /*!< method1_isdoxy2 IS_DOXYGEN_SINGLE */
31- (void)method1_isdoxy3; /*!< method1_isdoxy3 IS_DOXYGEN_SINGLE */
32- (void)method1_isdoxy4; /*!< method1_isdoxy4 IS_DOXYGEN_SINGLE */
33@end
34
35
36#endif
37
38// RUN: rm -rf %t
39// RUN: mkdir %t
Dmitri Gribenkoabfa2612014-03-27 16:15:30 +000040// RUN: mkdir %t/module-cache
Dmitri Gribenko46dd39e2013-08-19 07:10:13 +000041
42// Check that we serialize comment source locations properly.
Dmitri Gribenko9ee0e302014-03-27 15:40:39 +000043// RUN: %clang_cc1 -emit-pch -o %t/out.pch -F %S/Inputs/Frameworks %s
44// RUN: %clang_cc1 -include-pch %t/out.pch -F %S/Inputs/Frameworks -fsyntax-only %s
Dmitri Gribenko46dd39e2013-08-19 07:10:13 +000045
Dmitri Gribenko9ee0e302014-03-27 15:40:39 +000046// 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
Dmitri Gribenkoabfa2612014-03-27 16:15:30 +000047// 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
Dmitri Gribenko9ee0e302014-03-27 15:40:39 +000048// RUN: c-index-test -test-load-tu %t/out.pch all -F %S/Inputs/Frameworks > %t/out.c-index-pch
Dmitri Gribenko46dd39e2013-08-19 07:10:13 +000049
50// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct
Dmitri Gribenko9ee0e302014-03-27 15:40:39 +000051// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-modules
Dmitri Gribenko46dd39e2013-08-19 07:10:13 +000052// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-pch
53
54// Declarations without Doxygen comments should not pick up some Doxygen comments.
55// WRONG-NOT: notdoxy{{.*}}Comment=
56// WRONG-NOT: test{{.*}}Comment=
57
58// Non-Doxygen comments should not be attached to anything.
59// WRONG-NOT: NOT_DOXYGEN
60
61// Some Doxygen comments are not attached to anything.
62// WRONG-NOT: IS_DOXYGEN_NOT_ATTACHED
63
64// Ensure we don't pick up extra comments.
65// WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START{{.*}}BriefComment=
66// WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END{{.*}}BriefComment=
67//
68// Ensure that XML is not invalid
69// WRONG-NOT: CommentXMLInvalid
70
71// RUN: FileCheck %s < %t/out.c-index-direct
Dmitri Gribenko9ee0e302014-03-27 15:40:39 +000072// RUN: FileCheck %s < %t/out.c-index-modules
Dmitri Gribenko46dd39e2013-08-19 07:10:13 +000073// RUN: FileCheck %s < %t/out.c-index-pch
74
75// These CHECK lines are not located near the code on purpose. This test
76// checks that documentation comments are attached to declarations correctly.
77// Adding a non-documentation comment with CHECK line between every two
78// documentation comments will only test a single code path.
79//
Dmitri Gribenko9ee0e302014-03-27 15:40:39 +000080// CHECK-DAG: annotate-comments-objc.m:7:6: FunctionDecl=functionBeforeImports:{{.*}} BriefComment=[Comment for 'functionBeforeImports'.]
81// CHECK-DAG: DocCommentsA.h:2:6: FunctionDecl=functionFromDocCommentsA1:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsA1'.]
82// CHECK-DAG: DocCommentsA.h:7:6: FunctionDecl=functionFromDocCommentsA2:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsA2'.]
83// CHECK-DAG: DocCommentsB.h:2:6: FunctionDecl=functionFromDocCommentsB1:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsB1'.]
84// CHECK-DAG: DocCommentsB.h:7:6: FunctionDecl=functionFromDocCommentsB2:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsB2'.]
85// CHECK-DAG: DocCommentsC.h:2:6: FunctionDecl=functionFromDocCommentsC:{{.*}} BriefComment=[Comment for 'functionFromDocCommentsC'.]
86// CHECK: annotate-comments-objc.m:23:50: ObjCPropertyDecl=property1_isdoxy1:{{.*}} property1_isdoxy1 IS_DOXYGEN_SINGLE
87// CHECK: annotate-comments-objc.m:24:50: ObjCPropertyDecl=property1_isdoxy2:{{.*}} property1_isdoxy2 IS_DOXYGEN_SINGLE
88// CHECK: annotate-comments-objc.m:25:50: ObjCPropertyDecl=property1_isdoxy3:{{.*}} property1_isdoxy3 IS_DOXYGEN_SINGLE
89// CHECK: annotate-comments-objc.m:26:50: ObjCPropertyDecl=property1_isdoxy4:{{.*}} property1_isdoxy4 IS_DOXYGEN_SINGLE
90// CHECK: annotate-comments-objc.m:29:9: ObjCInstanceMethodDecl=method1_isdoxy1:{{.*}} method1_isdoxy1 IS_DOXYGEN_SINGLE
91// CHECK: annotate-comments-objc.m:30:9: ObjCInstanceMethodDecl=method1_isdoxy2:{{.*}} method1_isdoxy2 IS_DOXYGEN_SINGLE
92// CHECK: annotate-comments-objc.m:31:9: ObjCInstanceMethodDecl=method1_isdoxy3:{{.*}} method1_isdoxy3 IS_DOXYGEN_SINGLE
93// CHECK: annotate-comments-objc.m:32:9: ObjCInstanceMethodDecl=method1_isdoxy4:{{.*}} method1_isdoxy4 IS_DOXYGEN_SINGLE
Dmitri Gribenko46dd39e2013-08-19 07:10:13 +000094