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