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