Skip to content

[clang] NFCI: remove obsolete workaround for template default arguments #94311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions clang/include/clang/AST/TemplateName.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 0 additions & 17 deletions clang/lib/AST/TemplateName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
10 changes: 4 additions & 6 deletions clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Loading