aboutsummaryrefslogtreecommitdiff
path: root/test/CodeCompletion
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeCompletion')
-rw-r--r--test/CodeCompletion/accessibility-crash.cpp23
-rw-r--r--test/CodeCompletion/accessibility.cpp122
-rw-r--r--test/CodeCompletion/call.cpp2
-rw-r--r--test/CodeCompletion/crash-func-decl.cpp5
-rw-r--r--test/CodeCompletion/ctor-initializer.cpp85
-rw-r--r--test/CodeCompletion/function-overloads.cpp43
-rw-r--r--test/CodeCompletion/included-files.cpp35
-rw-r--r--test/CodeCompletion/member-access.c19
-rw-r--r--test/CodeCompletion/member-access.cpp70
-rw-r--r--test/CodeCompletion/objc-message.mm2
-rw-r--r--test/CodeCompletion/objc-protocol-member-access.m4
-rw-r--r--test/CodeCompletion/ordinary-name-cxx11.cpp1
-rw-r--r--test/CodeCompletion/ordinary-name.cpp1
-rw-r--r--test/CodeCompletion/overrides.cpp33
-rw-r--r--test/CodeCompletion/paren_locs.cpp33
-rw-r--r--test/CodeCompletion/pragma-macro-token-caching.c2
-rw-r--r--test/CodeCompletion/preferred-type.cpp15
-rw-r--r--test/CodeCompletion/self-inits.cpp3
-rw-r--r--test/CodeCompletion/signatures-crash.cpp15
-rw-r--r--test/CodeCompletion/this-quals.cpp21
20 files changed, 469 insertions, 65 deletions
diff --git a/test/CodeCompletion/accessibility-crash.cpp b/test/CodeCompletion/accessibility-crash.cpp
new file mode 100644
index 000000000000..b54f7cea3e20
--- /dev/null
+++ b/test/CodeCompletion/accessibility-crash.cpp
@@ -0,0 +1,23 @@
+class X {
+public:
+ int pub;
+protected:
+ int prot;
+private:
+ int priv;
+};
+
+class Y : public X {
+ int test() {
+ []() {
+
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:1 %s -o - \
+ // RUN: | FileCheck %s
+ // CHECK: priv (InBase,Inaccessible)
+ // CHECK: prot (InBase)
+ // CHECK: pub (InBase)
+ };
+ }
+};
+
+
diff --git a/test/CodeCompletion/accessibility.cpp b/test/CodeCompletion/accessibility.cpp
new file mode 100644
index 000000000000..a050efc9a73d
--- /dev/null
+++ b/test/CodeCompletion/accessibility.cpp
@@ -0,0 +1,122 @@
+class X {
+public:
+ int pub;
+protected:
+ int prot;
+private:
+ int priv;
+};
+
+class Unrelated {
+public:
+ static int pub;
+protected:
+ static int prot;
+private:
+ static int priv;
+};
+
+class Y : public X {
+ int test() {
+ this->pub = 10;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:21:11 %s -o - \
+ // RUN: | FileCheck -check-prefix=THIS %s
+ // THIS: priv (InBase,Inaccessible)
+ // THIS: prot (InBase)
+ // THIS: pub (InBase)
+ //
+ // Also check implicit 'this->', i.e. complete at the start of the line.
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:21:1 %s -o - \
+ // RUN: | FileCheck -check-prefix=THIS %s
+
+ X().pub + 10;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:9 %s -o - \
+ // RUN: | FileCheck -check-prefix=X-OBJ %s
+ // X-OBJ: priv (Inaccessible)
+ // X-OBJ: prot (Inaccessible)
+ // X-OBJ: pub : [#int#]pub
+
+ Y().pub + 10;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:39:9 %s -o - \
+ // RUN: | FileCheck -check-prefix=Y-OBJ %s
+ // Y-OBJ: priv (InBase,Inaccessible)
+ // Y-OBJ: prot (InBase)
+ // Y-OBJ: pub (InBase)
+
+ this->X::pub = 10;
+ X::pub = 10;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:46:14 %s -o - \
+ // RUN: | FileCheck -check-prefix=THIS-BASE %s
+ //
+ // THIS-BASE: priv (Inaccessible)
+ // THIS-BASE: prot : [#int#]prot
+ // THIS-BASE: pub : [#int#]pub
+ //
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:47:8 %s -o - \
+ // RUN: | FileCheck -check-prefix=THIS-BASE %s
+
+
+ this->Unrelated::pub = 10; // a check we don't crash in this cases.
+ Y().Unrelated::pub = 10; // a check we don't crash in this cases.
+ Unrelated::pub = 10;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:59:22 %s -o - \
+ // RUN: | FileCheck -check-prefix=UNRELATED %s
+ // UNRELATED: priv (Inaccessible)
+ // UNRELATED: prot (Inaccessible)
+ // UNRELATED: pub : [#int#]pub
+ //
+ // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:60:20 %s -o - \
+ // RUN: | FileCheck -check-prefix=UNRELATED %s
+ // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:61:16 %s -o - \
+ // RUN: | FileCheck -check-prefix=UNRELATED %s
+ }
+};
+
+class Outer {
+ public:
+ static int pub;
+ protected:
+ static int prot;
+ private:
+ static int priv;
+
+ class Inner {
+ int test() {
+ Outer::pub = 10;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:85:14 %s -o - \
+ // RUN: | FileCheck -check-prefix=OUTER %s
+ // OUTER: priv : [#int#]priv
+ // OUTER: prot : [#int#]prot
+ // OUTER: pub : [#int#]pub
+
+ // Also check the unqualified case.
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:85:1 %s -o - \
+ // RUN: | FileCheck -check-prefix=OUTER %s
+ }
+ };
+};
+
+class Base {
+public:
+ int pub;
+};
+
+class Accessible : public Base {
+};
+
+class Inaccessible : private Base {
+};
+
+class Test : public Accessible, public Inaccessible {
+ int test() {
+ this->Accessible::pub = 10;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:112:23 %s -o - \
+ // RUN: | FileCheck -check-prefix=ACCESSIBLE %s
+ // ACCESSIBLE: pub (InBase)
+
+ this->Inaccessible::pub = 10;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:117:25 %s -o - \
+ // RUN: | FileCheck -check-prefix=INACCESSIBLE %s
+ // INACCESSIBLE: pub (InBase,Inaccessible)
+ }
+};
diff --git a/test/CodeCompletion/call.cpp b/test/CodeCompletion/call.cpp
index 3e062109a9aa..c57c339cd130 100644
--- a/test/CodeCompletion/call.cpp
+++ b/test/CodeCompletion/call.cpp
@@ -18,10 +18,10 @@ void f();
void test() {
f(Y(), 0, 0);
// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
- // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
// CHECK-CC1: f(Y y, <#int ZZ#>)
// CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
// CHECK-CC1-NEXT: f(float x, <#float y#>)
+ // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2-NOT: f(Y y, int ZZ)
// CHECK-CC2: f(int i, int j, <#int k#>)
diff --git a/test/CodeCompletion/crash-func-decl.cpp b/test/CodeCompletion/crash-func-decl.cpp
new file mode 100644
index 000000000000..7abcdcdb271f
--- /dev/null
+++ b/test/CodeCompletion/crash-func-decl.cpp
@@ -0,0 +1,5 @@
+// Important that BB is unknown.
+// This triggers completion in PCC_RecoveryInFunction context, with no function.
+int AA(BB cc);
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:12 %s | FileCheck %s
+// CHECK: COMPLETION: char
diff --git a/test/CodeCompletion/ctor-initializer.cpp b/test/CodeCompletion/ctor-initializer.cpp
index e1a0d1436874..ead99f087ca8 100644
--- a/test/CodeCompletion/ctor-initializer.cpp
+++ b/test/CodeCompletion/ctor-initializer.cpp
@@ -2,14 +2,14 @@ struct Base1 {
Base1() : {}
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
- // CHECK-CC1: COMPLETION: Pattern : member1(<#args#>)
- // CHECK-CC1: COMPLETION: Pattern : member2(<#args#>
+ // CHECK-CC1: COMPLETION: Pattern : member1(<#int#>)
+ // CHECK-CC1: COMPLETION: Pattern : member2(<#float#>)
Base1(int) : member1(123), {}
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:8:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:8:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
- // CHECK-CC2-NOT: COMPLETION: Pattern : member1(<#args#>)
- // CHECK-CC2: COMPLETION: Pattern : member2(<#args#>
+ // CHECK-CC2-NOT: COMPLETION: Pattern : member1(<#int#>)
+ // CHECK-CC2: COMPLETION: Pattern : member2(<#float#>)
int member1;
float member2;
@@ -25,42 +25,81 @@ struct Derived : public Base1 {
Derived::Derived() : {}
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:25:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:25:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3: COMPLETION: Pattern : Base1(<#args#>)
-// CHECK-CC3: COMPLETION: Pattern : deriv1(<#args#>)
+// CHECK-CC3: COMPLETION: Pattern : Base1()
+// CHECK-CC3: COMPLETION: Pattern : Base1(<#int#>)
+// CHECK-CC3: COMPLETION: Pattern : deriv1(<#int#>)
Derived::Derived(int) try : {
} catch (...) {
}
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:31:29 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:31:29 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
-// CHECK-CC4: COMPLETION: Pattern : Base1(<#args#>)
-// CHECK-CC4: COMPLETION: Pattern : deriv1(<#args#>)
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:32:29 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:32:29 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
Derived::Derived(float) try : Base1(),
{
} catch (...) {
}
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:39:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:39:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
-// CHECK-CC5-NOT: COMPLETION: Pattern : Base1(<#args#>)
-// CHECK-CC5: COMPLETION: Pattern : deriv1(<#args#>)
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:38:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:38:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5-NOT: COMPLETION: Pattern : Base1
+// CHECK-CC5: COMPLETION: Pattern : deriv1(<#int#>)
struct A {
A() : , member2() {}
- // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:49:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
- // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:49:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
- // CHECK-CC6: COMPLETION: Pattern : member1(<#args#>
+ // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:48:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+ // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:48:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+ // CHECK-CC6: COMPLETION: Pattern : member1(<#int#>)
int member1, member2;
};
struct B {
B() : member2() {}
- // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
- // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
- // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+ // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+ // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:56:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+ // CHECK-CC7: COMPLETION: Pattern : member1(<#int#>)
// Check in the middle and at the end of identifier too.
- // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
- // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
- // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
+ // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+ // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:16 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+ // CHECK-CC8: COMPLETION: Pattern : member2(<#int#>)
int member1, member2;
};
+
+struct Base2 {
+ Base2(int);
+};
+
+struct Composition1 {
+ Composition1() : b2_elem(2) {}
+ // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:72:28 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+ // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:72:28 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+ // CHECK-CC9: OVERLOAD: Base2(<#int#>)
+ // CHECK-CC9: OVERLOAD: Base2(<#const Base2 &#>)
+ // CHECK-CC9-NOT: OVERLOAD: Composition1
+ Composition1(Base2);
+ Base2 b2_elem;
+};
+
+struct Composition2 {
+ Composition2() : c1_elem(Base2(1)) {}
+ // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:34 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+ // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:34 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+ // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:35 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+ // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:35 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+ Composition1 c1_elem;
+};
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:20 %s -o - | FileCheck -check-prefix=CHECK-CC10 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:20 %s -o - | FileCheck -check-prefix=CHECK-CC10 %s
+// CHECK-CC10: Pattern : c1_elem()
+// CHECK-CC10: Pattern : c1_elem(<#Base2#>)
+
+template <class T>
+struct Y : T {};
+
+template <class T>
+struct X : Y<T> {
+ X() : Y<T>() {};
+};
+
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:100:9 %s -o - | FileCheck -check-prefix=CHECK-CC11 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:100:9 %s -o - | FileCheck -check-prefix=CHECK-CC11 %s
+// CHECK-CC11: Pattern : Y<T>(<#Y<T>#>)
diff --git a/test/CodeCompletion/function-overloads.cpp b/test/CodeCompletion/function-overloads.cpp
new file mode 100644
index 000000000000..11c864c28107
--- /dev/null
+++ b/test/CodeCompletion/function-overloads.cpp
@@ -0,0 +1,43 @@
+int f(int i, int j = 2, int k = 5);
+int f(float x, float y...);
+
+class A {
+ public:
+ A(int, int, int);
+};
+
+void test() {
+ A a(f(1, 2, 3, 4), 2, 3);
+}
+
+
+namespace NS {
+ struct X { };
+ struct Y { Y(X); };
+ template <class T = int>
+ void g(X, Y);
+}
+
+void test_adl() {
+ NS::X x;
+ g(x, x);
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:17 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:19 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:20 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:21 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:7 %s -o - | \
+// RUN: FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC1: OVERLOAD: [#int#]f(<#float x#>, float y)
+// CHECK-CC1: OVERLOAD: [#int#]f(<#int i#>)
+// CHECK-CC1-NOT, CHECK-CC2-NOT: OVERLOAD: A(
+// CHECK-CC2: OVERLOAD: [#int#]f(float x, float y)
+// CHECK-CC2-NOT: OVERLOAD: [#int#]f(int i)
+// CHECK-CC3: OVERLOAD: A(<#int#>, int, int)
+// CHECK-CC3: OVERLOAD: A(<#const A &#>)
+// CHECK-CC3: OVERLOAD: A(<#A &&#>)
+// CHECK-CC4: OVERLOAD: A(int, <#int#>, int)
+// CHECK-CC5: OVERLOAD: [#void#]g(X, <#Y#>)
diff --git a/test/CodeCompletion/included-files.cpp b/test/CodeCompletion/included-files.cpp
new file mode 100644
index 000000000000..ba153e6e2754
--- /dev/null
+++ b/test/CodeCompletion/included-files.cpp
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a
+// RUN: touch %t/foo.h && touch %t/foo.cc && touch %t/a/foosys %t/a/foosys.h
+
+// Quoted string shows header-ish files from CWD, and all from system.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:5:13 %t/main.cc | FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1-NOT: foo.cc"
+// CHECK-1: foo.h"
+// CHECK-1: foosys"
+
+// Quoted string with dir shows header-ish files in that subdir.
+#include "a/foosys"
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:12:13 %t/main.cc | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2-NOT: foo.h"
+// CHECK-2: foosys.h"
+// CHECK-2-NOT: foosys"
+
+// Angled shows headers from system dirs.
+#include <foosys>
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:19:13 %t/main.cc | FileCheck -check-prefix=CHECK-3 %s
+// CHECK-3-NOT: foo.cc>
+// CHECK-3-NOT: foo.h>
+// CHECK-3: foosys>
+
+// With -I rather than -isystem, the header extension is required.
+#include <foosys>
+// RUN: %clang -fsyntax-only -I %t/a -Xclang -code-completion-at=%t/main.cc:26:13 %t/main.cc | FileCheck -check-prefix=CHECK-4 %s
+// CHECK-4-NOT: foo.cc>
+// CHECK-4-NOT: foo.h>
+// CHECK-4-NOT: foosys>
+
+// Backslash handling.
+#include "a\foosys"
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:33:13 %t/main.cc -fms-compatibility | FileCheck -check-prefix=CHECK-5 %s
+// CHECK-5: foosys.h"
diff --git a/test/CodeCompletion/member-access.c b/test/CodeCompletion/member-access.c
index 226e182ab15f..72afbf2ff947 100644
--- a/test/CodeCompletion/member-access.c
+++ b/test/CodeCompletion/member-access.c
@@ -10,3 +10,22 @@ void test(struct Point *p) {
// CHECK-CC1: x
// CHECK-CC1: y
// CHECK-CC1: z
+}
+
+struct Point2 {
+ float x;
+};
+
+void test2(struct Point2 p) {
+ p->
+}
+
+void test3(struct Point2 *p) {
+ p.
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:20:6 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: x (requires fix-it: {20:4-20:6} to ".")
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:24:5 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: x (requires fix-it: {24:4-24:5} to "->")
diff --git a/test/CodeCompletion/member-access.cpp b/test/CodeCompletion/member-access.cpp
index 008e223716bb..003d224fbe24 100644
--- a/test/CodeCompletion/member-access.cpp
+++ b/test/CodeCompletion/member-access.cpp
@@ -51,16 +51,16 @@ struct Bar {
};
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:31:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 --implicit-check-not="Derived : Derived(" %s
- // CHECK-CC1: Base1 : Base1::
- // CHECK-CC1: member1 : [#int#][#Base1::#]member1
- // CHECK-CC1: member1 : [#int#][#Base2::#]member1
- // CHECK-CC1: member2 : [#float#][#Base1::#]member2
- // CHECK-CC1: member3
+ // CHECK-CC1: Base1 (InBase) : Base1::
+ // CHECK-CC1: member1 (InBase) : [#int#][#Base1::#]member1
+ // CHECK-CC1: member1 (InBase) : [#int#][#Base2::#]member1
+ // CHECK-CC1: member2 (InBase) : [#float#][#Base1::#]member2
+ // CHECK-CC1: member3 (InBase)
// CHECK-CC1: member4
- // CHECK-CC1: memfun1 : [#void#][#Base3::#]memfun1(<#float#>)
- // CHECK-CC1: memfun1 : [#void#][#Base3::#]memfun1(<#double#>)[# const#]
- // CHECK-CC1: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>)
- // CHECK-CC1: memfun2 : [#void#][#Base3::#]memfun2(<#int#>)
+ // CHECK-CC1: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#float#>)
+ // CHECK-CC1: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#double#>)[# const#]
+ // CHECK-CC1: memfun1 (Hidden,InBase) : [#void#]Base2::memfun1(<#int#>)
+ // CHECK-CC1: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>)
// CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>)
// Make sure this doesn't crash
@@ -93,12 +93,12 @@ void completeDependentMembers(TemplateClass<T, S> &object,
TemplateClass<int, S> *object2) {
object.field;
object2->field;
-// CHECK-CC2: baseTemplateField : [#T#][#BaseTemplate<T>::#]baseTemplateField
-// CHECK-CC2: baseTemplateFunction : [#T#][#BaseTemplate<T>::#]baseTemplateFunction()
+// CHECK-CC2: baseTemplateField (InBase) : [#T#][#BaseTemplate<T>::#]baseTemplateField
+// CHECK-CC2: baseTemplateFunction (InBase) : [#T#][#BaseTemplate<T>::#]baseTemplateFunction()
// CHECK-CC2: field : [#T#]field
// CHECK-CC2: function : [#T#]function()
-// CHECK-CC2: member1 : [#int#][#Base1::#]member1
-// CHECK-CC2: member2 : [#float#][#Base1::#]member2
+// CHECK-CC2: member1 (InBase) : [#int#][#Base1::#]member1
+// CHECK-CC2: member2 (InBase) : [#float#][#Base1::#]member2
// CHECK-CC2: overload1 : [#void#]overload1(<#const T &#>)
// CHECK-CC2: overload1 : [#void#]overload1(<#const S &#>)
@@ -111,12 +111,12 @@ void completeDependentSpecializedMembers(TemplateClass<int, double> &object,
TemplateClass<int, double> *object2) {
object.field;
object2->field;
-// CHECK-CC3: baseTemplateField : [#int#][#BaseTemplate<int>::#]baseTemplateField
-// CHECK-CC3: baseTemplateFunction : [#int#][#BaseTemplate<int>::#]baseTemplateFunction()
+// CHECK-CC3: baseTemplateField (InBase) : [#int#][#BaseTemplate<int>::#]baseTemplateField
+// CHECK-CC3: baseTemplateFunction (InBase) : [#int#][#BaseTemplate<int>::#]baseTemplateFunction()
// CHECK-CC3: field : [#int#]field
// CHECK-CC3: function : [#int#]function()
-// CHECK-CC3: member1 : [#int#][#Base1::#]member1
-// CHECK-CC3: member2 : [#float#][#Base1::#]member2
+// CHECK-CC3: member1 (InBase) : [#int#][#Base1::#]member1
+// CHECK-CC3: member2 (InBase) : [#float#][#Base1::#]member2
// CHECK-CC3: overload1 : [#void#]overload1(<#const int &#>)
// CHECK-CC3: overload1 : [#void#]overload1(<#const double &#>)
@@ -182,31 +182,31 @@ void test3(const Proxy2 &p) {
}
// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:177:6 %s -o - | FileCheck -check-prefix=CHECK-CC8 --implicit-check-not="Derived : Derived(" %s
-// CHECK-CC8: Base1 : Base1::
-// CHECK-CC8: member1 : [#int#][#Base1::#]member1
-// CHECK-CC8: member1 : [#int#][#Base2::#]member1
-// CHECK-CC8: member2 : [#float#][#Base1::#]member2
-// CHECK-CC8: member3 : [#double#][#Base2::#]member3
+// CHECK-CC8: Base1 (InBase) : Base1::
+// CHECK-CC8: member1 (InBase) : [#int#][#Base1::#]member1
+// CHECK-CC8: member1 (InBase) : [#int#][#Base2::#]member1
+// CHECK-CC8: member2 (InBase) : [#float#][#Base1::#]member2
+// CHECK-CC8: member3 (InBase) : [#double#][#Base2::#]member3
// CHECK-CC8: member4 : [#int#]member4
// CHECK-CC8: member5 : [#int#]member5 (requires fix-it: {177:4-177:6} to ".")
-// CHECK-CC8: memfun1 : [#void#][#Base3::#]memfun1(<#float#>)
-// CHECK-CC8: memfun1 : [#void#][#Base3::#]memfun1(<#double#>)[# const#]
-// CHECK-CC8: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>)
-// CHECK-CC8: memfun2 : [#void#][#Base3::#]memfun2(<#int#>)
+// CHECK-CC8: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#float#>)
+// CHECK-CC8: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#double#>)[# const#]
+// CHECK-CC8: memfun1 (Hidden,InBase) : [#void#]Base2::memfun1(<#int#>)
+// CHECK-CC8: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>)
// CHECK-CC8: memfun3 : [#int#]memfun3(<#int#>)
// CHECK-CC8: operator-> : [#Derived *#]operator->()[# const#] (requires fix-it: {177:4-177:6} to ".")
// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:181:6 %s -o - | FileCheck -check-prefix=CHECK-CC9 --implicit-check-not="Derived : Derived(" %s
-// CHECK-CC9: Base1 : Base1::
-// CHECK-CC9: member1 : [#int#][#Base1::#]member1 (requires fix-it: {181:4-181:5} to "->")
-// CHECK-CC9: member1 : [#int#][#Base2::#]member1 (requires fix-it: {181:4-181:5} to "->")
-// CHECK-CC9: member2 : [#float#][#Base1::#]member2 (requires fix-it: {181:4-181:5} to "->")
-// CHECK-CC9: member3 : [#double#][#Base2::#]member3 (requires fix-it: {181:4-181:5} to "->")
+// CHECK-CC9: Base1 (InBase) : Base1::
+// CHECK-CC9: member1 (InBase) : [#int#][#Base1::#]member1 (requires fix-it: {181:4-181:5} to "->")
+// CHECK-CC9: member1 (InBase) : [#int#][#Base2::#]member1 (requires fix-it: {181:4-181:5} to "->")
+// CHECK-CC9: member2 (InBase) : [#float#][#Base1::#]member2 (requires fix-it: {181:4-181:5} to "->")
+// CHECK-CC9: member3 (InBase) : [#double#][#Base2::#]member3 (requires fix-it: {181:4-181:5} to "->")
// CHECK-CC9: member4 : [#int#]member4 (requires fix-it: {181:4-181:5} to "->")
// CHECK-CC9: member5 : [#int#]member5
-// CHECK-CC9: memfun1 : [#void#][#Base3::#]memfun1(<#float#>) (requires fix-it: {181:4-181:5} to "->")
-// CHECK-CC9: memfun1 : [#void#][#Base3::#]memfun1(<#double#>)[# const#] (requires fix-it: {181:4-181:5} to "->")
-// CHECK-CC9: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>) (requires fix-it: {181:4-181:5} to "->")
-// CHECK-CC9: memfun2 : [#void#][#Base3::#]memfun2(<#int#>) (requires fix-it: {181:4-181:5} to "->")
+// CHECK-CC9: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#float#>) (requires fix-it: {181:4-181:5} to "->")
+// CHECK-CC9: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#double#>)[# const#] (requires fix-it: {181:4-181:5} to "->")
+// CHECK-CC9: memfun1 (Hidden,InBase) : [#void#]Base2::memfun1(<#int#>) (requires fix-it: {181:4-181:5} to "->")
+// CHECK-CC9: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>) (requires fix-it: {181:4-181:5} to "->")
// CHECK-CC9: memfun3 : [#int#]memfun3(<#int#>) (requires fix-it: {181:4-181:5} to "->")
// CHECK-CC9: operator-> : [#Derived *#]operator->()[# const#]
diff --git a/test/CodeCompletion/objc-message.mm b/test/CodeCompletion/objc-message.mm
index 7a503097e076..33f392f5e0dc 100644
--- a/test/CodeCompletion/objc-message.mm
+++ b/test/CodeCompletion/objc-message.mm
@@ -41,6 +41,6 @@ void func(const RetainPtr<id <FooTestProtocol>>& ptr)
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-at=%s:33:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: categoryInstanceMethod : [#id#]categoryInstanceMethod
// CHECK-CC1: instanceMethod1 : [#id#]instanceMethod1
-// CHECK-CC1: protocolInstanceMethod : [#id#]protocolInstanceMethod
+// CHECK-CC1: protocolInstanceMethod (InBase) : [#id#]protocolInstanceMethod
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-at=%s:38:8 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: protocolInstanceMethod : [#id#]protocolInstanceMethod
diff --git a/test/CodeCompletion/objc-protocol-member-access.m b/test/CodeCompletion/objc-protocol-member-access.m
index 0ed55387e3d6..9e769d5afa86 100644
--- a/test/CodeCompletion/objc-protocol-member-access.m
+++ b/test/CodeCompletion/objc-protocol-member-access.m
@@ -19,6 +19,6 @@ int getFoo(id object) {
}
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:25 %s -o - | FileCheck %s
-// CHECK: bar : [#int#]bar
-// CHECK: foo : [#int#]foo
+// CHECK: bar (InBase) : [#int#]bar
+// CHECK: foo (InBase) : [#int#]foo
// CHECK-NOT: foobar
diff --git a/test/CodeCompletion/ordinary-name-cxx11.cpp b/test/CodeCompletion/ordinary-name-cxx11.cpp
index 34c3bf96a9d5..0125ffbbb3cf 100644
--- a/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ b/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -197,7 +197,6 @@ void foo() {
// CHECK-CC4-NEXT: COMPLETION: volatile
// CHECK-CC4-NEXT: COMPLETION: wchar_t
// CHECK-CC4-NEXT: COMPLETION: X : X
- // CHECK-CC4-NEXT: COMPLETION: y : [#int#]y
// CHECK-CC4-NEXT: COMPLETION: z : [#void#]z(<#int#>)
// RUN: %clang_cc1 -fsyntax-only -fno-rtti -code-completion-patterns -code-completion-at=%s:6:14 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-NO-RTTI %s
diff --git a/test/CodeCompletion/ordinary-name.cpp b/test/CodeCompletion/ordinary-name.cpp
index 03dbbcaf7448..ba613bc9152b 100644
--- a/test/CodeCompletion/ordinary-name.cpp
+++ b/test/CodeCompletion/ordinary-name.cpp
@@ -171,7 +171,6 @@ void foo() {
// CHECK-CC4-NEXT: COMPLETION: volatile
// CHECK-CC4-NEXT: COMPLETION: wchar_t
// CHECK-CC4-NEXT: COMPLETION: X : X
- // CHECK-CC4-NEXT: COMPLETION: y : [#int#]y
// CHECK-CC4-NEXT: COMPLETION: z : [#void#]z(<#int#>)
// RUN: %clang_cc1 -fsyntax-only -fno-rtti -code-completion-patterns -code-completion-at=%s:6:14 -std=gnu++98 %s -o - | FileCheck -check-prefix=CHECK-NO-RTTI %s
diff --git a/test/CodeCompletion/overrides.cpp b/test/CodeCompletion/overrides.cpp
new file mode 100644
index 000000000000..06cff6af4d12
--- /dev/null
+++ b/test/CodeCompletion/overrides.cpp
@@ -0,0 +1,33 @@
+class A {
+ public:
+ virtual void vfunc(bool param);
+ virtual void vfunc(bool param, int p);
+ void func(bool param);
+};
+class B : public A {
+virtual int ttt(bool param, int x = 3) const;
+void vfunc(bool param, int p) override;
+};
+class C : public B {
+ public:
+ void vfunc(bool param) override;
+ void
+};
+
+// Runs completion at ^void.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
+// CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
+//
+// Runs completion at vo^id.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
+// CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
+//
+// Runs completion at void ^.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
+// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
diff --git a/test/CodeCompletion/paren_locs.cpp b/test/CodeCompletion/paren_locs.cpp
new file mode 100644
index 000000000000..303264cff725
--- /dev/null
+++ b/test/CodeCompletion/paren_locs.cpp
@@ -0,0 +1,33 @@
+void foo(int a, int b);
+void foo(int a, int b, int c);
+
+void test() {
+ foo(10, );
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:10 %s -o - \
+ // RUN: | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:5:6
+
+#define FOO foo(
+ FOO 10, );
+#undef FOO
+ // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:11:10 %s -o - \
+ // RUN: | FileCheck -check-prefix=CHECK-CC2 %s
+ // CHECK-CC2: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:11:3
+
+ struct Foo {
+ Foo(int a, int b);
+ Foo(int a, int b, int c);
+ };
+ Foo a(10, );
+ // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:21:12 %s -o - \
+ // RUN: | FileCheck -check-prefix=CHECK-CC3 %s
+ // CHECK-CC3: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:21:8
+ Foo(10, );
+ // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:25:10 %s -o - \
+ // RUN: | FileCheck -check-prefix=CHECK-CC4 %s
+ // CHECK-CC4: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:25:6
+ new Foo(10, );
+ // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:29:15 %s -o - \
+ // RUN: | FileCheck -check-prefix=CHECK-CC5 %s
+ // CHECK-CC5: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:29:10
+}
diff --git a/test/CodeCompletion/pragma-macro-token-caching.c b/test/CodeCompletion/pragma-macro-token-caching.c
index 432706e85ceb..59b6621b56ad 100644
--- a/test/CodeCompletion/pragma-macro-token-caching.c
+++ b/test/CodeCompletion/pragma-macro-token-caching.c
@@ -12,7 +12,7 @@ void completeParam(int param) {
void completeParamPragmaError(int param) {
Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a parenthesized string literal}}
- param;
+ param; // expected-warning {{expression result unused}}
}
// RUN: %clang_cc1 -fsyntax-only -verify -code-completion-at=%s:16:1 %s | FileCheck %s
diff --git a/test/CodeCompletion/preferred-type.cpp b/test/CodeCompletion/preferred-type.cpp
new file mode 100644
index 000000000000..5048dfac8954
--- /dev/null
+++ b/test/CodeCompletion/preferred-type.cpp
@@ -0,0 +1,15 @@
+void test(bool x) {
+ if (x) {}
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:7 %s | FileCheck %s
+ // CHECK: PREFERRED-TYPE: _Bool
+
+ while (x) {}
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:10 %s | FileCheck %s
+
+ for (; x;) {}
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:9:10 %s | FileCheck %s
+
+ // FIXME(ibiryukov): the condition in do-while is parsed as expression, so we
+ // fail to detect it should be converted to bool.
+ // do {} while (x);
+}
diff --git a/test/CodeCompletion/self-inits.cpp b/test/CodeCompletion/self-inits.cpp
new file mode 100644
index 000000000000..a64209534ae6
--- /dev/null
+++ b/test/CodeCompletion/self-inits.cpp
@@ -0,0 +1,3 @@
+int foo = 10;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:1:11 %s -o - | FileCheck --check-prefix=CC1 %s
+// CC1-NOT: foo
diff --git a/test/CodeCompletion/signatures-crash.cpp b/test/CodeCompletion/signatures-crash.cpp
new file mode 100644
index 000000000000..c58ae0cc2fd9
--- /dev/null
+++ b/test/CodeCompletion/signatures-crash.cpp
@@ -0,0 +1,15 @@
+struct map {
+ void find(int);
+ void find();
+};
+
+int main() {
+ map *m;
+ m->find(10);
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:11 %s -o - | FileCheck %s
+ // CHECK: OVERLOAD: [#void#]find(<#int#>)
+
+ // Also check when the lhs is an explicit pr-value.
+ (m+0)->find(10);
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:15 %s -o - | FileCheck %s
+}
diff --git a/test/CodeCompletion/this-quals.cpp b/test/CodeCompletion/this-quals.cpp
new file mode 100644
index 000000000000..eeaed00aa857
--- /dev/null
+++ b/test/CodeCompletion/this-quals.cpp
@@ -0,0 +1,21 @@
+class foo {
+ void mut_func() {
+ [this]() {
+
+ }();
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:1 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: const_func
+ // CHECK-CC1: mut_func
+ }
+
+ void const_func() const {
+ [this]() {
+
+ }();
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:1 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+ // CHECK-CC2-NOT: mut_func
+ // CHECK-CC2: const_func
+ };
+};
+
+