Differential Revision: https://reviews.llvm.org/D141362
}
void VisitFriendDecl(const FriendDecl *D) {
- if (!D->getFriendType())
+ if (D->getFriendType()) {
+ // Traverse any CXXRecordDecl owned by this type, since
+ // it will not be in the parent context:
+ if (auto *ET = D->getFriendType()->getType()->getAs<ElaboratedType>())
+ if (auto *TD = ET->getOwnedTagDecl())
+ Visit(TD);
+ } else {
Visit(D->getFriendDecl());
+ }
}
void VisitObjCMethodDecl(const ObjCMethodDecl *D) {
// CHECK-NEXT: FriendDecl
// CHECK-NEXT: FunctionDecl{{.*}} foo
// CHECK-NEXT: FriendDecl{{.*}} 'class A':'A'
+// CHECK-NEXT: CXXRecordDecl{{.*}} class A
// CHECK-NEXT: FriendDecl{{.*}} 'T'
namespace TestFileScopeAsmDecl {