[libcxx-commits] [PATCH] D127695: WIP: clang: Implement Template Specialization Resugaring
David Rector via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 5 10:11:37 PDT 2022
davrec added inline comments.
================
Comment at: clang/lib/Sema/SemaTemplate.cpp:534-540
+ QualType TransformSubstTemplateTypeParmType(TypeLocBuilder &TLB,
+ SubstTemplateTypeParmTypeLoc TL) {
+ QualType QT = TL.getType();
+ const SubstTemplateTypeParmType *T = TL.getTypePtr();
+ Decl *ReplacedDecl = T->getReplacedDecl();
+
+ Optional<unsigned> PackIndex = T->getPackIndex();
----------------
Haven't thought this through fully, but: would the following make D128113 (storing the pack index in the STTPT or introducing a new sugar type) unnecessary?
```
map<pair<Decl *, unsigned>, Optional<unsigned>> CurPackIndices;
QualType TransformSubstTemplateTypeParmType(TypeLocBuilder &TLB,
SubstTemplateTypeParmTypeLoc TL) {
QualType QT = TL.getType();
const SubstTemplateTypeParmType *T = TL.getTypePtr();
Decl *ReplacedDecl = T->getReplacedDecl();
Optional<unsigned> &PackIndex = CurPackIndices[{ReplacedDecl, T->getIndex()}];
if (!PackIndex && T->getReplacedParameter()->isParameterPack())
PackIndex = 0;
...
if (PackIndex)
++PackIndex;
// ^ maybe reset to zero if > pack size, if we might be resugaring multiple expansions
return QT;
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127695/new/
https://reviews.llvm.org/D127695
More information about the libcxx-commits
mailing list