brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 53524fc Raw
75 lines · cpp
1template <class T>2struct function {3};4 5 6void test() {7  void (*x)(int, double) = nullptr;8 9  function<void(int, double)> y = {};10  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-3):28 %s -o - | FileCheck -check-prefix=CHECK-1 %s11  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-2):35 %s -o - | FileCheck -check-prefix=CHECK-1 %s12  // 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 = {};16  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):36 %s -o - | FileCheck -check-prefix=CHECK-2 %s17  // 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 = {};21  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):24 %s -o - | FileCheck -check-prefix=CHECK-3 %s22  // CHECK-3: COMPLETION: Pattern : [<#=#>] { <#body#> }23}24 25template <class T, class Allocator = int>26struct vector {};27 28void 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 = {};34  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):35 %s -o - | FileCheck -check-prefix=CHECK-4 %s35  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-2):24 %s -o - | FileCheck -check-prefix=CHECK-4 %s36  // CHECK-4: COMPLETION: Pattern : [<#=#>](vector<int> <#parameter#>) { <#body#> }37}38 39// Check another common function wrapper name.40template <class T> struct unique_function {};41 42void test3() {43  unique_function<void()> a = {};44  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):31 %s -o - | FileCheck -check-prefix=CHECK-5 %s45  // CHECK-5: COMPLETION: Pattern : [<#=#>] { <#body#> }46}47 48template <class T, class U> struct weird_function {};49void test4() {50  weird_function<void(), int> b = {};51  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):35 %s -o - | FileCheck -check-prefix=CHECK-6 %s52  // CHECK-6-NOT: COMPLETION: Pattern : [<#=53}54 55void test5() {56  // Completions are only added when -code-completion-patterns are enabled.57  function<void()> b = {};58  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):24 %s -o - | FileCheck -check-prefix=CHECK-7 %s59  // CHECK-7: COMPLETION: Pattern : [<#=60  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):24 %s -o - | FileCheck -check-prefix=CHECK-8 %s61  // CHECK-8-NOT: COMPLETION: Pattern : [<#=62}63 64void test6() {65  auto my_lambda = [&](int a, double &b) { return 1.f; };66  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):58 %s -o - | FileCheck -check-prefix=CHECK-9 %s67  // CHECK-9: [#float#]my_lambda(<#int a#>, <#double &b#>)[# const#]68}69 70void test7() {71  auto generic_lambda = [&](auto a, const auto &b) { return a + b; };72  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):70 %s -o - | FileCheck -check-prefix=CHECK-10 %s73  // CHECK-10: [#auto#]generic_lambda(<#auto a#>, <#const auto &b#>)[# const#]74}75