================ @@ -487,7 +487,26 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) { } this->Indent(); - Visit(*D); + + // Group friend declarations if need be. + if (isa<FriendDecl>(*D)) { + auto *FD = cast<FriendDecl>(*D); + VisitFriendDecl(FD); + SourceLocation FriendLoc = FD->getFriendLoc(); + + // Use a separate iterator; 'D' is always one declaration 'behind' in + // this loop; the last friend printed here (or the first printed just + // now before this loop if there are no subsequent friends) will be + // skipped by the '++D' of the outer loop. + for (DeclContext::decl_iterator It; It = std::next(D), It != DEnd; ++D) { + auto *NextFriend = dyn_cast<FriendDecl>(*It); + if (!NextFriend || NextFriend->getFriendLoc() != FriendLoc) + break; + VisitFriendDecl(NextFriend, false); + } + } else { + Visit(*D); + } ---------------- cor3ntin wrote:
I think we should move all of that to `VisitFriendDecl` https://github.com/llvm/llvm-project/pull/101448 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits