[clang] [Clang] Unify interface for accessing template arguments as written for class/variable template specializations (PR #81642)
Krystian Stasiowski via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 13 12:31:19 PST 2024
================
@@ -1985,44 +1986,45 @@ class ClassTemplateSpecializationDecl
SpecializedTemplate = TemplDecl;
}
- /// Sets the type of this specialization as it was written by
- /// the user. This will be a class template specialization type.
- void setTypeAsWritten(TypeSourceInfo *T) {
- if (!ExplicitInfo)
- ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
- ExplicitInfo->TypeAsWritten = T;
- }
-
- /// Gets the type of this specialization as it was written by
- /// the user, if it was so written.
- TypeSourceInfo *getTypeAsWritten() const {
- return ExplicitInfo ? ExplicitInfo->TypeAsWritten : nullptr;
+ const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const {
+ if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>())
+ return Info->TemplateArgsAsWritten;
+ return ExplicitInfo.get<const ASTTemplateArgumentListInfo *>();
}
/// Gets the location of the extern keyword, if present.
SourceLocation getExternLoc() const {
- return ExplicitInfo ? ExplicitInfo->ExternLoc : SourceLocation();
+ if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>())
+ return Info->ExternLoc;
+ return SourceLocation();
}
- /// Sets the location of the extern keyword.
- void setExternLoc(SourceLocation Loc) {
- if (!ExplicitInfo)
- ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
- ExplicitInfo->ExternLoc = Loc;
+ /// Gets the location of the template keyword, if present.
+ SourceLocation getTemplateKeywordLoc() const {
+ if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>())
+ return Info->TemplateKeywordLoc;
+ return SourceLocation();
}
- /// Sets the location of the template keyword.
- void setTemplateKeywordLoc(SourceLocation Loc) {
- if (!ExplicitInfo)
- ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
- ExplicitInfo->TemplateKeywordLoc = Loc;
+ void
+ setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten) {
+ if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>())
+ Info->TemplateArgsAsWritten = ArgsWritten;
+ else
+ ExplicitInfo = ArgsWritten;
}
- /// Gets the location of the template keyword, if present.
- SourceLocation getTemplateKeywordLoc() const {
- return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
+ void setTemplateArgsAsWritten(const TemplateArgumentListInfo &ArgsInfo) {
----------------
sdkrystian wrote:
Sure
https://github.com/llvm/llvm-project/pull/81642
More information about the cfe-commits
mailing list