Skip to content

Commit

Permalink
[AST] include decls owned by FriendDecl in -ast-dump
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D141362
  • Loading branch information
sam-mccall committed Jan 10, 2023
1 parent fadacaa commit 98ae361
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion clang/include/clang/AST/ASTNodeTraverser.h
Expand Up @@ -644,8 +644,15 @@ class ASTNodeTraverser
}

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) {
Expand Down
1 change: 1 addition & 0 deletions clang/test/AST/ast-dump-decl.cpp
Expand Up @@ -784,6 +784,7 @@ template<typename T> class TestFriendDecl {
// CHECK-NEXT: FriendDecl
// CHECK-NEXT: FunctionDecl{{.*}} foo
// CHECK-NEXT: FriendDecl{{.*}} 'class A':'A'
// CHECK-NEXT: CXXRecordDecl{{.*}} class A
// CHECK-NEXT: FriendDecl{{.*}} 'T'

namespace TestFileScopeAsmDecl {
Expand Down

0 comments on commit 98ae361

Please sign in to comment.