blob: 37bb70f30750c378e7f18376b1cc69621a0268ca [file] [log] [blame]
Douglas Gregor40749ee2010-11-03 00:35:38 +00001// Test is line- and column-sensitive. Run lines are below.
2
3struct X {
4 X();
5 X(int);
6 X(int, int);
7 X(const X&);
8};
9
10X getX(int value) {
11 switch (value) {
12 case 1: return X(value);
13 case 2: return X(value, value);
14 case 3: return (X)value;
15 default: break;
16 }
17 return X();
18}
19
Douglas Gregor89629a72010-11-17 17:15:08 +000020struct Y {
21 int member;
22
23 X getX();
24};
25
26X Y::getX() {
27 return member;
28}
29
30struct YDerived : Y {
31 X getAnotherX() { return member; }
32};
33
Argyrios Kyrtzidis064c44b2011-06-27 19:42:23 +000034void test() {
35 X foo;
Argyrios Kyrtzidisdcbb2fb2011-12-03 03:49:44 +000036
37 try {
38 } catch (X e) {
39 X x;
40 }
Argyrios Kyrtzidis5641b0d2012-05-16 23:49:15 +000041
42 struct LocalS {
43 void meth() {
44 int x;
45 ++x;
46 }
47 };
Argyrios Kyrtzidis064c44b2011-06-27 19:42:23 +000048}
49
Argyrios Kyrtzidis516143b2013-04-05 21:04:10 +000050template <bool (*tfn)(X*)>
51struct TS {
52 void foo();
53};
54
55template <bool (*tfn)(X*)>
56void TS<tfn>::foo() {}
57
Douglas Gregor8fa0a802011-08-04 20:04:59 +000058// RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
59// CHECK-COMPLETION-1: CXXConstructor=X:6:3
60// CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
61
62// RUN: c-index-test -cursor-at=%s:31:16 %s | FileCheck -check-prefix=CHECK-COMPLETION-2 %s
63// CHECK-COMPLETION-2: CXXMethod=getAnotherX:31:5 (Definition)
64// CHECK-COMPLETION-2-NEXT: Completion string: {ResultType X}{TypedText getAnotherX}{LeftParen (}{RightParen )}
65
Douglas Gregor40749ee2010-11-03 00:35:38 +000066// RUN: c-index-test -cursor-at=%s:12:20 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
67// RUN: c-index-test -cursor-at=%s:13:21 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
68// RUN: c-index-test -cursor-at=%s:13:28 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
69// RUN: c-index-test -cursor-at=%s:14:23 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
70// CHECK-VALUE-REF: DeclRefExpr=value:10:12
71
Douglas Gregor93798e22010-11-05 21:11:19 +000072// RUN: c-index-test -cursor-at=%s:12:18 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
73// RUN: c-index-test -cursor-at=%s:13:18 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR2 %s
74// RUN: c-index-test -cursor-at=%s:14:19 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
75// RUN: c-index-test -cursor-at=%s:17:10 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR3 %s
Douglas Gregor40749ee2010-11-03 00:35:38 +000076// CHECK-TYPE-REF: TypeRef=struct X:3:8
Douglas Gregor93798e22010-11-05 21:11:19 +000077// CHECK-CONSTRUCTOR1: CallExpr=X:5:3
78// CHECK-CONSTRUCTOR2: CallExpr=X:6:3
79// CHECK-CONSTRUCTOR3: CallExpr=X:4:3
Douglas Gregor89629a72010-11-17 17:15:08 +000080
81// RUN: c-index-test -cursor-at=%s:23:3 %s | FileCheck -check-prefix=CHECK-RETTYPE %s
82// RUN: c-index-test -cursor-at=%s:26:1 %s | FileCheck -check-prefix=CHECK-RETTYPE %s
83// CHECK-RETTYPE: TypeRef=struct X:3:8
84
85// RUN: c-index-test -cursor-at=%s:23:7 %s | FileCheck -check-prefix=CHECK-MEMFUNC-DECL %s
86// CHECK-MEMFUNC-DECL: CXXMethod=getX:23:5
87// RUN: c-index-test -cursor-at=%s:26:7 %s | FileCheck -check-prefix=CHECK-MEMFUNC-DEF %s
88// CHECK-MEMFUNC-DEF: CXXMethod=getX:26:6
89
90// RUN: c-index-test -cursor-at=%s:26:3 %s | FileCheck -check-prefix=CHECK-TYPEREF-Y %s
91// CHECK-TYPEREF-Y: TypeRef=struct Y:20:8
92
93// RUN: c-index-test -cursor-at=%s:27:10 %s | FileCheck -check-prefix=CHECK-IMPLICIT-MEMREF %s
94// RUN: c-index-test -cursor-at=%s:31:28 %s | FileCheck -check-prefix=CHECK-IMPLICIT-MEMREF %s
95// CHECK-IMPLICIT-MEMREF: MemberRefExpr=member:21:7
Argyrios Kyrtzidis064c44b2011-06-27 19:42:23 +000096
97// RUN: c-index-test -cursor-at=%s:35:5 %s | FileCheck -check-prefix=CHECK-DECL %s
98// CHECK-DECL: VarDecl=foo:35:5
Douglas Gregor8fa0a802011-08-04 20:04:59 +000099
100// RUN: c-index-test -cursor-at=%s:21:3 %s | FileCheck -check-prefix=CHECK-MEMBER %s
101// CHECK-MEMBER: FieldDecl=member:21:7 (Definition)
102// CHECK-MEMBER-NEXT: Completion string: {ResultType int}{TypedText member}
Argyrios Kyrtzidisdcbb2fb2011-12-03 03:49:44 +0000103
104// RUN: c-index-test -cursor-at=%s:38:12 -cursor-at=%s:39:5 %s | FileCheck -check-prefix=CHECK-CXXCATCH %s
105// CHECK-CXXCATCH: TypeRef=struct X:3:8
106// CHECK-CXXCATCH-NEXT: TypeRef=struct X:3:8
Argyrios Kyrtzidisd977e6b2011-12-03 03:49:47 +0000107
108// RUN: c-index-test -test-load-source-usrs local %s | FileCheck -check-prefix=CHECK-USR %s
109// CHECK-USR: get-cursor.cpp c:get-cursor.cpp@472@F@test#@e Extent=[38:12 - 38:15]
110// CHECK-USR: get-cursor.cpp c:get-cursor.cpp@483@F@test#@x Extent=[39:5 - 39:8]
Argyrios Kyrtzidis5641b0d2012-05-16 23:49:15 +0000111
112// RUN: c-index-test -cursor-at=%s:45:9 %s | FileCheck -check-prefix=CHECK-LOCALCLASS %s
113// CHECK-LOCALCLASS: 45:9 DeclRefExpr=x:44:11 Extent=[45:9 - 45:10] Spelling=x ([45:9 - 45:10])
Argyrios Kyrtzidis516143b2013-04-05 21:04:10 +0000114
115// RUN: c-index-test -cursor-at=%s:50:23 -cursor-at=%s:55:23 %s | FileCheck -check-prefix=CHECK-TEMPLPARAM %s
116// CHECK-TEMPLPARAM: 50:23 TypeRef=struct X:3:8 Extent=[50:23 - 50:24] Spelling=struct X ([50:23 - 50:24])
117// CHECK-TEMPLPARAM: 55:23 TypeRef=struct X:3:8 Extent=[55:23 - 55:24] Spelling=struct X ([55:23 - 55:24])