brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.0 KiB · ea97237 Raw
154 lines · cpp
1struct A {2  void foo(this auto&& self, int arg);3  void bar(this A self, int arg);4};5 6int func1() {7  A a {};8  a.9}10// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):5 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC1 %s11// CHECK-CC1: COMPLETION: A : A::12// CHECK-NEXT-CC1: COMPLETION: bar : [#void#]bar(<#int arg#>)13// CHECK-NEXT-CC1: COMPLETION: foo : [#void#]foo(<#int arg#>)14// CHECK-NEXT-CC1: COMPLETION: operator= : [#A &#]operator=(<#const A &#>)15// CHECK-NEXT-CC1: COMPLETION: operator= : [#A &#]operator=(<#A &&#>)16// CHECK-NEXT-CC1: COMPLETION: ~A : [#void#]~A()17 18struct B {19  template <typename T>20  void foo(this T&& self, int arg);21};22 23int func2() {24  B b {};25  b.foo();26}27// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):9 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC2 %s28// CHECK-CC2: OVERLOAD: [#void#]foo(int arg)29 30// TODO: llvm/llvm-project/14664931// This is incorrect behavior. Correct Result should be a variant of, 32// CC3: should be something like [#void#]foo(<#A self#>, <#int arg#>)33// CC4: should be something like [#void#]bar(<#A self#>, <#int arg#>)34int func3() {35  (&A::foo)36  (&A::bar)37}38// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):10 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC3 %s39// CHECK-CC3: COMPLETION: foo : [#void#]foo<<#class self:auto#>>(<#int arg#>)40// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):10 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC4 %s41// CHECK-CC4: COMPLETION: bar : [#void#]bar(<#int arg#>)42 43int func4() {44  // TODO (&A::foo)(45  (&A::bar)()46}47// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):13 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC5 %s48// CHECK-CC5: OVERLOAD: [#void#](<#A#>, int)49 50struct C {51  int member {};52  int memberFnA(int a);53  int memberFnA(this C&, float a);54 55  void foo(this C& self) {56    // Should not offer any members here, since 57    // it needs to be referenced through `self`.58    mem59    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 -std=c++23 %s | FileCheck --allow-empty %s60    // CHECK-NOT: COMPLETION: member : [#int#]member61    // CHECK-NOT: COMPLETION: memberFnA : [#int#]memberFnA(<#int a#>)62    // CHECK-NOT: COMPLETION: memberFnA : [#int#]memberFnA(<#float a#>)63  }64  void bar(this C& self) {65    // should offer all results66    self.mem67    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):13 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC6 %s68    // CHECK-CC6: COMPLETION: member : [#int#]member69    // CHECK-CC6: COMPLETION: memberFnA : [#int#]memberFnA(<#int a#>)70    // CHECK-CC6: COMPLETION: memberFnA : [#int#]memberFnA(<#float a#>)71  }72  void baz(this C& self) {73    [&]() {74      // Should not offer any results75      mem76      // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):10 -std=c++23 %s | FileCheck --allow-empty %s77      // CHECK-NOT: COMPLETION: member : [#int#]member78      // CHECK-NOT: COMPLETION: memberFnA : [#int#]memberFnA(<#int a#>)79      // CHECK-NOT: COMPLETION: memberFnA : [#int#]memberFnA(<#float a#>)80    }();81  }82};83 84 85struct S {86  void foo1(int a);87  void foo2(int a) const;88  void foo2(this const S& self, float a);  89  void foo3(this const S& self, int a);90  void foo4(this S& self, int a);91};92 93void S::foo1(int a) {94  this->;95// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC7 %s96// CHECK-CC7: COMPLETION: foo1 : [#void#]foo1(<#int a#>)97// CHECK-CC7: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]98// CHECK-CC7: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]99// CHECK-CC7: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]100// CHECK-CC7: COMPLETION: foo4 : [#void#]foo4(<#int a#>)101}102 103void S::foo2(int a) const {104  this->;105// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC8 %s106// CHECK-CC8: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]107// CHECK-CC8: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]108// CHECK-CC8: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]109}110 111void S::foo3(this const S& self, int a) {112  self.;113// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC9 %s114// CHECK-CC9: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]115// CHECK-CC9: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]116// CHECK-CC9: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]117}118 119void S::foo4(this S& self, int a) {120  self.;121// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC10 %s122// CHECK-CC10: COMPLETION: foo1 : [#void#]foo1(<#int a#>)123// CHECK-CC10: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]124// CHECK-CC10: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]125// CHECK-CC10: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]126// CHECK-CC10: COMPLETION: foo4 : [#void#]foo4(<#int a#>)127}128 129void test1(S s) {130  s.;131// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):5 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC11 %s132// CHECK-CC11: COMPLETION: foo1 : [#void#]foo1(<#int a#>)133// CHECK-CC11: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]134// CHECK-CC11: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]135// CHECK-CC11: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]136// CHECK-CC11: COMPLETION: foo4 : [#void#]foo4(<#int a#>)137}138 139void test2(const S s) {140  s.;141// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):5 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC12 %s142// CHECK-CC12: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]143// CHECK-CC12: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]144// CHECK-CC12: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]145}146 147void test3(S s) {148  s.foo2();149// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):10 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC13 %s150// CHECK-CC13: OVERLOAD: [#void#]foo2(<#int a#>)151// CHECK-CC13: OVERLOAD: [#void#]foo2(float a)152// TODO: foo2 should be OVERLOAD: [#void#]foo2(<#float a#>)153}154