[clang] [clang-tools-extra] [lldb] Revert "[clang] Reland: fix getTemplateInstantiationArgs" (PR #201864)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 5 08:26:59 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen
Author: Hans Wennborg (zmodem)
<details>
<summary>Changes</summary>
Reverts llvm/llvm-project#<!-- -->201373
This caused compilation errors. See comment on the original PR.
---
Patch is 272.42 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/201864.diff
61 Files Affected:
- (modified) clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp (+1-1)
- (modified) clang-tools-extra/clangd/SemanticHighlighting.cpp (+18-21)
- (modified) clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp (+1-1)
- (modified) clang/docs/ReleaseNotes.rst (-1)
- (modified) clang/include/clang/AST/Decl.h (+37-21)
- (modified) clang/include/clang/AST/DeclTemplate.h (+95-96)
- (modified) clang/include/clang/AST/JSONNodeDumper.h (-1)
- (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+6-8)
- (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (-5)
- (modified) clang/include/clang/ASTMatchers/ASTMatchersInternal.h (+6-2)
- (modified) clang/include/clang/Basic/Specifiers.h (-3)
- (modified) clang/include/clang/Sema/Sema.h (+101-42)
- (modified) clang/lib/AST/ASTContext.cpp (-2)
- (modified) clang/lib/AST/ASTDumper.cpp (-1)
- (modified) clang/lib/AST/ASTImporter.cpp (+34-97)
- (modified) clang/lib/AST/Comment.cpp (+4-6)
- (modified) clang/lib/AST/Decl.cpp (+9-36)
- (modified) clang/lib/AST/DeclPrinter.cpp (-1)
- (modified) clang/lib/AST/DeclTemplate.cpp (+94-62)
- (modified) clang/lib/AST/JSONNodeDumper.cpp (-3)
- (modified) clang/lib/AST/TextNodeDumper.cpp (-3)
- (modified) clang/lib/ASTMatchers/Dynamic/Registry.cpp (-1)
- (modified) clang/lib/Analysis/ExprMutationAnalyzer.cpp (+5-8)
- (modified) clang/lib/CIR/CodeGen/CIRGenVTables.cpp (-2)
- (modified) clang/lib/CodeGen/CGVTables.cpp (+15-17)
- (modified) clang/lib/Index/IndexingContext.cpp (-1)
- (modified) clang/lib/InstallAPI/Visitor.cpp (-5)
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+6-8)
- (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+8-7)
- (modified) clang/lib/Sema/SemaConcept.cpp (+129-59)
- (modified) clang/lib/Sema/SemaDecl.cpp (+26-27)
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+4-7)
- (modified) clang/lib/Sema/SemaExprMember.cpp (+3-2)
- (modified) clang/lib/Sema/SemaOverload.cpp (+2-4)
- (modified) clang/lib/Sema/SemaTemplate.cpp (+146-150)
- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+32-11)
- (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+50-7)
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+423-188)
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+167-277)
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+36-41)
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+39-61)
- (modified) clang/lib/StaticAnalyzer/Core/BugSuppression.cpp (+81-10)
- (modified) clang/lib/Tooling/Syntax/BuildTree.cpp (+6-7)
- (modified) clang/test/AST/ast-dump-templates-pattern.cpp (+9-10)
- (modified) clang/test/CXX/basic/basic.link/p11.cpp (+2)
- (modified) clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp (+7-4)
- (modified) clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp (+15-2)
- (modified) clang/test/CXX/temp/temp.decls/temp.spec.partial/temp.spec.partial.member/p2.cpp (-1)
- (modified) clang/test/CXX/temp/temp.spec/temp.expl.spec/p7.cpp (+23)
- (modified) clang/test/CodeGenCXX/default-arguments.cpp (-12)
- (modified) clang/test/CodeGenCXX/explicit-instantiation.cpp (-7)
- (modified) clang/test/SemaTemplate/concepts-out-of-line-def.cpp (+7-2)
- (modified) clang/test/SemaTemplate/friend-template.cpp (-8)
- (modified) clang/test/SemaTemplate/instantiate-scope.cpp (+6-4)
- (modified) clang/test/Templight/templight-default-func-arg.cpp (+10-23)
- (modified) clang/test/Templight/templight-empty-entries-fix.cpp (+38-50)
- (modified) clang/tools/libclang/CIndex.cpp (-1)
- (modified) clang/unittests/AST/ASTImporterTest.cpp (+2-4)
- (modified) clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+8-4)
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-46)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
index a1a705dd043a0..ae063a19d779d 100644
--- a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -106,7 +106,7 @@ void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult &Result) {
return;
diag(FD->getLocation(), "mark the definition as 'inline'",
DiagnosticIDs::Note)
- << FixItHint::CreateInsertion(FD->getFunctionLocStart(), "inline ");
+ << FixItHint::CreateInsertion(FD->getInnerLocStart(), "inline ");
} else if (const auto *VD = dyn_cast<VarDecl>(ND)) {
// C++14 variable templates are allowed.
if (VD->getDescribedVarTemplate())
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 856904bc810d1..d1ed3ea9bc88a 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -590,28 +590,28 @@ class CollectExtraHighlightings
bool
VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D) {
- if (const auto *Info = D->getExplicitInstantiationInfo()) {
- H.addAngleBracketTokens(Info->TemplateArgsAsWritten->getLAngleLoc(),
- Info->TemplateArgsAsWritten->getRAngleLoc());
- } else if (const auto *Info = D->getExplicitSpecializationInfo()) {
- H.addAngleBracketTokens(Info->TemplateParams->getLAngleLoc(),
- Info->TemplateParams->getRAngleLoc());
- H.addAngleBracketTokens(Info->TemplateArgsAsWritten->getLAngleLoc(),
- Info->TemplateArgsAsWritten->getRAngleLoc());
- }
+ if (auto *Args = D->getTemplateArgsAsWritten())
+ H.addAngleBracketTokens(Args->getLAngleLoc(), Args->getRAngleLoc());
+ return true;
+ }
+
+ bool VisitClassTemplatePartialSpecializationDecl(
+ ClassTemplatePartialSpecializationDecl *D) {
+ if (auto *TPL = D->getTemplateParameters())
+ H.addAngleBracketTokens(TPL->getLAngleLoc(), TPL->getRAngleLoc());
return true;
}
bool VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D) {
- if (const auto *Info = D->getExplicitInstantiationInfo()) {
- H.addAngleBracketTokens(Info->TemplateArgsAsWritten->getLAngleLoc(),
- Info->TemplateArgsAsWritten->getRAngleLoc());
- } else if (const auto *Info = D->getExplicitSpecializationInfo()) {
- H.addAngleBracketTokens(Info->TemplateParams->getLAngleLoc(),
- Info->TemplateParams->getRAngleLoc());
- H.addAngleBracketTokens(Info->TemplateArgsAsWritten->getLAngleLoc(),
- Info->TemplateArgsAsWritten->getRAngleLoc());
- }
+ if (auto *Args = D->getTemplateArgsAsWritten())
+ H.addAngleBracketTokens(Args->getLAngleLoc(), Args->getRAngleLoc());
+ return true;
+ }
+
+ bool VisitVarTemplatePartialSpecializationDecl(
+ VarTemplatePartialSpecializationDecl *D) {
+ if (auto *TPL = D->getTemplateParameters())
+ H.addAngleBracketTokens(TPL->getLAngleLoc(), TPL->getRAngleLoc());
return true;
}
@@ -625,9 +625,6 @@ class CollectExtraHighlightings
}
bool VisitFunctionDecl(FunctionDecl *D) {
- if (const TemplateParameterList *TPL =
- D->getTemplateSpecializationParameters())
- H.addAngleBracketTokens(TPL->getLAngleLoc(), TPL->getRAngleLoc());
if (D->isOverloadedOperator()) {
const auto AddOpDeclToken = [&](SourceLocation Loc) {
auto &Token = H.addToken(Loc, HighlightingKind::Operator)
diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
index 5fcb1a24448b8..c9704492bf1cd 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -364,7 +364,7 @@ addInlineIfInHeader(const FunctionDecl *FD) {
if (!isHeaderFile(FileName, FD->getASTContext().getLangOpts()))
return std::nullopt;
- return tooling::Replacement(SM, FD->getFunctionLocStart(), 0, "inline ");
+ return tooling::Replacement(SM, FD->getInnerLocStart(), 0, "inline ");
}
/// Moves definition of a function/method to its declaration location.
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 77f801e6f7d67..cf4826f50e5a5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -701,7 +701,6 @@ Bug Fixes to C++ Support
- Fixed an alias template CTAD crash.
- Correctly diagnose uses of ``co_await`` / ``co_yield`` in the default argument of nested function declarations. (#GH98923)
- Fixed a crash when diagnosing an invalid static member function with an explicit object parameter (#GH177741)
-- Fixed clang incorrectly rejecting several cases of out-of-line definitions. (#GH101330)
- Clang incorrectly instantiated variable specializations outside of the immediate context. (#GH54439)
- Fixed a crash when pack expansions are used as arguments for non-pack parameters of built-in templates. (#GH180307)
- Fixed crash instantiating class member specializations.
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index e3f513732e588..620206612f98f 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -2122,6 +2122,34 @@ class FunctionDecl : public DeclaratorDecl,
/// the DeclaratorDecl base class.
DeclarationNameLoc DNLoc;
+ /// Specify that this function declaration is actually a function
+ /// template specialization.
+ ///
+ /// \param C the ASTContext.
+ ///
+ /// \param Template the function template that this function template
+ /// specialization specializes.
+ ///
+ /// \param TemplateArgs the template arguments that produced this
+ /// function template specialization from the template.
+ ///
+ /// \param InsertPos If non-NULL, the position in the function template
+ /// specialization set where the function template specialization data will
+ /// be inserted.
+ ///
+ /// \param TSK the kind of template specialization this is.
+ ///
+ /// \param TemplateArgsAsWritten location info of template arguments.
+ ///
+ /// \param PointOfInstantiation point at which the function template
+ /// specialization was first instantiated.
+ void setFunctionTemplateSpecialization(
+ ASTContext &C, FunctionTemplateDecl *Template,
+ TemplateArgumentList *TemplateArgs, void *InsertPos,
+ TemplateSpecializationKind TSK,
+ const TemplateArgumentListInfo *TemplateArgsAsWritten,
+ SourceLocation PointOfInstantiation);
+
/// Specify that this record is an instantiation of the
/// member function FD.
void setInstantiationOfMemberFunction(ASTContext &C, FunctionDecl *FD,
@@ -2217,8 +2245,6 @@ class FunctionDecl : public DeclaratorDecl,
return SourceLocation();
}
- SourceLocation getFunctionLocStart() const;
-
SourceRange getSourceRange() const override LLVM_READONLY;
// Function definitions.
@@ -3044,14 +3070,9 @@ class FunctionDecl : public DeclaratorDecl,
const ASTTemplateArgumentListInfo*
getTemplateSpecializationArgsAsWritten() const;
- /// Returns the template parameter list for an explicit specialization.
- const TemplateParameterList *getTemplateSpecializationParameters() const;
-
/// Specify that this function declaration is actually a function
/// template specialization.
///
- /// \param C the ASTContext.
- ///
/// \param Template the function template that this function template
/// specialization specializes.
///
@@ -3064,30 +3085,25 @@ class FunctionDecl : public DeclaratorDecl,
///
/// \param TSK the kind of template specialization this is.
///
- /// \param TemplateParams the template parameters if this is an explicit
- /// specialization.
- ///
/// \param TemplateArgsAsWritten location info of template arguments.
///
/// \param PointOfInstantiation point at which the function template
/// specialization was first instantiated.
- ///
- /// \param AddSpecialization whether to add this specialization to the
- /// template's specialization set.
- ///
void setFunctionTemplateSpecialization(
- ASTContext &C, FunctionTemplateDecl *Template,
- TemplateArgumentList *TemplateArgs, void *InsertPos,
- TemplateSpecializationKind TSK,
- const TemplateParameterList *TemplateParams,
- const TemplateArgumentListInfo *TemplateArgsAsWritten,
- SourceLocation PointOfInstantiation, bool AddSpecialization);
+ FunctionTemplateDecl *Template, TemplateArgumentList *TemplateArgs,
+ void *InsertPos,
+ TemplateSpecializationKind TSK = TSK_ImplicitInstantiation,
+ TemplateArgumentListInfo *TemplateArgsAsWritten = nullptr,
+ SourceLocation PointOfInstantiation = SourceLocation()) {
+ setFunctionTemplateSpecialization(getASTContext(), Template, TemplateArgs,
+ InsertPos, TSK, TemplateArgsAsWritten,
+ PointOfInstantiation);
+ }
/// Specifies that this function declaration is actually a
/// dependent function template specialization.
void setDependentTemplateSpecialization(
ASTContext &Context, const UnresolvedSetImpl &Templates,
- const TemplateParameterList *TemplateParams,
const TemplateArgumentListInfo *TemplateArgs);
DependentFunctionTemplateSpecializationInfo *
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index 672648c3fc03c..4f5a4e1b7b8a6 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -73,7 +73,7 @@ class TemplateParameterList final
: private llvm::TrailingObjects<TemplateParameterList, NamedDecl *,
Expr *> {
/// The template argument list of the template parameter list.
- mutable TemplateArgument *InjectedArgs = nullptr;
+ TemplateArgument *InjectedArgs = nullptr;
/// The location of the 'template' keyword.
SourceLocation TemplateLoc;
@@ -200,8 +200,7 @@ class TemplateParameterList final
bool hasAssociatedConstraints() const;
/// Get the template argument list of the template parameter list.
- ArrayRef<TemplateArgument>
- getInjectedTemplateArgs(const ASTContext &Context) const;
+ ArrayRef<TemplateArgument> getInjectedTemplateArgs(const ASTContext &Context);
SourceLocation getTemplateLoc() const { return TemplateLoc; }
SourceLocation getLAngleLoc() const { return LAngleLoc; }
@@ -476,18 +475,14 @@ class FunctionTemplateSpecializationInfo final
/// The function template from which this function template
/// specialization was generated.
///
- /// The three bits contain the TemplateSpecializationKind.
- llvm::PointerIntPair<FunctionTemplateDecl *, 3> Template;
+ /// The two bits contain the top 4 values of TemplateSpecializationKind.
+ llvm::PointerIntPair<FunctionTemplateDecl *, 2> Template;
public:
/// The template arguments used to produce the function template
/// specialization from the function template.
TemplateArgumentList *TemplateArguments;
- // The template parameters if this is an explicit specialization.
- /// FIXME: Normally null; tail-allocate this.
- const TemplateParameterList *TemplateParameters;
-
/// The template arguments as written in the sources, if provided.
/// FIXME: Normally null; tail-allocate this.
const ASTTemplateArgumentListInfo *TemplateArgumentsAsWritten;
@@ -500,14 +495,12 @@ class FunctionTemplateSpecializationInfo final
FunctionTemplateSpecializationInfo(
FunctionDecl *FD, FunctionTemplateDecl *Template,
TemplateSpecializationKind TSK, TemplateArgumentList *TemplateArgs,
- const TemplateParameterList *TemplateParameters,
const ASTTemplateArgumentListInfo *TemplateArgsAsWritten,
SourceLocation POI, MemberSpecializationInfo *MSInfo)
: Function(FD, MSInfo ? true : false), Template(Template, TSK - 1),
- TemplateArguments(TemplateArgs), TemplateParameters(TemplateParameters),
+ TemplateArguments(TemplateArgs),
TemplateArgumentsAsWritten(TemplateArgsAsWritten),
PointOfInstantiation(POI) {
- assert(TemplateParameters == nullptr || TSK == TSK_ExplicitSpecialization);
if (MSInfo)
getTrailingObjects()[0] = MSInfo;
}
@@ -520,7 +513,6 @@ class FunctionTemplateSpecializationInfo final
static FunctionTemplateSpecializationInfo *
Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template,
TemplateSpecializationKind TSK, TemplateArgumentList *TemplateArgs,
- const TemplateParameterList *TemplateParameters,
const TemplateArgumentListInfo *TemplateArgsAsWritten,
SourceLocation POI, MemberSpecializationInfo *MSInfo);
@@ -621,8 +613,8 @@ class FunctionTemplateSpecializationInfo final
/// member class or member enumeration.
class MemberSpecializationInfo {
// The member declaration from which this member was instantiated, and the
- // manner in which the instantiation occurred (in the lower three bits).
- llvm::PointerIntPair<NamedDecl *, 3> MemberAndTSK;
+ // manner in which the instantiation occurred (in the lower two bits).
+ llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
// The point at which this member was first instantiated.
SourceLocation PointOfInstantiation;
@@ -701,19 +693,14 @@ class DependentFunctionTemplateSpecializationInfo final
DependentFunctionTemplateSpecializationInfo(
const UnresolvedSetImpl &Candidates,
- const TemplateParameterList *TemplateParams,
const ASTTemplateArgumentListInfo *TemplateArgsWritten);
public:
- // The template parameters if this is an explicit specialization.
- const TemplateParameterList *TemplateParameters;
-
/// The template arguments as written in the sources, if provided.
const ASTTemplateArgumentListInfo *TemplateArgumentsAsWritten;
static DependentFunctionTemplateSpecializationInfo *
Create(ASTContext &Context, const UnresolvedSetImpl &Candidates,
- const TemplateParameterList *TemplateParams,
const TemplateArgumentListInfo *TemplateArgs);
/// Returns the candidates for the primary function template.
@@ -1018,6 +1005,11 @@ class FunctionTemplateDecl : public RedeclarableTemplateDecl {
return getTemplatedDecl()->isThisDeclarationADefinition();
}
+ bool isCompatibleWithDefinition() const {
+ return getTemplatedDecl()->isInstantiatedFromMemberTemplate() ||
+ isThisDeclarationADefinition();
+ }
+
// This bit closely tracks 'RedeclarableTemplateDecl::InstantiatedFromMember',
// except this is per declaration, while the redeclarable field is
// per chain. This indicates a template redeclaration which
@@ -1815,18 +1807,8 @@ struct ExplicitInstantiationInfo {
ExplicitInstantiationInfo() = default;
};
-struct ExplicitSpecializationInfo {
- /// The list of template parameters
- TemplateParameterList *TemplateParams = nullptr;
-
- /// The template arguments as written.
- const ASTTemplateArgumentListInfo *TemplateArgsAsWritten = nullptr;
-
- ExplicitSpecializationInfo() = default;
-};
-
using SpecializationOrInstantiationInfo =
- llvm::PointerUnion<ExplicitSpecializationInfo *,
+ llvm::PointerUnion<const ASTTemplateArgumentListInfo *,
ExplicitInstantiationInfo *>;
/// Represents a class template specialization, which refers to
@@ -2056,38 +2038,49 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
/// Retrieve the template argument list as written in the sources,
/// if any.
const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const {
- if (const auto *Info = getExplicitSpecializationInfo())
+ if (auto *Info =
+ dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
return Info->TemplateArgsAsWritten;
- if (const auto *Info = getExplicitInstantiationInfo())
- return Info->TemplateArgsAsWritten;
- return nullptr;
+ return cast<const ASTTemplateArgumentListInfo *>(ExplicitInfo);
+ }
+
+ /// Set the template argument list as written in the sources.
+ void
+ setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten) {
+ if (auto *Info =
+ dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
+ Info->TemplateArgsAsWritten = ArgsWritten;
+ else
+ ExplicitInfo = ArgsWritten;
}
- /// Gets the explicit instantiation info, if present.
- const ExplicitInstantiationInfo *getExplicitInstantiationInfo() const {
- return dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo);
+ /// Set the template argument list as written in the sources.
+ void setTemplateArgsAsWritten(const TemplateArgumentListInfo &ArgsInfo) {
+ setTemplateArgsAsWritten(
+ ASTTemplateArgumentListInfo::Create(getASTContext(), ArgsInfo));
}
- /// Sets the explicit instantiation info.
- void setExplicitInstantiationInfo(
- SourceLocation ExternKeywordLoc, SourceLocation TemplateKeywordLoc,
- const ASTTemplateArgumentListInfo *TemplateArgsAsWritten) {
- auto *Info = new (getASTContext()) ExplicitInstantiationInfo();
- Info->ExternKeywordLoc = ExternKeywordLoc;
- Info->TemplateKeywordLoc = TemplateKeywordLoc;
- Info->TemplateArgsAsWritten = TemplateArgsAsWritten;
- ExplicitInfo = Info;
+ /// Gets the location of the extern keyword, if present.
+ SourceLocation getExternKeywordLoc() const {
+ if (auto *Info =
+ dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
+ return Info->ExternKeywordLoc;
+ return SourceLocation();
}
- /// Gets the explicit specialization info, if present.
- const ExplicitSpecializationInfo *getExplicitSpecializationInfo() const {
- return dyn_cast_if_present<ExplicitSpecializationInfo *>(ExplicitInfo);
+ /// Sets the location of the extern keyword.
+ void setExternKeywordLoc(SourceLocation Loc);
+
+ /// Gets the location of the template keyword, if present.
+ SourceLocation getTemplateKeywordLoc() const {
+ if (auto *Info =
+ dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
+ return Info->TemplateKeywordLoc;
+ return SourceLocation();
}
- /// Sets the explicit specialization info.
- void setExplicitSpecializationInfo(
- TemplateParameterList *TemplateParams,
- const ASTTemplateArgumentListInfo *TemplateArgsAsWritten);
+ /// Sets the location of the template keyword.
+ void setTemplateKeywordLoc(SourceLocation Loc);
SourceRange getSourceRange() const override LLVM_READONLY;
@@ -2112,7 +2105,10 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
};
class ClassTemplatePartialSpecializationDecl
- : public ClassTemplateSpecializationDecl {
+ : public ClassTemplateSpecializationDecl {
+ /// The list of template parameters
+ TemplateParameterList *TemplateParams = nullptr;
+
/// The class template partial specialization from which this
/// class template partial specialization was instantiated.
///
@@ -2126,7 +2122,6 @@ class ClassTemplatePartialSpecializationDecl
ClassTemplatePartialSpecializationDecl(
ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, TemplateParameterList *Params,
- const ASTTemplateArgumentListInfo *ArgsAsWritten,
ClassTemplateDecl *SpecializedTemplate, ArrayRef<TemplateArgument> Args,
CanQualType CanonInjectedTST,
ClassTemplatePartialSpecializationDecl *PrevDecl);
@@ -2144,9 +2139,7 @@ class ClassTemplatePartialSpecializationDecl
static ClassTemplatePartialSpecializationDecl *
Create(ASTContext &Context, TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
- TemplateParameterList *Params,
- const ASTTemplateArgumentListInfo *TemplateArgsAsWritten,
- ClassTemplateDecl *SpecializedTemplate,
+ TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate,
ArrayRef<TemplateArgument> Args, CanQualType CanonInjectedTST,
ClassTemplatePartialSpecializationDecl *PrevDecl);
@@ -2161,10 +2154,7 @@ class ClassTemplatePartial...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/201864
More information about the cfe-commits
mailing list