@@ -1792,23 +1792,24 @@ class ClassTemplateSpecializationDecl
1792
1792
llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1793
1793
SpecializedTemplate;
1794
1794
1795
- // / Further info for explicit template specialization/instantiation.
1796
- struct ExplicitSpecializationInfo {
1797
- // / The type-as-written.
1798
- TypeSourceInfo *TypeAsWritten = nullptr ;
1795
+ struct ExplicitInstantiationInfo {
1796
+ // / The template arguments as written..
1797
+ const ASTTemplateArgumentListInfo *TemplateArgsAsWritten = nullptr ;
1799
1798
1800
1799
// / The location of the extern keyword.
1801
1800
SourceLocation ExternLoc;
1802
1801
1803
1802
// / The location of the template keyword.
1804
1803
SourceLocation TemplateKeywordLoc;
1805
1804
1806
- ExplicitSpecializationInfo () = default ;
1805
+ ExplicitInstantiationInfo () = default ;
1807
1806
};
1808
1807
1809
1808
// / Further info for explicit template specialization/instantiation.
1810
1809
// / Does not apply to implicit specializations.
1811
- ExplicitSpecializationInfo *ExplicitInfo = nullptr ;
1810
+ llvm::PointerUnion<const ASTTemplateArgumentListInfo *,
1811
+ ExplicitInstantiationInfo *>
1812
+ ExplicitInfo = nullptr ;
1812
1813
1813
1814
// / The template arguments used to describe this specialization.
1814
1815
const TemplateArgumentList *TemplateArgs;
@@ -1985,44 +1986,45 @@ class ClassTemplateSpecializationDecl
1985
1986
SpecializedTemplate = TemplDecl;
1986
1987
}
1987
1988
1988
- // / Sets the type of this specialization as it was written by
1989
- // / the user. This will be a class template specialization type.
1990
- void setTypeAsWritten (TypeSourceInfo *T) {
1991
- if (!ExplicitInfo)
1992
- ExplicitInfo = new (getASTContext ()) ExplicitSpecializationInfo;
1993
- ExplicitInfo->TypeAsWritten = T;
1994
- }
1995
-
1996
- // / Gets the type of this specialization as it was written by
1997
- // / the user, if it was so written.
1998
- TypeSourceInfo *getTypeAsWritten () const {
1999
- return ExplicitInfo ? ExplicitInfo->TypeAsWritten : nullptr ;
1989
+ const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten () const {
1990
+ if (auto *Info = ExplicitInfo.dyn_cast <ExplicitInstantiationInfo *>())
1991
+ return Info->TemplateArgsAsWritten ;
1992
+ return ExplicitInfo.get <const ASTTemplateArgumentListInfo *>();
2000
1993
}
2001
1994
2002
1995
// / Gets the location of the extern keyword, if present.
2003
1996
SourceLocation getExternLoc () const {
2004
- return ExplicitInfo ? ExplicitInfo->ExternLoc : SourceLocation ();
1997
+ if (auto *Info = ExplicitInfo.dyn_cast <ExplicitInstantiationInfo *>())
1998
+ return Info->ExternLoc ;
1999
+ return SourceLocation ();
2005
2000
}
2006
2001
2007
- // / Sets the location of the extern keyword.
2008
- void setExternLoc ( SourceLocation Loc) {
2009
- if (! ExplicitInfo)
2010
- ExplicitInfo = new ( getASTContext ()) ExplicitSpecializationInfo ;
2011
- ExplicitInfo-> ExternLoc = Loc ;
2002
+ // / Gets the location of the template keyword, if present .
2003
+ SourceLocation getTemplateKeywordLoc () const {
2004
+ if (auto *Info = ExplicitInfo. dyn_cast <ExplicitInstantiationInfo *>() )
2005
+ return Info-> TemplateKeywordLoc ;
2006
+ return SourceLocation () ;
2012
2007
}
2013
2008
2014
- // / Sets the location of the template keyword.
2015
- void setTemplateKeywordLoc (SourceLocation Loc) {
2016
- if (!ExplicitInfo)
2017
- ExplicitInfo = new (getASTContext ()) ExplicitSpecializationInfo;
2018
- ExplicitInfo->TemplateKeywordLoc = Loc;
2009
+ void
2010
+ setTemplateArgsAsWritten (const ASTTemplateArgumentListInfo *ArgsWritten) {
2011
+ if (auto *Info = ExplicitInfo.dyn_cast <ExplicitInstantiationInfo *>())
2012
+ Info->TemplateArgsAsWritten = ArgsWritten;
2013
+ else
2014
+ ExplicitInfo = ArgsWritten;
2019
2015
}
2020
2016
2021
- // / Gets the location of the template keyword, if present.
2022
- SourceLocation getTemplateKeywordLoc () const {
2023
- return ExplicitInfo ? ExplicitInfo-> TemplateKeywordLoc : SourceLocation ( );
2017
+ void setTemplateArgsAsWritten ( const TemplateArgumentListInfo &ArgsInfo) {
2018
+ setTemplateArgsAsWritten (
2019
+ ASTTemplateArgumentListInfo::Create ( getASTContext (), ArgsInfo) );
2024
2020
}
2025
2021
2022
+ // / Sets the location of the extern keyword.
2023
+ void setExternLoc (SourceLocation Loc);
2024
+
2025
+ // / Sets the location of the template keyword.
2026
+ void setTemplateKeywordLoc (SourceLocation Loc);
2027
+
2026
2028
SourceRange getSourceRange () const override LLVM_READONLY;
2027
2029
2028
2030
void Profile (llvm::FoldingSetNodeID &ID) const {
@@ -2050,10 +2052,6 @@ class ClassTemplatePartialSpecializationDecl
2050
2052
// / The list of template parameters
2051
2053
TemplateParameterList* TemplateParams = nullptr ;
2052
2054
2053
- // / The source info for the template arguments as written.
2054
- // / FIXME: redundant with TypeAsWritten?
2055
- const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr ;
2056
-
2057
2055
// / The class template partial specialization from which this
2058
2056
// / class template partial specialization was instantiated.
2059
2057
// /
@@ -2062,15 +2060,11 @@ class ClassTemplatePartialSpecializationDecl
2062
2060
llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1 , bool >
2063
2061
InstantiatedFromMember;
2064
2062
2065
- ClassTemplatePartialSpecializationDecl (ASTContext &Context, TagKind TK,
2066
- DeclContext *DC,
2067
- SourceLocation StartLoc,
2068
- SourceLocation IdLoc,
2069
- TemplateParameterList *Params,
2070
- ClassTemplateDecl *SpecializedTemplate,
2071
- ArrayRef<TemplateArgument> Args,
2072
- const ASTTemplateArgumentListInfo *ArgsAsWritten,
2073
- ClassTemplatePartialSpecializationDecl *PrevDecl);
2063
+ ClassTemplatePartialSpecializationDecl (
2064
+ ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc,
2065
+ SourceLocation IdLoc, TemplateParameterList *Params,
2066
+ ClassTemplateDecl *SpecializedTemplate, ArrayRef<TemplateArgument> Args,
2067
+ ClassTemplatePartialSpecializationDecl *PrevDecl);
2074
2068
2075
2069
ClassTemplatePartialSpecializationDecl (ASTContext &C)
2076
2070
: ClassTemplateSpecializationDecl(C, ClassTemplatePartialSpecialization),
@@ -2085,11 +2079,8 @@ class ClassTemplatePartialSpecializationDecl
2085
2079
static ClassTemplatePartialSpecializationDecl *
2086
2080
Create (ASTContext &Context, TagKind TK, DeclContext *DC,
2087
2081
SourceLocation StartLoc, SourceLocation IdLoc,
2088
- TemplateParameterList *Params,
2089
- ClassTemplateDecl *SpecializedTemplate,
2090
- ArrayRef<TemplateArgument> Args,
2091
- const TemplateArgumentListInfo &ArgInfos,
2092
- QualType CanonInjectedType,
2082
+ TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate,
2083
+ ArrayRef<TemplateArgument> Args, QualType CanonInjectedType,
2093
2084
ClassTemplatePartialSpecializationDecl *PrevDecl);
2094
2085
2095
2086
static ClassTemplatePartialSpecializationDecl *
@@ -2120,11 +2111,6 @@ class ClassTemplatePartialSpecializationDecl
2120
2111
return TemplateParams->hasAssociatedConstraints ();
2121
2112
}
2122
2113
2123
- // / Get the template arguments as written.
2124
- const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten () const {
2125
- return ArgsAsWritten;
2126
- }
2127
-
2128
2114
// / Retrieve the member class template partial specialization from
2129
2115
// / which this particular class template partial specialization was
2130
2116
// / instantiated.
@@ -2596,23 +2582,24 @@ class VarTemplateSpecializationDecl : public VarDecl,
2596
2582
llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2597
2583
SpecializedTemplate;
2598
2584
2599
- // / Further info for explicit template specialization/instantiation.
2600
- struct ExplicitSpecializationInfo {
2601
- // / The type-as-written.
2602
- TypeSourceInfo *TypeAsWritten = nullptr ;
2585
+ struct ExplicitInstantiationInfo {
2586
+ // / The template arguments as written..
2587
+ const ASTTemplateArgumentListInfo *TemplateArgsAsWritten = nullptr ;
2603
2588
2604
2589
// / The location of the extern keyword.
2605
2590
SourceLocation ExternLoc;
2606
2591
2607
2592
// / The location of the template keyword.
2608
2593
SourceLocation TemplateKeywordLoc;
2609
2594
2610
- ExplicitSpecializationInfo () = default ;
2595
+ ExplicitInstantiationInfo () = default ;
2611
2596
};
2612
2597
2613
2598
// / Further info for explicit template specialization/instantiation.
2614
2599
// / Does not apply to implicit specializations.
2615
- ExplicitSpecializationInfo *ExplicitInfo = nullptr ;
2600
+ llvm::PointerUnion<const ASTTemplateArgumentListInfo *,
2601
+ ExplicitInstantiationInfo *>
2602
+ ExplicitInfo = nullptr ;
2616
2603
2617
2604
// / The template arguments used to describe this specialization.
2618
2605
const TemplateArgumentList *TemplateArgs;
@@ -2670,14 +2657,6 @@ class VarTemplateSpecializationDecl : public VarDecl,
2670
2657
// / specialization.
2671
2658
const TemplateArgumentList &getTemplateArgs () const { return *TemplateArgs; }
2672
2659
2673
- // TODO: Always set this when creating the new specialization?
2674
- void setTemplateArgsInfo (const TemplateArgumentListInfo &ArgsInfo);
2675
- void setTemplateArgsInfo (const ASTTemplateArgumentListInfo *ArgsInfo);
2676
-
2677
- const ASTTemplateArgumentListInfo *getTemplateArgsInfo () const {
2678
- return TemplateArgsInfo;
2679
- }
2680
-
2681
2660
// / Determine the kind of specialization that this
2682
2661
// / declaration represents.
2683
2662
TemplateSpecializationKind getSpecializationKind () const {
@@ -2781,44 +2760,45 @@ class VarTemplateSpecializationDecl : public VarDecl,
2781
2760
SpecializedTemplate = TemplDecl;
2782
2761
}
2783
2762
2784
- // / Sets the type of this specialization as it was written by
2785
- // / the user.
2786
- void setTypeAsWritten (TypeSourceInfo *T) {
2787
- if (!ExplicitInfo)
2788
- ExplicitInfo = new (getASTContext ()) ExplicitSpecializationInfo;
2789
- ExplicitInfo->TypeAsWritten = T;
2790
- }
2791
-
2792
- // / Gets the type of this specialization as it was written by
2793
- // / the user, if it was so written.
2794
- TypeSourceInfo *getTypeAsWritten () const {
2795
- return ExplicitInfo ? ExplicitInfo->TypeAsWritten : nullptr ;
2763
+ const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten () const {
2764
+ if (auto *Info = ExplicitInfo.dyn_cast <ExplicitInstantiationInfo *>())
2765
+ return Info->TemplateArgsAsWritten ;
2766
+ return ExplicitInfo.get <const ASTTemplateArgumentListInfo *>();
2796
2767
}
2797
2768
2798
2769
// / Gets the location of the extern keyword, if present.
2799
2770
SourceLocation getExternLoc () const {
2800
- return ExplicitInfo ? ExplicitInfo->ExternLoc : SourceLocation ();
2771
+ if (auto *Info = ExplicitInfo.dyn_cast <ExplicitInstantiationInfo *>())
2772
+ return Info->ExternLoc ;
2773
+ return SourceLocation ();
2801
2774
}
2802
2775
2803
- // / Sets the location of the extern keyword.
2804
- void setExternLoc ( SourceLocation Loc) {
2805
- if (! ExplicitInfo)
2806
- ExplicitInfo = new ( getASTContext ()) ExplicitSpecializationInfo ;
2807
- ExplicitInfo-> ExternLoc = Loc ;
2776
+ // / Gets the location of the template keyword, if present .
2777
+ SourceLocation getTemplateKeywordLoc () const {
2778
+ if (auto *Info = ExplicitInfo. dyn_cast <ExplicitInstantiationInfo *>() )
2779
+ return Info-> TemplateKeywordLoc ;
2780
+ return SourceLocation () ;
2808
2781
}
2809
2782
2810
- // / Sets the location of the template keyword.
2811
- void setTemplateKeywordLoc (SourceLocation Loc) {
2812
- if (!ExplicitInfo)
2813
- ExplicitInfo = new (getASTContext ()) ExplicitSpecializationInfo;
2814
- ExplicitInfo->TemplateKeywordLoc = Loc;
2783
+ void
2784
+ setTemplateArgsAsWritten (const ASTTemplateArgumentListInfo *ArgsWritten) {
2785
+ if (auto *Info = ExplicitInfo.dyn_cast <ExplicitInstantiationInfo *>())
2786
+ Info->TemplateArgsAsWritten = ArgsWritten;
2787
+ else
2788
+ ExplicitInfo = ArgsWritten;
2815
2789
}
2816
2790
2817
- // / Gets the location of the template keyword, if present.
2818
- SourceLocation getTemplateKeywordLoc () const {
2819
- return ExplicitInfo ? ExplicitInfo-> TemplateKeywordLoc : SourceLocation ( );
2791
+ void setTemplateArgsAsWritten ( const TemplateArgumentListInfo &ArgsInfo) {
2792
+ setTemplateArgsAsWritten (
2793
+ ASTTemplateArgumentListInfo::Create ( getASTContext (), ArgsInfo) );
2820
2794
}
2821
2795
2796
+ // / Sets the location of the extern keyword.
2797
+ void setExternLoc (SourceLocation Loc);
2798
+
2799
+ // / Sets the location of the template keyword.
2800
+ void setTemplateKeywordLoc (SourceLocation Loc);
2801
+
2822
2802
SourceRange getSourceRange () const override LLVM_READONLY;
2823
2803
2824
2804
void Profile (llvm::FoldingSetNodeID &ID) const {
@@ -2846,10 +2826,6 @@ class VarTemplatePartialSpecializationDecl
2846
2826
// / The list of template parameters
2847
2827
TemplateParameterList *TemplateParams = nullptr ;
2848
2828
2849
- // / The source info for the template arguments as written.
2850
- // / FIXME: redundant with TypeAsWritten?
2851
- const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr ;
2852
-
2853
2829
// / The variable template partial specialization from which this
2854
2830
// / variable template partial specialization was instantiated.
2855
2831
// /
@@ -2862,8 +2838,7 @@ class VarTemplatePartialSpecializationDecl
2862
2838
ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
2863
2839
SourceLocation IdLoc, TemplateParameterList *Params,
2864
2840
VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
2865
- StorageClass S, ArrayRef<TemplateArgument> Args,
2866
- const ASTTemplateArgumentListInfo *ArgInfos);
2841
+ StorageClass S, ArrayRef<TemplateArgument> Args);
2867
2842
2868
2843
VarTemplatePartialSpecializationDecl (ASTContext &Context)
2869
2844
: VarTemplateSpecializationDecl(VarTemplatePartialSpecialization,
@@ -2880,8 +2855,8 @@ class VarTemplatePartialSpecializationDecl
2880
2855
Create (ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
2881
2856
SourceLocation IdLoc, TemplateParameterList *Params,
2882
2857
VarTemplateDecl *SpecializedTemplate, QualType T,
2883
- TypeSourceInfo *TInfo, StorageClass S, ArrayRef<TemplateArgument> Args,
2884
- const TemplateArgumentListInfo &ArgInfos );
2858
+ TypeSourceInfo *TInfo, StorageClass S,
2859
+ ArrayRef<TemplateArgument> Args );
2885
2860
2886
2861
static VarTemplatePartialSpecializationDecl *CreateDeserialized (ASTContext &C,
2887
2862
unsigned ID);
@@ -2897,11 +2872,6 @@ class VarTemplatePartialSpecializationDecl
2897
2872
return TemplateParams;
2898
2873
}
2899
2874
2900
- // / Get the template arguments as written.
2901
- const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten () const {
2902
- return ArgsAsWritten;
2903
- }
2904
-
2905
2875
// / \brief All associated constraints of this partial specialization,
2906
2876
// / including the requires clause and any constraints derived from
2907
2877
// / constrained-parameters.
0 commit comments