[clang] 924611b - [clang] NFCI: remove obsolete workaround for template default arguments (#94311)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 4 04:52:21 PDT 2024
Author: Matheus Izvekov
Date: 2024-06-04T08:52:17-03:00
New Revision: 924611b0301f751e8c3fef9759b9d2683b0345fc
URL: https://github.com/llvm/llvm-project/commit/924611b0301f751e8c3fef9759b9d2683b0345fc
DIFF: https://github.com/llvm/llvm-project/commit/924611b0301f751e8c3fef9759b9d2683b0345fc.diff
LOG: [clang] NFCI: remove obsolete workaround for template default arguments (#94311)
Added:
Modified:
clang/include/clang/AST/TemplateName.h
clang/lib/AST/TemplateName.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/TemplateName.h b/clang/include/clang/AST/TemplateName.h
index 7aedc086ab7d0..489fccb2ef74d 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -314,11 +314,6 @@ class TemplateName {
TemplateName getUnderlying() const;
- /// Get the template name to substitute when this template name is used as a
- /// template template argument. This refers to the most recent declaration of
- /// the template, including any default template arguments.
- TemplateName getNameToSubstitute() const;
-
TemplateNameDependence getDependence() const;
/// Determines whether this is a dependent template name.
diff --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index 3dbdad92813f6..4fc25cb34803e 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -214,23 +214,6 @@ UsingShadowDecl *TemplateName::getAsUsingShadowDecl() const {
return nullptr;
}
-TemplateName TemplateName::getNameToSubstitute() const {
- TemplateDecl *Decl = getAsTemplateDecl();
-
- // Substituting a dependent template name: preserve it as written.
- if (!Decl)
- return *this;
-
- // If we have a template declaration, use the most recent non-friend
- // declaration of that template.
- Decl = cast<TemplateDecl>(Decl->getMostRecentDecl());
- while (Decl->getFriendObjectKind()) {
- Decl = cast<TemplateDecl>(Decl->getPreviousDecl());
- assert(Decl && "all declarations of template are friends");
- }
- return TemplateName(Decl);
-}
-
TemplateNameDependence TemplateName::getDependence() const {
auto D = TemplateNameDependence::None;
switch (getKind()) {
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index abb8a260faab9..863cc53c55afa 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1856,7 +1856,7 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) {
Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
}
- TemplateName Template = Arg.getAsTemplate().getNameToSubstitute();
+ TemplateName Template = Arg.getAsTemplate();
assert(!Template.isNull() && Template.getAsTemplateDecl() &&
"Wrong kind of template template argument");
return Template.getAsTemplateDecl();
@@ -2029,10 +2029,8 @@ TemplateName TemplateInstantiator::TransformTemplateName(
Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
}
- TemplateName Template = Arg.getAsTemplate().getNameToSubstitute();
+ TemplateName Template = Arg.getAsTemplate();
assert(!Template.isNull() && "Null template template argument");
- assert(!Template.getAsQualifiedTemplateName() &&
- "template decl to substitute is qualified?");
if (Final)
return Template;
@@ -2052,8 +2050,8 @@ TemplateName TemplateInstantiator::TransformTemplateName(
if (SubstPack->getFinal())
return Template;
return getSema().Context.getSubstTemplateTemplateParm(
- Template.getNameToSubstitute(), SubstPack->getAssociatedDecl(),
- SubstPack->getIndex(), getPackIndex(Pack));
+ Template, SubstPack->getAssociatedDecl(), SubstPack->getIndex(),
+ getPackIndex(Pack));
}
return inherited::TransformTemplateName(SS, Name, NameLoc, ObjectType,
More information about the cfe-commits
mailing list