xref: /minix3/external/bsd/llvm/dist/clang/test/Index/complete-exprs.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // Line- and column-sensitive test; run lines follow.
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc class string {
4*f4a2713aSLionel Sambuc  public:
5*f4a2713aSLionel Sambuc   string();
6*f4a2713aSLionel Sambuc   string(const char *);
7*f4a2713aSLionel Sambuc   string(const char *, int n);
8*f4a2713aSLionel Sambuc };
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc template<typename T>
11*f4a2713aSLionel Sambuc class vector {
12*f4a2713aSLionel Sambuc public:
13*f4a2713aSLionel Sambuc   vector(const T &, unsigned n);
14*f4a2713aSLionel Sambuc   template<typename InputIterator>
15*f4a2713aSLionel Sambuc   vector(InputIterator first, InputIterator last);
16*f4a2713aSLionel Sambuc   void push_back(const T&);
17*f4a2713aSLionel Sambuc };
push_back(const T &)18*f4a2713aSLionel Sambuc template<typename T> void vector<T>::push_back(const T&) { }
f()19*f4a2713aSLionel Sambuc void f() {
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc int foo();
24*f4a2713aSLionel Sambuc 
g()25*f4a2713aSLionel Sambuc void g() {
26*f4a2713aSLionel Sambuc   vector<int>(foo(), foo());
27*f4a2713aSLionel Sambuc }
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc struct X {
30*f4a2713aSLionel Sambuc   void f() const;
31*f4a2713aSLionel Sambuc };
32*f4a2713aSLionel Sambuc 
f() const33*f4a2713aSLionel Sambuc void X::f() const {
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc }
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc namespace N {
38*f4a2713aSLionel Sambuc   int x;
39*f4a2713aSLionel Sambuc   class C {
40*f4a2713aSLionel Sambuc     int member;
41*f4a2713aSLionel Sambuc 
f(int param)42*f4a2713aSLionel Sambuc     int f(int param) {
43*f4a2713aSLionel Sambuc       return member;
44*f4a2713aSLionel Sambuc     }
45*f4a2713aSLionel Sambuc   };
46*f4a2713aSLionel Sambuc }
47*f4a2713aSLionel Sambuc 
48*f4a2713aSLionel Sambuc // RUN: c-index-test -code-completion-at=%s:20:2 %s -std=c++0x | FileCheck -check-prefix=CHECK-CC1 %s
49*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:20:2 -std=c++0x %s | FileCheck -check-prefix=CHECK-CC1 %s
50*f4a2713aSLionel Sambuc // CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText alignof}{LeftParen (}{Placeholder type}{RightParen )} (40)
51*f4a2713aSLionel Sambuc // CHECK-CC1: NotImplemented:{ResultType bool}{TypedText noexcept}{LeftParen (}{Placeholder expression}{RightParen )} (40)
52*f4a2713aSLionel Sambuc // CHECK-CC1: NotImplemented:{ResultType std::nullptr_t}{TypedText nullptr} (40)
53*f4a2713aSLionel Sambuc // CHECK-CC1: NotImplemented:{TypedText operator} (40)
54*f4a2713aSLionel Sambuc // CHECK-CC1-NOT: push_back
55*f4a2713aSLionel Sambuc // CHECK-CC1: ClassDecl:{TypedText string} (50)
56*f4a2713aSLionel Sambuc // CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{RightParen )} (50)
57*f4a2713aSLionel Sambuc // CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{Placeholder const char *}{RightParen )} (50)
58*f4a2713aSLionel Sambuc // CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{Placeholder const char *}{Comma , }{Placeholder int n}{RightParen )} (50)
59*f4a2713aSLionel Sambuc // CHECK-CC1: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
60*f4a2713aSLionel Sambuc // CHECK-CC1: CXXConstructor:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder const T &}{Comma , }{Placeholder unsigned int n}{RightParen )} (50)
61*f4a2713aSLionel Sambuc // CHECK-CC1: FunctionTemplate:{ResultType void}{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder InputIterator first}{Comma , }{Placeholder InputIterator last}{RightParen )} (50)
62*f4a2713aSLionel Sambuc 
63*f4a2713aSLionel Sambuc // RUN: c-index-test -code-completion-at=%s:19:1 %s | FileCheck -check-prefix=CHECK-CC2 %s
64*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:19:1 %s | FileCheck -check-prefix=CHECK-CC2 %s
65*f4a2713aSLionel Sambuc // CHECK-CC2: ClassDecl:{TypedText string} (50)
66*f4a2713aSLionel Sambuc // CHECK-CC2-NOT: CXXConstructor
67*f4a2713aSLionel Sambuc // CHECK-CC2: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
68*f4a2713aSLionel Sambuc 
69*f4a2713aSLionel Sambuc // RUN: c-index-test -code-completion-at=%s:26:15 %s | FileCheck -check-prefix=CHECK-CC3 %s
70*f4a2713aSLionel Sambuc // CHECK-CC3: NotImplemented:{TypedText float} (50)
71*f4a2713aSLionel Sambuc // CHECK-CC3: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{RightParen )} (50)
72*f4a2713aSLionel Sambuc // CHECK-CC3: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{RightParen )} (50)
73*f4a2713aSLionel Sambuc // CHECK-CC3: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
74*f4a2713aSLionel Sambuc // CHECK-CC3: CXXConstructor:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder const T &}{Comma , }{Placeholder unsigned int n}{RightParen )} (50)
75*f4a2713aSLionel Sambuc // CHECK-CC3: FunctionTemplate:{ResultType void}{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder InputIterator first}{Comma , }{Placeholder InputIterator last}{RightParen )} (50)
76*f4a2713aSLionel Sambuc 
77*f4a2713aSLionel Sambuc // RUN: c-index-test -code-completion-at=%s:34:1 %s -std=c++0x | FileCheck -check-prefix=CHECK-CC4 %s
78*f4a2713aSLionel Sambuc // CHECK-CC4: NotImplemented:{ResultType const X *}{TypedText this} (40)
79*f4a2713aSLionel Sambuc 
80*f4a2713aSLionel Sambuc // RUN: c-index-test -code-completion-at=%s:43:14 %s | FileCheck -check-prefix=CHECK-CC5 %s
81*f4a2713aSLionel Sambuc // CHECK-CC5: FieldDecl:{ResultType int}{TypedText member} (8)
82*f4a2713aSLionel Sambuc // CHECK-CC5: ParmDecl:{ResultType int}{TypedText param} (8)
83*f4a2713aSLionel Sambuc // CHECK-CC5: StructDecl:{TypedText X} (50)
84*f4a2713aSLionel Sambuc // CHECK-CC5: VarDecl:{ResultType int}{TypedText x} (12)
85