Skip to content

Commit f7d9337

Browse files
authored
[Sema][NFC] Cleanups after 843cc47 (llvm#87996)
I forgot to tidy up these lines that should've been done in the previous commit, specifically: 1. Merge two `CodeSynthesisContext`s into one in `CheckTemplateIdType`. 2. Remove some gratuitous `Sema::` specifiers. 3. Rename the parameter `Template` to `Entity` to avoid confusion.
1 parent e35fb3f commit f7d9337

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10077,7 +10077,7 @@ class Sema final : public SemaBase {
1007710077

1007810078
/// Note that we are instantiating a type alias template declaration.
1007910079
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10080-
TypeAliasTemplateDecl *Template,
10080+
TypeAliasTemplateDecl *Entity,
1008110081
ArrayRef<TemplateArgument> TemplateArgs,
1008210082
SourceRange InstantiationRange = SourceRange());
1008310083

clang/lib/Frontend/FrontendActions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ class DefaultTemplateInstCallback : public TemplateInstantiationCallback {
453453
return "BuildingBuiltinDumpStructCall";
454454
case CodeSynthesisContext::BuildingDeductionGuides:
455455
return "BuildingDeductionGuides";
456-
case Sema::CodeSynthesisContext::TypeAliasTemplateInstantiation:
456+
case CodeSynthesisContext::TypeAliasTemplateInstantiation:
457457
return "TypeAliasTemplateInstantiation";
458458
}
459459
return "";

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4494,15 +4494,13 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
44944494
AliasTemplate->getTemplateParameters()->getDepth());
44954495

44964496
LocalInstantiationScope Scope(*this);
4497-
InstantiatingTemplate Inst(*this, TemplateLoc, Template);
4497+
InstantiatingTemplate Inst(
4498+
*this, /*PointOfInstantiation=*/TemplateLoc,
4499+
/*Entity=*/AliasTemplate,
4500+
/*TemplateArgs=*/TemplateArgLists.getInnermost());
44984501
if (Inst.isInvalid())
44994502
return QualType();
45004503

4501-
InstantiatingTemplate InstTemplate(
4502-
*this, /*PointOfInstantiation=*/AliasTemplate->getBeginLoc(),
4503-
/*Template=*/AliasTemplate,
4504-
/*TemplateArgs=*/TemplateArgLists.getInnermost());
4505-
45064504
std::optional<ContextRAII> SavedContext;
45074505
if (!AliasTemplate->getDeclContext()->isFileContext())
45084506
SavedContext.emplace(*this, AliasTemplate->getDeclContext());

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,11 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
737737

738738
Sema::InstantiatingTemplate::InstantiatingTemplate(
739739
Sema &SemaRef, SourceLocation PointOfInstantiation,
740-
TypeAliasTemplateDecl *Template, ArrayRef<TemplateArgument> TemplateArgs,
740+
TypeAliasTemplateDecl *Entity, ArrayRef<TemplateArgument> TemplateArgs,
741741
SourceRange InstantiationRange)
742742
: InstantiatingTemplate(
743-
SemaRef, Sema::CodeSynthesisContext::TypeAliasTemplateInstantiation,
744-
PointOfInstantiation, InstantiationRange, /*Entity=*/Template,
743+
SemaRef, CodeSynthesisContext::TypeAliasTemplateInstantiation,
744+
PointOfInstantiation, InstantiationRange, /*Entity=*/Entity,
745745
/*Template=*/nullptr, TemplateArgs) {}
746746

747747
Sema::InstantiatingTemplate::InstantiatingTemplate(
@@ -983,11 +983,6 @@ void Sema::PrintInstantiationStack() {
983983
Diags.Report(Active->PointOfInstantiation,
984984
diag::note_template_class_instantiation_here)
985985
<< CTD << Active->InstantiationRange;
986-
} else {
987-
Diags.Report(Active->PointOfInstantiation,
988-
diag::note_template_type_alias_instantiation_here)
989-
<< cast<TypeAliasTemplateDecl>(D)
990-
<< Active->InstantiationRange;
991986
}
992987
break;
993988
}
@@ -1262,6 +1257,10 @@ void Sema::PrintInstantiationStack() {
12621257
diag::note_building_deduction_guide_here);
12631258
break;
12641259
case CodeSynthesisContext::TypeAliasTemplateInstantiation:
1260+
Diags.Report(Active->PointOfInstantiation,
1261+
diag::note_template_type_alias_instantiation_here)
1262+
<< cast<TypeAliasTemplateDecl>(Active->Entity)
1263+
<< Active->InstantiationRange;
12651264
break;
12661265
}
12671266
}
@@ -1278,12 +1277,13 @@ std::optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const {
12781277
++Active)
12791278
{
12801279
switch (Active->Kind) {
1281-
case CodeSynthesisContext::TemplateInstantiation:
1280+
case CodeSynthesisContext::TypeAliasTemplateInstantiation:
12821281
// An instantiation of an alias template may or may not be a SFINAE
12831282
// context, depending on what else is on the stack.
12841283
if (isa<TypeAliasTemplateDecl>(Active->Entity))
12851284
break;
12861285
[[fallthrough]];
1286+
case CodeSynthesisContext::TemplateInstantiation:
12871287
case CodeSynthesisContext::DefaultFunctionArgumentInstantiation:
12881288
case CodeSynthesisContext::ExceptionSpecInstantiation:
12891289
case CodeSynthesisContext::ConstraintsCheck:
@@ -1340,7 +1340,6 @@ std::optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const {
13401340
break;
13411341

13421342
case CodeSynthesisContext::Memoization:
1343-
case CodeSynthesisContext::TypeAliasTemplateInstantiation:
13441343
break;
13451344
}
13461345

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,8 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
11191119
: (TemplateArgs.begin() + TemplateArgs.getNumLevels() - 1 -
11201120
D->getTemplateDepth())
11211121
->Args);
1122+
if (InstTemplate.isInvalid())
1123+
return nullptr;
11221124

11231125
TypeAliasTemplateDecl *PrevAliasTemplate = nullptr;
11241126
if (getPreviousDeclForInstantiation<TypedefNameDecl>(Pattern)) {

0 commit comments

Comments
 (0)