diff options
Diffstat (limited to 'clang/test/CodeCompletion')
30 files changed, 777 insertions, 0 deletions
diff --git a/clang/test/CodeCompletion/Inputs/macros.h b/clang/test/CodeCompletion/Inputs/macros.h new file mode 100644 index 0000000..98b5ac6 --- /dev/null +++ b/clang/test/CodeCompletion/Inputs/macros.h @@ -0,0 +1,4 @@ +#define FOO +#define BAR(X, Y) X, Y +#define IDENTITY(X) X +#define WIBBLE(...) diff --git a/clang/test/CodeCompletion/Inputs/reserved.h b/clang/test/CodeCompletion/Inputs/reserved.h new file mode 100644 index 0000000..fafe4ac --- /dev/null +++ b/clang/test/CodeCompletion/Inputs/reserved.h @@ -0,0 +1,2 @@ +typedef int _INTEGER_TYPE; +typedef float FLOATING_TYPE; diff --git a/clang/test/CodeCompletion/PR9728.cpp b/clang/test/CodeCompletion/PR9728.cpp new file mode 100644 index 0000000..91f49be --- /dev/null +++ b/clang/test/CodeCompletion/PR9728.cpp @@ -0,0 +1,9 @@ +namespace N { +struct SFoo; +} + +struct brokenfile_t { + brokenfile_t (N:: + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:20 %s -o - | FileCheck %s + // CHECK: SFoo + diff --git a/clang/test/CodeCompletion/call.c b/clang/test/CodeCompletion/call.c new file mode 100644 index 0000000..8581414 --- /dev/null +++ b/clang/test/CodeCompletion/call.c @@ -0,0 +1,15 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. +void f0(float x, float y); +void f1(); +void test() { + f0(0, 0); + g0(0, 0); + f1(0, 0); + // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:6:6 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: f0(<#float x#>, float y) + // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CC2 %s + // CHECK-CC2: f0(float x, <#float y#>) + // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CC3 %s + // CHECK-CC3: f1() +} diff --git a/clang/test/CodeCompletion/call.cpp b/clang/test/CodeCompletion/call.cpp new file mode 100644 index 0000000..f06470f --- /dev/null +++ b/clang/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_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>) + // CHECK-CC1: f(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_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CC2 %s + // CHECK-CC2-NOT: f(N::Y y, int ZZ) + // CHECK-CC2: f(int i, int j, <#int k#>) +} diff --git a/clang/test/CodeCompletion/enum-switch-case-qualified.cpp b/clang/test/CodeCompletion/enum-switch-case-qualified.cpp new file mode 100644 index 0000000..e74ec9b --- /dev/null +++ b/clang/test/CodeCompletion/enum-switch-case-qualified.cpp @@ -0,0 +1,32 @@ +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_cc1 -fsyntax-only -code-completion-at=%s:23:8 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: Blue : [#M::N::C::Color#]N::C::Blue + // CHECK-CC1-NEXT: Green : [#M::N::C::Color#]N::C::Green + // CHECK-CC1-NEXT: Indigo : [#M::N::C::Color#]N::C::Indigo + // CHECK-CC1-NEXT: Orange : [#M::N::C::Color#]N::C::Orange + // CHECK-CC1-NEXT: Red : [#M::N::C::Color#]N::C::Red + // CHECK-CC1-NEXT: Violet : [#M::N::C::Color#]N::C::Violet + // CHECK-CC1: Yellow : [#M::N::C::Color#]N::C::Yellow + diff --git a/clang/test/CodeCompletion/enum-switch-case.c b/clang/test/CodeCompletion/enum-switch-case.c new file mode 100644 index 0000000..b83bd7f --- /dev/null +++ b/clang/test/CodeCompletion/enum-switch-case.c @@ -0,0 +1,45 @@ +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; + } + + unsigned c2; + switch (c2) { + case + } + + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:10 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: Blue + // CHECK-CC1-NEXT: Green + // CHECK-CC1-NEXT: Indigo + // CHECK-CC1-NEXT: Orange + // CHECK-CC1-NEXT: Violet + + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:25:10 %s -o - | FileCheck -check-prefix=CC2 %s + // CHECK-CC2: COMPLETION: Blue : [#enum Color#]Blue + // CHECK-CC2-NEXT: COMPLETION: c2 : [#unsigned int#]c2 + // CHECK-CC2-NEXT: COMPLETION: color : [#enum Color#]color + // CHECK-CC2-NEXT: COMPLETION: Green : [#enum Color#]Green + // CHECK-CC2-NEXT: COMPLETION: Indigo : [#enum Color#]Indigo + // CHECK-CC2-NEXT: COMPLETION: Orange : [#enum Color#]Orange + // CHECK-CC2-NEXT: COMPLETION: Red : [#enum Color#]Red + // CHECK-CC2-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>) + // CHECK-CC2-NEXT: COMPLETION: Violet : [#enum Color#]Violet + // CHECK-CC2-NEXT: COMPLETION: Yellow : [#enum Color#]Yellow diff --git a/clang/test/CodeCompletion/enum-switch-case.cpp b/clang/test/CodeCompletion/enum-switch-case.cpp new file mode 100644 index 0000000..2677f33 --- /dev/null +++ b/clang/test/CodeCompletion/enum-switch-case.cpp @@ -0,0 +1,28 @@ +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_cc1 -fsyntax-only -code-completion-at=%s:21:8 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: Blue : [#N::Color#]N::Blue + // CHECK-CC1-NEXT: Green : [#N::Color#]N::Green + // CHECK-CC1-NEXT: Indigo : [#N::Color#]N::Indigo + // CHECK-CC1-NEXT: Orange : [#N::Color#]N::Orange + // CHECK-CC1-NEXT: Violet : [#N::Color#]N::Violet + diff --git a/clang/test/CodeCompletion/function-templates.cpp b/clang/test/CodeCompletion/function-templates.cpp new file mode 100644 index 0000000..cdbbf75 --- /dev/null +++ b/clang/test/CodeCompletion/function-templates.cpp @@ -0,0 +1,23 @@ +namespace std { + template<typename RandomAccessIterator> + void sort(RandomAccessIterator first, RandomAccessIterator last); + + template<class X, class Y> + X* dyn_cast(Y *Val); +} + +class Foo { +public: + template<typename T> T &getAs(); +}; + +void f() { + std::sort(1, 2); + Foo().getAs<int>(); + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:15:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // CHECK-CC1: dyn_cast<<#class X#>>(<#Y *Val#>) + // CHECK-CC1: sort(<#RandomAccessIterator first#>, <#RandomAccessIterator last#> + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:16:9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s + // CHECK-CC2: getAs<<#typename T#>>() +) + diff --git a/clang/test/CodeCompletion/functions.cpp b/clang/test/CodeCompletion/functions.cpp new file mode 100644 index 0000000..fcab3dc --- /dev/null +++ b/clang/test/CodeCompletion/functions.cpp @@ -0,0 +1,8 @@ +void f(int i, int j = 2, int k = 5); +void f(float x, float y...); + +void test() { + :: + // RUN: %clang_cc1 -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, ...#>) diff --git a/clang/test/CodeCompletion/macros.c b/clang/test/CodeCompletion/macros.c new file mode 100644 index 0000000..0758bbf --- /dev/null +++ b/clang/test/CodeCompletion/macros.c @@ -0,0 +1,34 @@ +enum Color { + Red, Green, Blue +}; + +struct Point { + float x, y, z; + enum Color color; +}; + +void test(struct Point *p) { + // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CC1 %s + switch (p->IDENTITY(color)) { + // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:14:9 %s -o - | FileCheck -check-prefix=CC2 %s + case + } + + // Run the same tests, this time with macros loaded from the PCH file. + // RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/macros.h + // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CC1 %s + // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:14:9 %s -o - | FileCheck -check-prefix=CC2 %s + + // CC1: color + // CC1: x + // CC1: y + // CC1: z + + // CC2: BAR(<#X#>, <#Y#>) + // CC2: Blue + // CC2: FOO + // CC2: Green + // CC2: IDENTITY(<#X#>) + // CC2: Red + // CC2: WIBBLE +} diff --git a/clang/test/CodeCompletion/member-access.c b/clang/test/CodeCompletion/member-access.c new file mode 100644 index 0000000..f41c509 --- /dev/null +++ b/clang/test/CodeCompletion/member-access.c @@ -0,0 +1,12 @@ +struct Point { + float x; + float y; + float z; +}; + +void test(struct Point *p) { + p-> + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: x + // CHECK-CC1: y + // CHECK-CC1: z diff --git a/clang/test/CodeCompletion/member-access.cpp b/clang/test/CodeCompletion/member-access.cpp new file mode 100644 index 0000000..8f772c0 --- /dev/null +++ b/clang/test/CodeCompletion/member-access.cpp @@ -0,0 +1,42 @@ +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) const; + 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_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %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: 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: memfun3 : [#int#]memfun3(<#int#>) + diff --git a/clang/test/CodeCompletion/namespace-alias.cpp b/clang/test/CodeCompletion/namespace-alias.cpp new file mode 100644 index 0000000..efbf996 --- /dev/null +++ b/clang/test/CodeCompletion/namespace-alias.cpp @@ -0,0 +1,20 @@ +namespace N4 { + namespace N3 { } +} + +class N3; + +namespace N2 { + namespace I1 { } + namespace I4 = I1; + namespace I5 { } + namespace I1 { } + + namespace New = + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:18 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: I1 + // CHECK-CC1: I4 + // CHECK-CC1: I5 + // CHECK-CC1: N2 + // CHECK-CC1-NEXT: N4 + diff --git a/clang/test/CodeCompletion/namespace.cpp b/clang/test/CodeCompletion/namespace.cpp new file mode 100644 index 0000000..ecd8480 --- /dev/null +++ b/clang/test/CodeCompletion/namespace.cpp @@ -0,0 +1,14 @@ +namespace N3 { +} + +namespace N2 { + namespace I1 { } + namespace I4 = I1; + namespace I5 { } + namespace I1 { } + + namespace + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:12 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: I1 + // CHECK-CC1-NEXT: I5 + diff --git a/clang/test/CodeCompletion/nested-name-specifier.cpp b/clang/test/CodeCompletion/nested-name-specifier.cpp new file mode 100644 index 0000000..e09a14b --- /dev/null +++ b/clang/test/CodeCompletion/nested-name-specifier.cpp @@ -0,0 +1,17 @@ +namespace N { + struct A { }; + namespace M { + struct C { }; + }; +} + +namespace N { + struct B { }; +} + +N:: +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:4 %s -o - | FileCheck -check-prefix=CC1 %s +// CHECK-CC1: A +// CHECK-CC1: B +// CHECK-CC1: M + diff --git a/clang/test/CodeCompletion/objc-message.m b/clang/test/CodeCompletion/objc-message.m new file mode 100644 index 0000000..a7b111f --- /dev/null +++ b/clang/test/CodeCompletion/objc-message.m @@ -0,0 +1,35 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +@protocol FooTestProtocol ++ protocolClassMethod; +- protocolInstanceMethod; +@end +@interface Foo <FooTestProtocol> { + void *isa; +} ++ (int)classMethod1:a withKeyword:b; ++ (void)classMethod2; ++ new; +- instanceMethod1; +@end + +@interface Foo (FooTestCategory) ++ categoryClassMethod; +- categoryInstanceMethod; +@end + +void func() { + Foo *obj = [Foo new]; + [obj xx]; +} +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: categoryClassMethod +// CHECK-CC1: classMethod1:withKeyword: +// CHECK-CC1: classMethod2 +// CHECK-CC1: new +// CHECK-CC1: protocolClassMethod +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:8 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: categoryInstanceMethod +// CHECK-CC2: instanceMethod1 +// CHECK-CC2: protocolInstanceMethod diff --git a/clang/test/CodeCompletion/operator.cpp b/clang/test/CodeCompletion/operator.cpp new file mode 100644 index 0000000..05cd768 --- /dev/null +++ b/clang/test/CodeCompletion/operator.cpp @@ -0,0 +1,17 @@ +class T { }; + +typedef int Integer; + +namespace N { } + +void f() { + typedef float Float; + + operator + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:11 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: + + // CHECK-CC1: Float + // CHECK-CC1: Integer + // CHECK-CC1: N + // CHECK-CC1: short + // CHECK-CC1: T diff --git a/clang/test/CodeCompletion/ordinary-name.c b/clang/test/CodeCompletion/ordinary-name.c new file mode 100644 index 0000000..dda7bb0 --- /dev/null +++ b/clang/test/CodeCompletion/ordinary-name.c @@ -0,0 +1,17 @@ +#include <reserved.h> +struct X { int x; }; +typedef struct t TYPEDEF; +typedef struct t _TYPEDEF; +void foo() { + int y; + // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // CHECK-CC1: _Imaginary + // CHECK-CC1-NOT: _INTEGER_TYPE; + // CHECK-CC1: _TYPEDEF + // CHECK-CC1: FLOATING_TYPE + // CHECK-CC1: foo + // CHECK-CC1: TYPEDEF + // CHECK-CC1: y + + // PR8744 + // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:1:11 %s diff --git a/clang/test/CodeCompletion/ordinary-name.cpp b/clang/test/CodeCompletion/ordinary-name.cpp new file mode 100644 index 0000000..d0b09b5 --- /dev/null +++ b/clang/test/CodeCompletion/ordinary-name.cpp @@ -0,0 +1,229 @@ +struct X { int x; }; +void z(int); +typedef struct t TYPEDEF; + +void foo() { + int y = 17; + // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -code-completion-patterns -code-completion-at=%s:6:14 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // CHECK-CC1: COMPLETION: bool + // CHECK-CC1-NEXT: COMPLETION: char + // CHECK-CC1-NEXT: COMPLETION: class + // CHECK-CC1-NEXT: COMPLETION: const + // CHECK-CC1-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>) + // CHECK-CC1: COMPLETION: Pattern : [#void#]delete <#expression#> + // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#> + // CHECK-CC1-NEXT: COMPLETION: Pattern : do{<#statements#> + // CHECK-CC1: COMPLETION: double + // CHECK-CC1-NEXT: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>) + // CHECK-CC1-NEXT: COMPLETION: enum + // CHECK-CC1-NEXT: COMPLETION: extern + // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]false + // CHECK-CC1-NEXT: COMPLETION: float + // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo() + // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){ + // CHECK-CC1: COMPLETION: Pattern : goto <#label#> + // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#> + // CHECK-CC1: COMPLETION: int + // CHECK-CC1-NEXT: COMPLETION: long + // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>) + // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>) + // CHECK-CC1-NEXT: COMPLETION: operator + // CHECK-CC1-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>) + // CHECK-CC1-NEXT: COMPLETION: Pattern : return + // CHECK-CC1-NEXT: COMPLETION: short + // CHECK-CC1-NEXT: COMPLETION: signed + // CHECK-CC1-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>) + // CHECK-CC1-NEXT: COMPLETION: static + // CHECK-CC1-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>) + // CHECK-CC1-NEXT: COMPLETION: struct + // CHECK-CC1-NEXT: COMPLETION: Pattern : switch(<#condition#>){ + // CHECK-CC1: COMPLETION: t : t + // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#> + // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]true + // CHECK-CC1-NEXT: COMPLETION: Pattern : try{<#statements#> + // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF + // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#> + // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>) + // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#> + // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#> + // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>) + // CHECK-CC1-NEXT: COMPLETION: union + // CHECK-CC1-NEXT: COMPLETION: unsigned + // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#> + // CHECK-CC1-NEXT: COMPLETION: void + // CHECK-CC1-NEXT: COMPLETION: volatile + // CHECK-CC1-NEXT: COMPLETION: wchar_t + // CHECK-CC1-NEXT: COMPLETION: Pattern : while(<#condition#>){<#statements#> + // CHECK-CC1: COMPLETION: X : X + // CHECK-CC1-NEXT: COMPLETION: y : [#int#]y + // CHECK-CC1-NEXT: COMPLETION: z : [#void#]z(<#int#>) + + // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:1 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s + // CHECK-CC2: COMPLETION: Pattern : asm(<#string-literal#>) + // CHECK-CC2-NEXT: COMPLETION: bool + // CHECK-CC2-NEXT: COMPLETION: char + // CHECK-CC2-NEXT: COMPLETION: class + // CHECK-CC2-NEXT: COMPLETION: const + // CHECK-CC2-NEXT: COMPLETION: double + // CHECK-CC2-NEXT: COMPLETION: enum + // CHECK-CC2-NEXT: COMPLETION: extern + // CHECK-CC2-NEXT: COMPLETION: float + // CHECK-CC2-NEXT: COMPLETION: inline + // CHECK-CC2-NEXT: COMPLETION: int + // CHECK-CC2-NEXT: COMPLETION: long + // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{<#declarations#> + // CHECK-CC2: COMPLETION: Pattern : namespace <#name#> = <#namespace#> + // CHECK-CC2-NEXT: COMPLETION: operator + // CHECK-CC2-NEXT: COMPLETION: short + // CHECK-CC2-NEXT: COMPLETION: signed + // CHECK-CC2-NEXT: COMPLETION: static + // CHECK-CC2-NEXT: COMPLETION: struct + // CHECK-CC2-NEXT: COMPLETION: t : t + // CHECK-CC2-NEXT: COMPLETION: Pattern : template <#declaration#> + // CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>> + // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF + // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#> + // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#> + // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#> + // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>) + // CHECK-CC2-NEXT: COMPLETION: union + // CHECK-CC2-NEXT: COMPLETION: unsigned + // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#> + // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#> + // CHECK-CC2-NEXT: COMPLETION: void + // CHECK-CC2-NEXT: COMPLETION: volatile + // CHECK-CC2-NEXT: COMPLETION: wchar_t + // CHECK-CC2-NEXT: COMPLETION: X : X + + // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:1:19 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s + // CHECK-CC3: COMPLETION: bool + // CHECK-CC3-NEXT: COMPLETION: char + // CHECK-CC3-NEXT: COMPLETION: class + // CHECK-CC3-NEXT: COMPLETION: const + // CHECK-CC3-NEXT: COMPLETION: double + // CHECK-CC3-NEXT: COMPLETION: enum + // CHECK-CC3-NEXT: COMPLETION: explicit + // CHECK-CC3-NEXT: COMPLETION: extern + // CHECK-CC3-NEXT: COMPLETION: float + // CHECK-CC3-NEXT: COMPLETION: friend + // CHECK-CC3-NEXT: COMPLETION: inline + // CHECK-CC3-NEXT: COMPLETION: int + // CHECK-CC3-NEXT: COMPLETION: long + // CHECK-CC3-NEXT: COMPLETION: mutable + // CHECK-CC3-NEXT: COMPLETION: operator + // CHECK-CC3-NEXT: COMPLETION: Pattern : private: + // CHECK-CC3-NEXT: COMPLETION: Pattern : protected: + // CHECK-CC3-NEXT: COMPLETION: Pattern : public: + // CHECK-CC3-NEXT: COMPLETION: short + // CHECK-CC3-NEXT: COMPLETION: signed + // CHECK-CC3-NEXT: COMPLETION: static + // CHECK-CC3-NEXT: COMPLETION: struct + // CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>> + // CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#> + // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#> + // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#> + // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>) + // CHECK-CC3-NEXT: COMPLETION: union + // CHECK-CC3-NEXT: COMPLETION: unsigned + // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#> + // CHECK-CC3-NEXT: COMPLETION: virtual + // CHECK-CC3-NEXT: COMPLETION: void + // CHECK-CC3-NEXT: COMPLETION: volatile + // CHECK-CC3-NEXT: COMPLETION: wchar_t + // CHECK-CC3-NEXT: COMPLETION: X : X + + // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -code-completion-patterns -code-completion-at=%s:6:11 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s + // CHECK-CC4: COMPLETION: bool + // CHECK-CC4-NEXT: COMPLETION: char + // CHECK-CC4-NEXT: COMPLETION: class + // CHECK-CC4-NEXT: COMPLETION: const + // CHECK-CC4-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>) + // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]delete <#expression#> + // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#> + // CHECK-CC4-NEXT: COMPLETION: double + // CHECK-CC4-NEXT: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>) + // CHECK-CC4-NEXT: COMPLETION: enum + // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]false + // CHECK-CC4-NEXT: COMPLETION: float + // CHECK-CC4-NEXT: COMPLETION: foo : [#void#]foo() + // CHECK-CC4-NEXT: COMPLETION: int + // CHECK-CC4-NEXT: COMPLETION: long + // CHECK-CC4-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>) + // CHECK-CC4-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>) + // CHECK-CC4-NEXT: COMPLETION: operator + // CHECK-CC4-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>) + // CHECK-CC4-NEXT: COMPLETION: short + // CHECK-CC4-NEXT: COMPLETION: signed + // CHECK-CC4-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>) + // CHECK-CC4-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>) + // CHECK-CC4-NEXT: COMPLETION: struct + // CHECK-CC4-NEXT: COMPLETION: t : t + // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#> + // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]true + // CHECK-CC4-NEXT: COMPLETION: TYPEDEF : TYPEDEF + // CHECK-CC4-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>) + // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#> + // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof <#expression#> + // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof(<#type#>) + // CHECK-CC4-NEXT: COMPLETION: union + // CHECK-CC4-NEXT: COMPLETION: unsigned + // CHECK-CC4-NEXT: COMPLETION: void + // 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 %s -o - | FileCheck -check-prefix=CHECK-NO-RTTI %s + // CHECK-NO-RTTI: COMPLETION: bool + // CHECK-NO-RTTI-NEXT: COMPLETION: char + // CHECK-NO-RTTI-NEXT: COMPLETION: class + // CHECK-NO-RTTI-NEXT: COMPLETION: const + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>) + // CHECK-NO-RTTI: COMPLETION: Pattern : [#void#]delete <#expression#> + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#> + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : do{<#statements#> + // CHECK-NO-RTTI: COMPLETION: double + // CHECK-NO-RTTI-NOT: dynamic_cast + // CHECK-NO-RTTI: COMPLETION: enum + // CHECK-NO-RTTI-NEXT: COMPLETION: extern + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#bool#]false + // CHECK-NO-RTTI-NEXT: COMPLETION: float + // CHECK-NO-RTTI-NEXT: COMPLETION: foo : [#void#]foo() + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){ + // CHECK-NO-RTTI: COMPLETION: Pattern : goto <#label#> + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#> + // CHECK-NO-RTTI: COMPLETION: int + // CHECK-NO-RTTI-NEXT: COMPLETION: long + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>) + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>) + // CHECK-NO-RTTI-NEXT: COMPLETION: operator + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>) + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : return + // CHECK-NO-RTTI-NEXT: COMPLETION: short + // CHECK-NO-RTTI-NEXT: COMPLETION: signed + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>) + // CHECK-NO-RTTI-NEXT: COMPLETION: static + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>) + // CHECK-NO-RTTI-NEXT: COMPLETION: struct + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : switch(<#condition#>){ + // CHECK-NO-RTTI: COMPLETION: t : t + // CHECK-NO-RTTI-NOT: throw + // CHECK-NO-RTTI: COMPLETION: Pattern : [#bool#]true + // CHECK-NO-RTTI-NOT: try + // CHECK-NO-RTTI: COMPLETION: TYPEDEF : TYPEDEF + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#> + // CHECK-NO-RTTI-NOT: typeid + // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#qualifier#>::<#name#> + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof <#expression#> + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>) + // CHECK-NO-RTTI-NEXT: COMPLETION: union + // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#> + // CHECK-NO-RTTI-NEXT: COMPLETION: void + // CHECK-NO-RTTI-NEXT: COMPLETION: volatile + // CHECK-NO-RTTI-NEXT: COMPLETION: wchar_t + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : while(<#condition#>){<#statements#> + // CHECK-NO-RTTI: COMPLETION: X : X + // CHECK-NO-RTTI-NEXT: COMPLETION: y : [#int#]y + // CHECK-NO-RTTI-NEXT: COMPLETION: z : [#void#]z(<#int#>) diff --git a/clang/test/CodeCompletion/preamble.c b/clang/test/CodeCompletion/preamble.c new file mode 100644 index 0000000..f322e09 --- /dev/null +++ b/clang/test/CodeCompletion/preamble.c @@ -0,0 +1,7 @@ +#include "some_struct.h" +void foo() { + struct X x; + x. + +// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:4:5 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: FieldDecl:{ResultType int}{TypedText m} (35) (parent: StructDecl 'X') diff --git a/clang/test/CodeCompletion/some_struct.h b/clang/test/CodeCompletion/some_struct.h new file mode 100644 index 0000000..63aa2a3 --- /dev/null +++ b/clang/test/CodeCompletion/some_struct.h @@ -0,0 +1 @@ +struct X { int m; }; diff --git a/clang/test/CodeCompletion/stdin.c b/clang/test/CodeCompletion/stdin.c new file mode 100644 index 0000000..46495b2 --- /dev/null +++ b/clang/test/CodeCompletion/stdin.c @@ -0,0 +1,7 @@ +enum X { x }; +enum Y { y }; + +enum + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=-:4:6 < %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: X + // CHECK-CC1: Y diff --git a/clang/test/CodeCompletion/tag.c b/clang/test/CodeCompletion/tag.c new file mode 100644 index 0000000..6ad2988 --- /dev/null +++ b/clang/test/CodeCompletion/tag.c @@ -0,0 +1,12 @@ +enum X { x }; +enum Y { y }; +struct Z { }; + +void X(); + +void test() { + enum X { x }; + enum + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:9:7 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: X + // CHECK-CC1: Y diff --git a/clang/test/CodeCompletion/tag.cpp b/clang/test/CodeCompletion/tag.cpp new file mode 100644 index 0000000..03fc0fd --- /dev/null +++ b/clang/test/CodeCompletion/tag.cpp @@ -0,0 +1,27 @@ +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_cc1 -fsyntax-only -code-completion-at=%s:17:10 %s -o - | FileCheck -check-prefix=CC1 %s + // FIXME: the redundant Y is really annoying... it needs qualification to + // actually be useful. Here, it just looks redundant :( + // CHECK-CC1: A + // CHECK-CC1: M : M:: + // CHECK-CC1: N : N:: + // CHECK-CC1: X + // CHECK-CC1: Y + // CHECK-CC1: Y + // CHECK-CC1: Z diff --git a/clang/test/CodeCompletion/templates.cpp b/clang/test/CodeCompletion/templates.cpp new file mode 100644 index 0000000..32a7b21 --- /dev/null +++ b/clang/test/CodeCompletion/templates.cpp @@ -0,0 +1,28 @@ +namespace std { + template<typename T> + class allocator { + public: + void in_base(); + }; + + template<typename T, typename Alloc = std::allocator<T> > + class vector : Alloc { + public: + void foo(); + void stop(); + }; + template<typename Alloc> class vector<bool, Alloc>; +} + +void f() { + std::vector<int> v; + v.foo(); + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:18:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // CHECK-CC1: allocator<<#typename T#>> + // CHECK-CC1-NEXT: vector<<#typename T#>{#, <#typename Alloc#>#}> + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s + // CHECK-CC2: foo + // CHECK-CC2: in_base + // CHECK-CC2: stop + + diff --git a/clang/test/CodeCompletion/truncation.c b/clang/test/CodeCompletion/truncation.c new file mode 100644 index 0000000..473e858 --- /dev/null +++ b/clang/test/CodeCompletion/truncation.c @@ -0,0 +1,15 @@ +#include "truncation.c.h" + +/* foo */ + +struct + +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s.h:4:8 -o - %s | FileCheck -check-prefix=CC1 %s +// CHECK-CC1: X +// CHECK-CC1-NEXT: Y +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:8 -o - %s | FileCheck -check-prefix=CC2 %s +// CHECK-CC2: X +// CHECK-CC2: Xa +// CHECK-CC2: Y + +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:3:3 -o - %s diff --git a/clang/test/CodeCompletion/truncation.c.h b/clang/test/CodeCompletion/truncation.c.h new file mode 100644 index 0000000..a5ebbac --- /dev/null +++ b/clang/test/CodeCompletion/truncation.c.h @@ -0,0 +1,5 @@ +struct X { }; +struct Y { }; + +struct Xa { }; + diff --git a/clang/test/CodeCompletion/using-namespace.cpp b/clang/test/CodeCompletion/using-namespace.cpp new file mode 100644 index 0000000..eb1c2bd --- /dev/null +++ b/clang/test/CodeCompletion/using-namespace.cpp @@ -0,0 +1,20 @@ +namespace N4 { + namespace N3 { } +} + +class N3; + +namespace N2 { + namespace I1 { } + namespace I4 = I1; + namespace I5 { } + namespace I1 { } + + void foo() { + using namespace + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:20 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: I1 + // CHECK-CC1: I4 + // CHECK-CC1: I5 + // CHECK-CC1: N2 + // CHECK-CC1-NEXT: N4 diff --git a/clang/test/CodeCompletion/using.cpp b/clang/test/CodeCompletion/using.cpp new file mode 100644 index 0000000..b84aa26 --- /dev/null +++ b/clang/test/CodeCompletion/using.cpp @@ -0,0 +1,24 @@ +namespace N4 { + namespace N3 { } +} + +class N3; + +namespace N2 { + namespace I1 { } + namespace I4 = I1; + namespace I5 { } + namespace I1 { } + + void foo() { + int N3; + + using + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:16:10 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: I1 + // CHECK-CC1: I4 + // CHECK-CC1: I5 + // CHECK-CC1: N2 + // CHECK-CC1: N3 + // CHECK-CC1-NEXT: N4 + |