150
|
1 template <class T>
|
|
2 struct function {
|
|
3 };
|
|
4
|
|
5
|
|
6 void test() {
|
|
7 void (*x)(int, double) = nullptr;
|
|
8
|
|
9 function<void(int, double)> y = {};
|
252
|
10 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-3):28 %s -o - | FileCheck -check-prefix=CHECK-1 %s
|
|
11 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-2):35 %s -o - | FileCheck -check-prefix=CHECK-1 %s
|
150
|
12 // CHECK-1: COMPLETION: Pattern : [<#=#>](int <#parameter#>, double <#parameter#>) { <#body#> }
|
|
13
|
|
14 // == Placeholders for suffix types must be placed properly.
|
|
15 function<void(void(*)(int))> z = {};
|
252
|
16 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):36 %s -o - | FileCheck -check-prefix=CHECK-2 %s
|
150
|
17 // CHECK-2: COMPLETION: Pattern : [<#=#>](void (* <#parameter#>)(int)) { <#body#> }
|
|
18
|
|
19 // == No need for a parameter list if function has no parameters.
|
|
20 function<void()> a = {};
|
252
|
21 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):24 %s -o - | FileCheck -check-prefix=CHECK-3 %s
|
150
|
22 // CHECK-3: COMPLETION: Pattern : [<#=#>] { <#body#> }
|
|
23 }
|
|
24
|
|
25 template <class T, class Allocator = int>
|
|
26 struct vector {};
|
|
27
|
|
28 void test2() {
|
|
29 // == Try to preserve types as written.
|
|
30 function<void(vector<int>)> a = {};
|
|
31
|
|
32 using function_typedef = function<void(vector<int>)>;
|
|
33 function_typedef b = {};
|
252
|
34 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):35 %s -o - | FileCheck -check-prefix=CHECK-4 %s
|
|
35 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-2):24 %s -o - | FileCheck -check-prefix=CHECK-4 %s
|
150
|
36 // CHECK-4: COMPLETION: Pattern : [<#=#>](vector<int> <#parameter#>) { <#body#> }
|
|
37 }
|
|
38
|
|
39 // Check another common function wrapper name.
|
|
40 template <class T> struct unique_function {};
|
|
41
|
|
42 void test3() {
|
|
43 unique_function<void()> a = {};
|
252
|
44 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):31 %s -o - | FileCheck -check-prefix=CHECK-5 %s
|
150
|
45 // CHECK-5: COMPLETION: Pattern : [<#=#>] { <#body#> }
|
|
46 }
|
|
47
|
|
48 template <class T, class U> struct weird_function {};
|
|
49 void test4() {
|
|
50 weird_function<void(), int> b = {};
|
252
|
51 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):35 %s -o - | FileCheck -check-prefix=CHECK-6 %s
|
150
|
52 // CHECK-6-NOT: COMPLETION: Pattern : [<#=
|
|
53 }
|
|
54
|
|
55 void test5() {
|
|
56 // Completions are only added when -code-completion-patterns are enabled.
|
|
57 function<void()> b = {};
|
252
|
58 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):24 %s -o - | FileCheck -check-prefix=CHECK-7 %s
|
150
|
59 // CHECK-7: COMPLETION: Pattern : [<#=
|
252
|
60 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):24 %s -o - | FileCheck -check-prefix=CHECK-8 %s
|
150
|
61 // CHECK-8-NOT: COMPLETION: Pattern : [<#=
|
|
62 }
|
|
63
|
|
64 void test6() {
|
|
65 auto my_lambda = [&](int a, double &b) { return 1.f; };
|
252
|
66 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):58 %s -o - | FileCheck -check-prefix=CHECK-9 %s
|
150
|
67 // CHECK-9: [#float#]my_lambda(<#int a#>, <#double &b#>)[# const#]
|
|
68 }
|
|
69
|
|
70 void test7() {
|
|
71 auto generic_lambda = [&](auto a, const auto &b) { return a + b; };
|
252
|
72 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):70 %s -o - | FileCheck -check-prefix=CHECK-10 %s
|
150
|
73 // CHECK-10: [#auto#]generic_lambda(<#auto a#>, <#const auto &b#>)[# const#]
|
|
74 }
|