[PATCH] D98160: [clang] Use decltype((E)) for compound requirement type constraint

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 8 13:10:00 PST 2021


rsmith added inline comments.


================
Comment at: clang/lib/AST/ASTContext.cpp:5446
       // Build a new, canonical decltype(expr) type.
       Canon = new (*this, TypeAlignment) DependentDecltypeType(*this, e);
       DependentDecltypeTypes.InsertNode(Canon, InsertPos);
----------------
If we don't track the extra parens here too, we can end up giving the same canonical type to dependent `decltype` types with and without implicit parens, even though they can instantiate to different types. (But I think the simplest way to handle this would be to include the parens in the expression; see other comment.)


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:8643
     QualType MatchedType =
-        BuildDecltypeType(E, E->getBeginLoc()).getCanonicalType();
+        BuildDecltypeType(E, E->getBeginLoc(), true, true).getCanonicalType();
     llvm::SmallVector<TemplateArgument, 1> Args;
----------------
Instead of adding complexity to the type system to deal with this special case, can you directly create a `ParenExpr` here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98160



More information about the cfe-commits mailing list