Call VisitRedeclarable before VisitDeclContext to avoid any recursion that might occur.

This should have been included in the prior commit, but as it affects [ordering in] other DeclUnloader functions;
the ability to back it out separately is better.

Also exposes a bug/change necessary in clang when building in Debug mode to avoid an infinite loop.
This commit is contained in:
Frederich Munch 2016-07-06 16:08:00 -04:00 committed by sftnight
parent 7161f8660b
commit 8957d2b84e
3 changed files with 21 additions and 6 deletions

View File

@ -557,8 +557,8 @@ bool DeclUnloader::VisitRedeclarable(clang::Redeclarable<T>* R, DeclContext* DC)
// We start with the decl context first, because parameters are part of the
// DeclContext and when trying to remove them we need the full redecl chain
// still in place.
bool Successful = VisitDeclContext(FD);
Successful &= VisitRedeclarable(FD, FD->getDeclContext());
bool Successful = VisitRedeclarable(FD, FD->getDeclContext());
Successful &= VisitDeclContext(FD);
Successful &= VisitDeclaratorDecl(FD);
// Template instantiation of templated function first creates a canonical
@ -711,8 +711,8 @@ bool DeclUnloader::VisitRedeclarable(clang::Redeclarable<T>* R, DeclContext* DC)
bool DeclUnloader::VisitNamespaceDecl(NamespaceDecl* NSD) {
// NamespaceDecl: NamedDecl, DeclContext, Redeclarable
bool Successful = VisitDeclContext(NSD);
Successful &= VisitRedeclarable(NSD, NSD->getDeclContext());
bool Successful = VisitRedeclarable(NSD, NSD->getDeclContext());
Successful &= VisitDeclContext(NSD);
Successful &= VisitNamedDecl(NSD);
return Successful;
@ -809,8 +809,8 @@ bool DeclUnloader::VisitRedeclarable(clang::Redeclarable<T>* R, DeclContext* DC)
bool DeclUnloader::VisitTagDecl(TagDecl* TD) {
// TagDecl: TypeDecl, DeclContext, Redeclarable
bool Successful = VisitDeclContext(TD);
Successful &= VisitRedeclarable(TD, TD->getDeclContext());
bool Successful = VisitRedeclarable(TD, TD->getDeclContext());
Successful &= VisitDeclContext(TD);
Successful &= VisitTypeDecl(TD);
return Successful;
}

View File

@ -22,6 +22,12 @@ void bestFriend();
.compareState "NF"
//CHECK-NOT: Differences
#include "FriendRecursive.h"
.undo
.compareState "NF"
//CHECK-NOT: Differences
// STL has many of these in memory & stdexcept
//#include <memory>
//.undo

View File

@ -0,0 +1,9 @@
class TestA {
friend class TestB;
void empty() {}
};
class TestB {
friend class TestA;
void empty() {}
};