[PATCH] D140828: [C++] Implement "Deducing this" (P0847R7)
Corentin Jabot via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 8 07:28:33 PDT 2023
cor3ntin marked an inline comment as done.
cor3ntin added inline comments.
================
Comment at: clang/lib/CodeGen/CGExpr.cpp:4283
+ if (HasExplicitObjectParameter) {
+ const VarDecl *D = cast<CXXMethodDecl>(CurCodeDecl)->getParamDecl(0);
+ auto It = LocalDeclMap.find(D);
----------------
aaron.ballman wrote:
> Above we did `dyn_cast_if_present<CXXMethodDecl>(CurCodeDecl)` and here we're doing a straight-up `cast<>`. Which is incorrect?
neither, once `HasExplicitObjectParameter` is true we know it's a CXXMethodDecl
================
Comment at: clang/test/SemaCXX/cxx2b-deducing-this.cpp:42
+ int f(this B&, int); // expected-warning {{hides overloaded virtual function}}
+ int f(this B&); // expected-error {{an explicit object parameter cannot appear in a virtual function}}
+ int g(this B&); // expected-warning {{hides overloaded virtual function}}
----------------
aaron.ballman wrote:
> According to the paper, this is accepted but `B::f()` does not override `A::f()`.
>
> https://eel.is/c++draft/dcl.fct#6.sentence-3
>
> `B::f()` is not declared as virtual, only `A::f()` is.
>
> When this gets corrected, please add some codegen tests to demonstrate that a call to `f()` does not dispatch to `B::f()` unless the static type of the object is `B`.
This is this is https://cplusplus.github.io/CWG/issues/2553.html, I will leave a comment to clarify
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140828/new/
https://reviews.llvm.org/D140828
More information about the cfe-commits
mailing list