[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 10 19:14:29 PST 2021


rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Awesome!



================
Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:559
+  // Get the resolved template arguments from the canonical type.
+  // FIXME: Handle the as-written arguments so the sugar is not lost.
+  ArrayRef<TemplateArgument> PResolved =
----------------
Does this matter on the `P` side? (Can we remove this FIXME?)


================
Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:561
+  ArrayRef<TemplateArgument> PResolved =
+      TP->getCanonicalTypeInternal()
+          ->castAs<TemplateSpecializationType>()
----------------
Can we avoid using the `Internal` version here? (The only difference is whether we preserve top-level qualifiers that are outside any type sugar.)

Might also be worth a comment here explaining that we're going to the canonical type first here to step over any alias templates.


================
Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:571-573
+  // FIXME: Should not lose sugar here.
+  if (const auto *SA = dyn_cast<TemplateSpecializationType>(
+          UA->getCanonicalTypeInternal())) {
----------------
I think we can retain type sugar here without too much effort.


================
Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:573
+  if (const auto *SA = dyn_cast<TemplateSpecializationType>(
+          UA->getCanonicalTypeInternal())) {
     // Perform template argument deduction for the template name.
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216



More information about the cfe-commits mailing list