@@ -5384,46 +5384,40 @@ bool Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
53845384 return isAtLeastAsSpecializedAs (*this , PType, AType, AArg, Info);
53855385}
53865386
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;
53905392
5391- OccurringTemplateParameterFinder (llvm::SmallBitVector &OccurringIndices)
5392- : OccurringIndices(OccurringIndices) { }
5393+ MarkUsedTemplateParameterVisitor (llvm::SmallBitVector &Used,
5394+ unsigned Depth)
5395+ : Used(Used), Depth(Depth) { }
53935396
53945397 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 ;
53985400 return true ;
53995401 }
54005402
54015403 bool TraverseTemplateName (TemplateName Template) {
54025404 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>::
54095409 TraverseTemplateName (Template);
54105410 return true ;
54115411 }
54125412
54135413 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 ;
54195417 return true ;
54205418 }
5421-
5422- protected:
5423- void noteParameter (unsigned Index) {
5424- OccurringIndices.set (Index);
5425- }
54265419};
5420+ }
54275421
54285422// / Mark the template parameters that are used by the given
54295423// / expression.
@@ -5434,7 +5428,8 @@ MarkUsedTemplateParameters(ASTContext &Ctx,
54345428 unsigned Depth,
54355429 llvm::SmallBitVector &Used) {
54365430 if (!OnlyDeduced) {
5437- OccurringTemplateParameterFinder (Used).TraverseStmt (const_cast <Expr *>(E));
5431+ MarkUsedTemplateParameterVisitor (Used, Depth)
5432+ .TraverseStmt (const_cast <Expr *>(E));
54385433 return ;
54395434 }
54405435
0 commit comments