Skip to content

Commit 7b01861

Browse files
committed
[clang] NFCI: remove obsolete workaround for template default arguments
This removes a workaround for template template arguments pointing to older template declarations, which don't have the most recent default argument definition. The removed workaround was introduced in 1abacfc, but #75569 introduced a better fix which is more comprehensive and doesn't require rebuilding TemplateNames.
1 parent 98d5d34 commit 7b01861

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

clang/include/clang/AST/TemplateName.h

-5
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,6 @@ class TemplateName {
314314

315315
TemplateName getUnderlying() const;
316316

317-
/// Get the template name to substitute when this template name is used as a
318-
/// template template argument. This refers to the most recent declaration of
319-
/// the template, including any default template arguments.
320-
TemplateName getNameToSubstitute() const;
321-
322317
TemplateNameDependence getDependence() const;
323318

324319
/// Determines whether this is a dependent template name.

clang/lib/AST/TemplateName.cpp

-17
Original file line numberDiff line numberDiff line change
@@ -214,23 +214,6 @@ UsingShadowDecl *TemplateName::getAsUsingShadowDecl() const {
214214
return nullptr;
215215
}
216216

217-
TemplateName TemplateName::getNameToSubstitute() const {
218-
TemplateDecl *Decl = getAsTemplateDecl();
219-
220-
// Substituting a dependent template name: preserve it as written.
221-
if (!Decl)
222-
return *this;
223-
224-
// If we have a template declaration, use the most recent non-friend
225-
// declaration of that template.
226-
Decl = cast<TemplateDecl>(Decl->getMostRecentDecl());
227-
while (Decl->getFriendObjectKind()) {
228-
Decl = cast<TemplateDecl>(Decl->getPreviousDecl());
229-
assert(Decl && "all declarations of template are friends");
230-
}
231-
return TemplateName(Decl);
232-
}
233-
234217
TemplateNameDependence TemplateName::getDependence() const {
235218
auto D = TemplateNameDependence::None;
236219
switch (getKind()) {

clang/lib/Sema/SemaTemplateInstantiate.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) {
18561856
Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
18571857
}
18581858

1859-
TemplateName Template = Arg.getAsTemplate().getNameToSubstitute();
1859+
TemplateName Template = Arg.getAsTemplate();
18601860
assert(!Template.isNull() && Template.getAsTemplateDecl() &&
18611861
"Wrong kind of template template argument");
18621862
return Template.getAsTemplateDecl();
@@ -2029,10 +2029,8 @@ TemplateName TemplateInstantiator::TransformTemplateName(
20292029
Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
20302030
}
20312031

2032-
TemplateName Template = Arg.getAsTemplate().getNameToSubstitute();
2032+
TemplateName Template = Arg.getAsTemplate();
20332033
assert(!Template.isNull() && "Null template template argument");
2034-
assert(!Template.getAsQualifiedTemplateName() &&
2035-
"template decl to substitute is qualified?");
20362034

20372035
if (Final)
20382036
return Template;
@@ -2052,8 +2050,8 @@ TemplateName TemplateInstantiator::TransformTemplateName(
20522050
if (SubstPack->getFinal())
20532051
return Template;
20542052
return getSema().Context.getSubstTemplateTemplateParm(
2055-
Template.getNameToSubstitute(), SubstPack->getAssociatedDecl(),
2056-
SubstPack->getIndex(), getPackIndex(Pack));
2053+
Template, SubstPack->getAssociatedDecl(), SubstPack->getIndex(),
2054+
getPackIndex(Pack));
20572055
}
20582056

20592057
return inherited::TransformTemplateName(SS, Name, NameLoc, ObjectType,

0 commit comments

Comments
 (0)