File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 1111#include " clang/AST/ASTFwd.h"
1212#include " clang/AST/Decl.h"
1313#include " clang/AST/DeclCXX.h"
14+ #include " clang/AST/DeclFriend.h"
1415#include " clang/AST/DeclTemplate.h"
1516#include " clang/AST/Expr.h"
1617#include " clang/AST/ExprCXX.h"
@@ -243,6 +244,14 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
243244 return true ;
244245 }
245246
247+ bool VisitFriendDecl (FriendDecl *D) {
248+ // We already visit the TypeLoc properly, but need to special case the decl
249+ // case.
250+ if (auto *FD = D->getFriendDecl ())
251+ report (D->getLocation (), FD);
252+ return true ;
253+ }
254+
246255 bool VisitConceptReference (const ConceptReference *CR) {
247256 report (CR->getConceptNameLoc (), CR->getFoundDecl ());
248257 return true ;
Original file line number Diff line number Diff line change @@ -550,5 +550,10 @@ TEST(WalkAST, Concepts) {
550550 // FIXME: Foo should be explicitly referenced.
551551 testWalk (" template<typename T> concept Foo = true;" , " void func() { ^Foo auto x = 1; }" );
552552}
553+
554+ TEST (WalkAST, FriendDecl) {
555+ testWalk (" void $explicit^foo();" , " struct Bar { friend void ^foo(); };" );
556+ testWalk (" struct $explicit^Foo {};" , " struct Bar { friend struct ^Foo; };" );
557+ }
553558} // namespace
554559} // namespace clang::include_cleaner
You can’t perform that action at this time.
0 commit comments