xref: /minix3/external/bsd/llvm/dist/clang/test/Index/annotate-tokens-cxx0x.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc template<typename ...Args>
f(Args...args)2f4a2713aSLionel Sambuc int f(Args ...args) {
3f4a2713aSLionel Sambuc   return sizeof...(args) + sizeof...(Args);
4f4a2713aSLionel Sambuc }
5f4a2713aSLionel Sambuc 
test()6f4a2713aSLionel Sambuc void test() {
7f4a2713aSLionel Sambuc   int a;
8f4a2713aSLionel Sambuc   decltype(a) b;
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc   typedef int Integer;
11f4a2713aSLionel Sambuc   typedef float Float;
12f4a2713aSLionel Sambuc   typedef bool Bool;
13f4a2713aSLionel Sambuc   bool b2 = __is_trivially_constructible(Integer, Float, Bool);
14f4a2713aSLionel Sambuc }
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc typedef int Int;
17f4a2713aSLionel Sambuc 
18f4a2713aSLionel Sambuc class B {
19f4a2713aSLionel Sambuc  virtual void foo(Int);
20f4a2713aSLionel Sambuc };
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc class S : public B {
23f4a2713aSLionel Sambuc   virtual void foo(Int) override;
24f4a2713aSLionel Sambuc };
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc // Need std::initializer_list
27f4a2713aSLionel Sambuc namespace std {
28f4a2713aSLionel Sambuc   typedef decltype(sizeof(int)) size_t;
29f4a2713aSLionel Sambuc 
30f4a2713aSLionel Sambuc   // libc++'s implementation
31f4a2713aSLionel Sambuc   template <class _E>
32f4a2713aSLionel Sambuc   class initializer_list
33f4a2713aSLionel Sambuc   {
34f4a2713aSLionel Sambuc     const _E* __begin_;
35f4a2713aSLionel Sambuc     size_t    __size_;
36f4a2713aSLionel Sambuc 
initializer_list(const _E * __b,size_t __s)37f4a2713aSLionel Sambuc     initializer_list(const _E* __b, size_t __s)
38f4a2713aSLionel Sambuc       : __begin_(__b),
39f4a2713aSLionel Sambuc         __size_(__s)
40f4a2713aSLionel Sambuc     {}
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc   public:
43f4a2713aSLionel Sambuc     typedef _E        value_type;
44f4a2713aSLionel Sambuc     typedef const _E& reference;
45f4a2713aSLionel Sambuc     typedef const _E& const_reference;
46f4a2713aSLionel Sambuc     typedef size_t    size_type;
47f4a2713aSLionel Sambuc 
48f4a2713aSLionel Sambuc     typedef const _E* iterator;
49f4a2713aSLionel Sambuc     typedef const _E* const_iterator;
50f4a2713aSLionel Sambuc 
initializer_list()51f4a2713aSLionel Sambuc     initializer_list() : __begin_(nullptr), __size_(0) {}
52f4a2713aSLionel Sambuc 
size() const53f4a2713aSLionel Sambuc     size_t    size()  const {return __size_;}
begin() const54f4a2713aSLionel Sambuc     const _E* begin() const {return __begin_;}
end() const55f4a2713aSLionel Sambuc     const _E* end()   const {return __begin_ + __size_;}
56f4a2713aSLionel Sambuc   };
57f4a2713aSLionel Sambuc }
58f4a2713aSLionel Sambuc 
59f4a2713aSLionel Sambuc struct Foo {
60f4a2713aSLionel Sambuc   Foo(std::initializer_list<int> il);
61f4a2713aSLionel Sambuc };
62f4a2713aSLionel Sambuc 
test2()63f4a2713aSLionel Sambuc void test2() {
64f4a2713aSLionel Sambuc   Foo{10};
65f4a2713aSLionel Sambuc }
66f4a2713aSLionel Sambuc 
67f4a2713aSLionel Sambuc 
68f4a2713aSLionel Sambuc // RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 -fno-delayed-template-parsing -std=c++11 %s | FileCheck %s
69f4a2713aSLionel Sambuc // CHECK: Identifier: "args" [3:20 - 3:24] SizeOfPackExpr=args:2:15
70f4a2713aSLionel Sambuc // CHECK: Identifier: "Args" [3:38 - 3:42] TypeRef=Args:1:22
71f4a2713aSLionel Sambuc 
72f4a2713aSLionel Sambuc // RUN: c-index-test -test-annotate-tokens=%s:8:1:9:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-DECLTYPE %s
73f4a2713aSLionel Sambuc // CHECK-DECLTYPE: Identifier: "a" [8:12 - 8:13] DeclRefExpr=a:7:7
74f4a2713aSLionel Sambuc 
75f4a2713aSLionel Sambuc // RUN: c-index-test -test-annotate-tokens=%s:13:1:14:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-TRAIT %s
76f4a2713aSLionel Sambuc // CHECK-TRAIT: Identifier: "Integer" [13:42 - 13:49] TypeRef=Integer:10:15
77f4a2713aSLionel Sambuc // CHECK-TRAIT: Identifier: "Float" [13:51 - 13:56] TypeRef=Float:11:17
78f4a2713aSLionel Sambuc // CHECK-TRAIT: Identifier: "Bool" [13:58 - 13:62] TypeRef=Bool:12:16
79f4a2713aSLionel Sambuc 
80f4a2713aSLionel Sambuc // RUN: c-index-test -test-annotate-tokens=%s:16:1:24:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-WITH-OVERRIDE %s
81f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Keyword: "virtual" [19:2 - 19:9] CXXMethod=foo:19:15 (virtual)
82f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Keyword: "void" [19:10 - 19:14] CXXMethod=foo:19:15 (virtual)
83f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Identifier: "foo" [19:15 - 19:18] CXXMethod=foo:19:15 (virtual)
84f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Punctuation: "(" [19:18 - 19:19] CXXMethod=foo:19:15 (virtual)
85f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Identifier: "Int" [19:19 - 19:22] TypeRef=Int:16:13
86*0a6a1f1dSLionel Sambuc // CHECK-WITH-OVERRIDE: Punctuation: ")" [19:22 - 19:23] CXXMethod=foo:19:15 (virtual)
87f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Punctuation: ";" [19:23 - 19:24] ClassDecl=B:18:7 (Definition)
88f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Keyword: "virtual" [23:3 - 23:10] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
89f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Keyword: "void" [23:11 - 23:15] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
90f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Identifier: "foo" [23:16 - 23:19] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
91f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Punctuation: "(" [23:19 - 23:20] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
92f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Identifier: "Int" [23:20 - 23:23] TypeRef=Int:16:13
93*0a6a1f1dSLionel Sambuc // CHECK-WITH-OVERRIDE: Punctuation: ")" [23:23 - 23:24] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
94f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Keyword: "override" [23:25 - 23:33] attribute(override)=
95f4a2713aSLionel Sambuc // CHECK-WITH-OVERRIDE: Punctuation: ";" [23:33 - 23:34] ClassDecl=S:22:7 (Definition)
96f4a2713aSLionel Sambuc 
97f4a2713aSLionel Sambuc // RUN: c-index-test -test-annotate-tokens=%s:64:1:65:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-INITLIST %s
98f4a2713aSLionel Sambuc // CHECK-INITLIST: Identifier: "Foo" [64:3 - 64:6] TypeRef=struct Foo:59:8
99