@@ -5384,46 +5384,40 @@ bool Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
5384
5384
return isAtLeastAsSpecializedAs (*this , PType, AType, AArg, Info);
5385
5385
}
5386
5386
5387
- struct OccurringTemplateParameterFinder :
5388
- RecursiveASTVisitor<OccurringTemplateParameterFinder> {
5389
- llvm::SmallBitVector &OccurringIndices;
5387
+ namespace {
5388
+ struct MarkUsedTemplateParameterVisitor :
5389
+ RecursiveASTVisitor<MarkUsedTemplateParameterVisitor> {
5390
+ llvm::SmallBitVector &Used;
5391
+ unsigned Depth;
5390
5392
5391
- OccurringTemplateParameterFinder (llvm::SmallBitVector &OccurringIndices)
5392
- : OccurringIndices(OccurringIndices) { }
5393
+ MarkUsedTemplateParameterVisitor (llvm::SmallBitVector &Used,
5394
+ unsigned Depth)
5395
+ : Used(Used), Depth(Depth) { }
5393
5396
5394
5397
bool VisitTemplateTypeParmType (TemplateTypeParmType *T) {
5395
- assert (T->getDepth () == 0 && " This assumes that we allow concepts at "
5396
- " namespace scope only" );
5397
- noteParameter (T->getIndex ());
5398
+ if (T->getDepth () == Depth)
5399
+ Used[T->getIndex ()] = true ;
5398
5400
return true ;
5399
5401
}
5400
5402
5401
5403
bool TraverseTemplateName (TemplateName Template) {
5402
5404
if (auto *TTP =
5403
- dyn_cast<TemplateTemplateParmDecl>(Template.getAsTemplateDecl ())) {
5404
- assert (TTP->getDepth () == 0 && " This assumes that we allow concepts at "
5405
- " namespace scope only" );
5406
- noteParameter (TTP->getIndex ());
5407
- }
5408
- RecursiveASTVisitor<OccurringTemplateParameterFinder>::
5405
+ dyn_cast<TemplateTemplateParmDecl>(Template.getAsTemplateDecl ()))
5406
+ if (TTP->getDepth () == Depth)
5407
+ Used[TTP->getIndex ()] = true ;
5408
+ RecursiveASTVisitor<MarkUsedTemplateParameterVisitor>::
5409
5409
TraverseTemplateName (Template);
5410
5410
return true ;
5411
5411
}
5412
5412
5413
5413
bool VisitDeclRefExpr (DeclRefExpr *E) {
5414
- if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(E->getDecl ())) {
5415
- assert (NTTP->getDepth () == 0 && " This assumes that we allow concepts at "
5416
- " namespace scope only" );
5417
- noteParameter (NTTP->getIndex ());
5418
- }
5414
+ if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(E->getDecl ()))
5415
+ if (NTTP->getDepth () == Depth)
5416
+ Used[NTTP->getIndex ()] = true ;
5419
5417
return true ;
5420
5418
}
5421
-
5422
- protected:
5423
- void noteParameter (unsigned Index) {
5424
- OccurringIndices.set (Index);
5425
- }
5426
5419
};
5420
+ }
5427
5421
5428
5422
// / Mark the template parameters that are used by the given
5429
5423
// / expression.
@@ -5434,7 +5428,8 @@ MarkUsedTemplateParameters(ASTContext &Ctx,
5434
5428
unsigned Depth,
5435
5429
llvm::SmallBitVector &Used) {
5436
5430
if (!OnlyDeduced) {
5437
- OccurringTemplateParameterFinder (Used).TraverseStmt (const_cast <Expr *>(E));
5431
+ MarkUsedTemplateParameterVisitor (Used, Depth)
5432
+ .TraverseStmt (const_cast <Expr *>(E));
5438
5433
return ;
5439
5434
}
5440
5435
0 commit comments