[PATCH] D140828: [C++] Implement "Deducing this" (P0847R7)

Corentin Jabot via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 04:37:38 PDT 2023


cor3ntin added inline comments.


================
Comment at: clang/test/CodeGenCXX/cxx2b-deducing-this.cpp:4
+
+struct TrivialStruct {
+    void explicit_object_function(this TrivialStruct) {}
----------------
cor3ntin wrote:
> aaron.ballman wrote:
> > I'd like to see more codegen tests in general -- for example, a test that demonstrates we properly handle code like:
> > ```
> > struct B {
> >   virtual void f();
> > };
> > 
> > struct T {};
> > struct D3 : B {
> >   void f(this T&); // Okay, not an override
> > };
> > 
> > void func() {
> >   T t;
> >   t.f(); // Verify this calls D3::f() and not B::f()
> > }
> > ```
> > but also tests that show that we do the correct thing for calling conventions (do explicit object parameter functions act as `__fastcall` functions?), explicit object parameters in lambdas, call through a pointer to member function, and so on.
> > 
> > Another test that could be interesting is how chained calls look (roughly):
> > ```
> > struct S {
> >   void foo(this const S&);
> > };
> > 
> > struct T {
> >   S bar(this const &T);
> > };
> > 
> > void func() {
> >   T t;
> >   t.bar().foo();
> > }
> > ```
> That first example is ill-formed (it is an override, not allowed)
> 
> I will need help for codegen tests.
> For `__thiscall`, are we even doing the same thing? https://compiler-explorer.com/z/KTea6W36T
NVM, just different optimization levels


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140828/new/

https://reviews.llvm.org/D140828



More information about the llvm-commits mailing list