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 11
11
#include " clang/AST/ASTFwd.h"
12
12
#include " clang/AST/Decl.h"
13
13
#include " clang/AST/DeclCXX.h"
14
+ #include " clang/AST/DeclFriend.h"
14
15
#include " clang/AST/DeclTemplate.h"
15
16
#include " clang/AST/Expr.h"
16
17
#include " clang/AST/ExprCXX.h"
@@ -243,6 +244,14 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
243
244
return true ;
244
245
}
245
246
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
+
246
255
bool VisitConceptReference (const ConceptReference *CR) {
247
256
report (CR->getConceptNameLoc (), CR->getFoundDecl ());
248
257
return true ;
Original file line number Diff line number Diff line change @@ -550,5 +550,10 @@ TEST(WalkAST, Concepts) {
550
550
// FIXME: Foo should be explicitly referenced.
551
551
testWalk (" template<typename T> concept Foo = true;" , " void func() { ^Foo auto x = 1; }" );
552
552
}
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
+ }
553
558
} // namespace
554
559
} // namespace clang::include_cleaner
You can’t perform that action at this time.
0 commit comments