[PATCH] D100713: [clang] NFC: refactor multiple implementations of getDecltypeForParenthesizedExpr

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 27 18:40:18 PDT 2021


mizvekov marked 2 inline comments as done.
mizvekov added inline comments.


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:5845
+  if (!To->isRValue()) {
+    QualType T = Self.Context.getDecltypeForParenthesizedExpr(To);
     InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);
----------------
rsmith wrote:
> mizvekov wrote:
> > aaronpuchert wrote:
> > > mizvekov wrote:
> > > > aaronpuchert wrote:
> > > > > The quote doesn't reference parenthesized expressions, isn't this just coincidentally the same thing?
> > > > It's fundamentally the same thing. The `getDecltypeForParenthesizedExpr` name is what I tried to keep, I don't have better ideas there.
> > > What this is doing is pointwise equal to `getDecltypeForParenthesizedExpr`, but there is no parenthesized expression, and no `decltype`. There is a quote from the standard that defines this separately (by now this seems to be [[http://eel.is/c++draft/expr.cond#4|expr.cond#4]]), and there are some differences especially in the prvalue case. So I'm not sure this helps.
> > Here for XValue and and LValue, the rules are exactly the same as https://eel.is/c++draft/dcl.type.decltype#1.
> > And the original code here even already special cases it...
> > 
> > I am sure there is some way we can agree that we should not repeat the code just because the standard did not bother to give a name to this part of the rules... And again I think it is no coincidence that it makes sense to perform the same changes in all these cases.
> Maybe we can find a more general name for this functionality that doesn't mention `decltype`. Perhaps something like `getReferenceQualifiedType`?
Yes that is a good name, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100713



More information about the cfe-commits mailing list