diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-14 18:03:49 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-14 18:03:49 +0000 |
commit | 4c8b24812ddcd1dedaca343a6d4e76f91f398981 (patch) | |
tree | 137ebebcae16fb0ce7ab4af456992bbd8d22fced /test/CodeCompletion | |
parent | 5362a71c02e7d448a8ce98cf00c47e353fba5d04 (diff) |
Notes
Diffstat (limited to 'test/CodeCompletion')
21 files changed, 431 insertions, 0 deletions
diff --git a/test/CodeCompletion/call.cpp b/test/CodeCompletion/call.cpp new file mode 100644 index 000000000000..90bf82bff307 --- /dev/null +++ b/test/CodeCompletion/call.cpp @@ -0,0 +1,28 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. +void f(float x, float y); +void f(int i, int j, int k); +struct X { }; +void f(X); +namespace N { + struct Y { + Y(int = 0); + + operator int() const; + }; + void f(Y y, int ZZ); +} +typedef N::Y Y; +void f(); + +void test() { + f(Y(), 0, 0); + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: f(struct N::Y y, <#int ZZ#>) + // CHECK-CC1-NEXT: f(int i, <#int j#>, int k) + // CHECK-CC1-NEXT: f(float x, <#float y#>) + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CC2 %s && + // CHECK-CC2-NOT: f(struct N::Y y, int ZZ) + // CHECK-CC2: f(int i, int j, <#int k#>) + // RUN: true +} diff --git a/test/CodeCompletion/enum-switch-case-qualified.cpp b/test/CodeCompletion/enum-switch-case-qualified.cpp new file mode 100644 index 000000000000..223aca8b9323 --- /dev/null +++ b/test/CodeCompletion/enum-switch-case-qualified.cpp @@ -0,0 +1,33 @@ +namespace M { + +namespace N { + struct C { + enum Color { + Red, + Orange, + Yellow, + Green, + Blue, + Indigo, + Violet + }; + }; +} + +} + +namespace M { + +void test(enum N::C::Color color) { + switch (color) { + case + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:23:8 %s -o - | FileCheck -check-prefix=CC1 %s && + // RUN: true + // CHECK-CC1: Blue : 0 : N::C::Blue + // CHECK-CC1-NEXT: Green : 0 : N::C::Green + // CHECK-CC1-NEXT: Indigo : 0 : N::C::Indigo + // CHECK-CC1-NEXT: Orange : 0 : N::C::Orange + // CHECK-CC1-NEXT: Red : 0 : N::C::Red + // CHECK-CC1-NEXT: Violet : 0 : N::C::Violet + // CHECK-CC1: Yellow : 0 : N::C::Yellow + diff --git a/test/CodeCompletion/enum-switch-case.c b/test/CodeCompletion/enum-switch-case.c new file mode 100644 index 000000000000..d8bb5e8ca474 --- /dev/null +++ b/test/CodeCompletion/enum-switch-case.c @@ -0,0 +1,29 @@ +enum Color { + Red, + Orange, + Yellow, + Green, + Blue, + Indigo, + Violet +}; + +void test(enum Color color) { + switch (color) { + case Red: + break; + + case Yellow: + break; + + case Green: + break; + + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:19:10 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: Blue : 0 + // CHECK-CC1-NEXT: Green : 0 + // CHECK-CC1-NEXT: Indigo : 0 + // CHECK-CC1-NEXT: Orange : 0 + // CHECK-CC1-NEXT: Violet : 0 + // RUN: true + diff --git a/test/CodeCompletion/enum-switch-case.cpp b/test/CodeCompletion/enum-switch-case.cpp new file mode 100644 index 000000000000..7a388fce0e39 --- /dev/null +++ b/test/CodeCompletion/enum-switch-case.cpp @@ -0,0 +1,29 @@ +namespace N { + enum Color { + Red, + Orange, + Yellow, + Green, + Blue, + Indigo, + Violet + }; +} + +void test(enum N::Color color) { + switch (color) { + case N::Red: + break; + + case N::Yellow: + break; + + case + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:21:8 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: Blue : 0 : N::Blue + // CHECK-CC1-NEXT: Green : 0 : N::Green + // CHECK-CC1-NEXT: Indigo : 0 : N::Indigo + // CHECK-CC1-NEXT: Orange : 0 : N::Orange + // CHECK-CC1-NEXT: Violet : 0 : N::Violet + + // RUN: true diff --git a/test/CodeCompletion/function-templates.cpp b/test/CodeCompletion/function-templates.cpp new file mode 100644 index 000000000000..52cba71bd2f9 --- /dev/null +++ b/test/CodeCompletion/function-templates.cpp @@ -0,0 +1,15 @@ +namespace std { + template<typename RandomAccessIterator> + void sort(RandomAccessIterator first, RandomAccessIterator last); + + template<class X, class Y> + X* dyn_cast(Y *Val); +} + +void f() { + std:: + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:8 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: dyn_cast<<#class X#>>(<#Y *Val#>) + // CHECK-CC1: sort(<#RandomAccessIterator first#>, <#RandomAccessIterator last#>) + // RUN: true + diff --git a/test/CodeCompletion/functions.cpp b/test/CodeCompletion/functions.cpp new file mode 100644 index 000000000000..2e1bc6edf8c4 --- /dev/null +++ b/test/CodeCompletion/functions.cpp @@ -0,0 +1,9 @@ +void f(int i, int j = 2, int k = 5); +void f(float x, float y...); + +void test() { + :: + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:5:5 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: f(<#int i#>{#, <#int j#>{#, <#int k#>#}#}) + // CHECK-CC1: f(<#float x#>, <#float y#><#, ...#>) + // RUN: true diff --git a/test/CodeCompletion/member-access.c b/test/CodeCompletion/member-access.c new file mode 100644 index 000000000000..1e8e5630981f --- /dev/null +++ b/test/CodeCompletion/member-access.c @@ -0,0 +1,13 @@ +struct Point { + float x; + float y; + float z; +}; + +void test(struct Point *p) { + p-> + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: x + // CHECK-CC1: y + // CHECK-CC1: z + // RUN: true diff --git a/test/CodeCompletion/member-access.cpp b/test/CodeCompletion/member-access.cpp new file mode 100644 index 000000000000..b810366209f5 --- /dev/null +++ b/test/CodeCompletion/member-access.cpp @@ -0,0 +1,43 @@ +struct Base1 { + int member1; + float member2; +}; + +struct Base2 { + int member1; + double member3; + void memfun1(int); +}; + +struct Base3 : Base1, Base2 { + void memfun1(float); + void memfun1(double); + void memfun2(int); +}; + +struct Derived : Base3 { + int member4; + int memfun3(int); +}; + +class Proxy { +public: + Derived *operator->() const; +}; + +void test(const Proxy &p) { + p-> + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s && + // CHECK-CC1: member1 : 0 : [#Base1::#]member1 + // CHECK-CC1: member1 : 0 : [#Base2::#]member1 + // CHECK-CC1: member2 : 0 : [#Base1::#]member2 + // CHECK-CC1: member3 : 0 + // CHECK-CC1: member4 : 0 + // CHECK-CC1: memfun1 : 0 : [#Base3::#]memfun1(<#float#>) + // CHECK-CC1: memfun1 : 0 : [#Base3::#]memfun1(<#double#>) + // CHECK-CC1: memfun2 : 0 : [#Base3::#]memfun2(<#int#>) + // CHECK-CC1: memfun3 : 0 : memfun3(<#int#>) + // CHECK-CC1: Base1 : 0 : Base1:: + // CHECK-CC1: memfun1 : 0 (Hidden) : Base2::memfun1(<#int#>) + // RUN: true + diff --git a/test/CodeCompletion/namespace-alias.cpp b/test/CodeCompletion/namespace-alias.cpp new file mode 100644 index 000000000000..0fa2ec20209c --- /dev/null +++ b/test/CodeCompletion/namespace-alias.cpp @@ -0,0 +1,21 @@ +namespace N4 { + namespace N3 { } +} + +class N3; + +namespace N2 { + namespace I1 { } + namespace I4 = I1; + namespace I5 { } + namespace I1 { } + + namespace New = + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:13:18 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: I1 : 1 + // CHECK-CC1: I4 : 1 + // CHECK-CC1: I5 : 1 + // CHECK-CC1: N2 : 3 + // CHECK-CC1-NEXT: N4 : 3 + // RUN: true + diff --git a/test/CodeCompletion/namespace.cpp b/test/CodeCompletion/namespace.cpp new file mode 100644 index 000000000000..d4ed639f8a05 --- /dev/null +++ b/test/CodeCompletion/namespace.cpp @@ -0,0 +1,15 @@ +namespace N3 { +} + +namespace N2 { + namespace I1 { } + namespace I4 = I1; + namespace I5 { } + namespace I1 { } + + namespace + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:12 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: I1 : 0 + // CHECK-CC1-NEXT: I5 : 0 + // RUN: true + diff --git a/test/CodeCompletion/nested-name-specifier.cpp b/test/CodeCompletion/nested-name-specifier.cpp new file mode 100644 index 000000000000..0cc5a19421c7 --- /dev/null +++ b/test/CodeCompletion/nested-name-specifier.cpp @@ -0,0 +1,18 @@ +namespace N { + struct A { }; + namespace M { + struct C { }; + }; +} + +namespace N { + struct B { }; +} + +N:: +// RUN: clang-cc -fsyntax-only -code-completion-at=%s:12:4 %s -o - | FileCheck -check-prefix=CC1 %s && +// CHECK-CC1: A : 0 +// CHECK-CC1: B : 0 +// CHECK-CC1: M : 0 +// RUN: true + diff --git a/test/CodeCompletion/operator.cpp b/test/CodeCompletion/operator.cpp new file mode 100644 index 000000000000..a3950f6b8913 --- /dev/null +++ b/test/CodeCompletion/operator.cpp @@ -0,0 +1,18 @@ +class T { }; + +typedef int Integer; + +namespace N { } + +void f() { + typedef float Float; + + operator + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:11 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: Float : 0 + // CHECK-CC1: + : 0 + // CHECK-CC1: short : 0 + // CHECK-CC1: Integer : 2 + // CHECK-CC1: T : 2 + // CHECK-CC1: N : 6 + // RUN: true diff --git a/test/CodeCompletion/ordinary-name.c b/test/CodeCompletion/ordinary-name.c new file mode 100644 index 000000000000..586e2b371bd7 --- /dev/null +++ b/test/CodeCompletion/ordinary-name.c @@ -0,0 +1,12 @@ +struct X { int x; }; + +typedef struct t TYPEDEF; + +void foo() { + int y; + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s && + // CHECK-CC1: y : 0 + // CHECK-CC1: foo : 2 + // CHECK-NOT-CC1: y : 2 + // CHECK-CC1-NEXT: TYPEDEF : 2 + // RUN: true diff --git a/test/CodeCompletion/property.m b/test/CodeCompletion/property.m new file mode 100644 index 000000000000..7f2321ee1395 --- /dev/null +++ b/test/CodeCompletion/property.m @@ -0,0 +1,29 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +@interface Foo { + void *isa; +} +@property(copy) Foo *myprop; +@property(retain, nonatomic) id xx; +// RUN: clang-cc -fsyntax-only -code-completion-at=%s:7:11 %s -o - | FileCheck -check-prefix=CC1 %s && +// CC1: assign +// CC1-NEXT: copy +// CC1-NEXT: getter +// CC1-NEXT: nonatomic +// CC1-NEXT: readonly +// CC1-NEXT: readwrite +// CC1-NEXT: retain +// CC1-NEXT: setter +// RUN: clang-cc -fsyntax-only -code-completion-at=%s:8:18 %s -o - | FileCheck -check-prefix=CC2 %s +// CC2: assign +// CC2-NEXT: copy +// CC2-NEXT: getter +// CC2-NEXT: nonatomic +// CC2-NEXT: readonly +// CC2-NEXT: readwrite +// CC2-NEXT: setter +@end + + + diff --git a/test/CodeCompletion/tag.c b/test/CodeCompletion/tag.c new file mode 100644 index 000000000000..e7250f540c4f --- /dev/null +++ b/test/CodeCompletion/tag.c @@ -0,0 +1,13 @@ +enum X { x }; +enum Y { y }; +struct Z { }; + +void X(); + +void test() { + enum X { x }; + enum + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:9:7 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: X : 0 + // CHECK-CC1: Y : 2 + // RUN: true diff --git a/test/CodeCompletion/tag.cpp b/test/CodeCompletion/tag.cpp new file mode 100644 index 000000000000..b00ff1fabdaa --- /dev/null +++ b/test/CodeCompletion/tag.cpp @@ -0,0 +1,26 @@ +class X { }; +struct Y { }; + +namespace N { + template<typename> class Z; +} + +namespace M { + class A; +} +using M::A; + +namespace N { + class Y; + + void test() { + class + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:17:10 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: Y : 2 + // CHECK-CC1: Z : 2 + // CHECK-CC1: A : 4 + // CHECK-CC1: X : 4 + // CHECK-CC1: Y : 4 + // CHECK-CC1: M : 9 : M:: + // CHECK-CC1: N : 9 : N:: + // RUN: true diff --git a/test/CodeCompletion/templates.cpp b/test/CodeCompletion/templates.cpp new file mode 100644 index 000000000000..22cca65bea98 --- /dev/null +++ b/test/CodeCompletion/templates.cpp @@ -0,0 +1,17 @@ +namespace std { + template<typename T> + class allocator; + + template<typename T, typename Alloc = std::allocator<T> > + class vector; +} + +void f() { + std:: + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:8 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: allocator<<#typename T#>> + // CHECK-CC1: vector<<#typename T#>{#, <#typename Alloc#>#}> + // RUN: true + + + diff --git a/test/CodeCompletion/truncation.c b/test/CodeCompletion/truncation.c new file mode 100644 index 000000000000..b72aa7facf79 --- /dev/null +++ b/test/CodeCompletion/truncation.c @@ -0,0 +1,12 @@ +#include "truncation.c.h" + +struct + +// RUN: clang-cc -fsyntax-only -code-completion-at=%s.h:4:8 -o - %s | FileCheck -check-prefix=CC1 %s && +// CHECK-CC1: X : 1 +// CHECK-CC1-NEXT: Y : 1 +// RUN: clang-cc -fsyntax-only -code-completion-at=%s:3:8 -o - %s | FileCheck -check-prefix=CC2 %s && +// CHECK-CC2: X : 1 +// CHECK-CC2: Xa : 1 +// CHECK-CC2: Y : 1 +// RUN: true diff --git a/test/CodeCompletion/truncation.c.h b/test/CodeCompletion/truncation.c.h new file mode 100644 index 000000000000..a5ebbacb3442 --- /dev/null +++ b/test/CodeCompletion/truncation.c.h @@ -0,0 +1,5 @@ +struct X { }; +struct Y { }; + +struct Xa { }; + diff --git a/test/CodeCompletion/using-namespace.cpp b/test/CodeCompletion/using-namespace.cpp new file mode 100644 index 000000000000..a332b880074e --- /dev/null +++ b/test/CodeCompletion/using-namespace.cpp @@ -0,0 +1,21 @@ +namespace N4 { + namespace N3 { } +} + +class N3; + +namespace N2 { + namespace I1 { } + namespace I4 = I1; + namespace I5 { } + namespace I1 { } + + void foo() { + using namespace + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:14:20 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: I1 : 2 + // CHECK-CC1: I4 : 2 + // CHECK-CC1: I5 : 2 + // CHECK-CC1: N2 : 4 + // CHECK-CC1-NEXT: N4 : 4 + // RUN: true diff --git a/test/CodeCompletion/using.cpp b/test/CodeCompletion/using.cpp new file mode 100644 index 000000000000..57b3aa7880a2 --- /dev/null +++ b/test/CodeCompletion/using.cpp @@ -0,0 +1,25 @@ +namespace N4 { + namespace N3 { } +} + +class N3; + +namespace N2 { + namespace I1 { } + namespace I4 = I1; + namespace I5 { } + namespace I1 { } + + void foo() { + int N3; + + using + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:16:10 %s -o - | FileCheck -check-prefix=CC1 %s && + // CHECK-CC1: I1 : 2 + // CHECK-CC1: I4 : 2 + // CHECK-CC1: I5 : 2 + // CHECK-CC1: N2 : 4 + // CHECK-CC1: N3 : 4 + // CHECK-CC1-NEXT: N4 : 4 + // RUN: true + |