@@ -1790,6 +1790,18 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
1790
1790
unsigned NumArgs;
1791
1791
};
1792
1792
1793
+ class SubstTemplateTypeParmTypeBitfields {
1794
+ friend class SubstTemplateTypeParmType ;
1795
+
1796
+ unsigned : NumTypeBits;
1797
+
1798
+ // / Represents the index within a pack if this represents a substitution
1799
+ // / from a pack expansion.
1800
+ // / Positive non-zero number represents the index + 1.
1801
+ // / Zero means this is not substituted from an expansion.
1802
+ unsigned PackIndex;
1803
+ };
1804
+
1793
1805
class SubstTemplateTypeParmPackTypeBitfields {
1794
1806
friend class SubstTemplateTypeParmPackType ;
1795
1807
@@ -1872,6 +1884,7 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
1872
1884
ElaboratedTypeBitfields ElaboratedTypeBits;
1873
1885
VectorTypeBitfields VectorTypeBits;
1874
1886
SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits;
1887
+ SubstTemplateTypeParmTypeBitfields SubstTemplateTypeParmTypeBits;
1875
1888
TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
1876
1889
DependentTemplateSpecializationTypeBitfields
1877
1890
DependentTemplateSpecializationTypeBits;
@@ -4974,9 +4987,12 @@ class SubstTemplateTypeParmType : public Type, public llvm::FoldingSetNode {
4974
4987
// The original type parameter.
4975
4988
const TemplateTypeParmType *Replaced;
4976
4989
4977
- SubstTemplateTypeParmType (const TemplateTypeParmType *Param, QualType Canon)
4990
+ SubstTemplateTypeParmType (const TemplateTypeParmType *Param, QualType Canon,
4991
+ Optional<unsigned > PackIndex)
4978
4992
: Type(SubstTemplateTypeParm, Canon, Canon->getDependence ()),
4979
- Replaced(Param) {}
4993
+ Replaced(Param) {
4994
+ SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0 ;
4995
+ }
4980
4996
4981
4997
public:
4982
4998
// / Gets the template parameter that was substituted for.
@@ -4990,18 +5006,25 @@ class SubstTemplateTypeParmType : public Type, public llvm::FoldingSetNode {
4990
5006
return getCanonicalTypeInternal ();
4991
5007
}
4992
5008
5009
+ Optional<unsigned > getPackIndex () const {
5010
+ if (SubstTemplateTypeParmTypeBits.PackIndex == 0 )
5011
+ return None;
5012
+ return SubstTemplateTypeParmTypeBits.PackIndex - 1 ;
5013
+ }
5014
+
4993
5015
bool isSugared () const { return true ; }
4994
5016
QualType desugar () const { return getReplacementType (); }
4995
5017
4996
5018
void Profile (llvm::FoldingSetNodeID &ID) {
4997
- Profile (ID, getReplacedParameter (), getReplacementType ());
5019
+ Profile (ID, getReplacedParameter (), getReplacementType (), getPackIndex () );
4998
5020
}
4999
5021
5000
5022
static void Profile (llvm::FoldingSetNodeID &ID,
5001
5023
const TemplateTypeParmType *Replaced,
5002
- QualType Replacement) {
5024
+ QualType Replacement, Optional< unsigned > PackIndex ) {
5003
5025
ID.AddPointer (Replaced);
5004
5026
ID.AddPointer (Replacement.getAsOpaquePtr ());
5027
+ ID.AddInteger (PackIndex ? *PackIndex - 1 : 0 );
5005
5028
}
5006
5029
5007
5030
static bool classof (const Type *T) {
0 commit comments