Loading clang-tools-extra/include-cleaner/lib/WalkAST.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ #include "clang/AST/ASTFwd.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" Loading Loading @@ -243,6 +244,14 @@ public: return true; } bool VisitFriendDecl(FriendDecl *D) { // We already visit the TypeLoc properly, but need to special case the decl // case. if (auto *FD = D->getFriendDecl()) report(D->getLocation(), FD); return true; } bool VisitConceptReference(const ConceptReference *CR) { report(CR->getConceptNameLoc(), CR->getFoundDecl()); return true; Loading clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -550,5 +550,10 @@ TEST(WalkAST, Concepts) { // FIXME: Foo should be explicitly referenced. testWalk("template<typename T> concept Foo = true;", "void func() { ^Foo auto x = 1; }"); } TEST(WalkAST, FriendDecl) { testWalk("void $explicit^foo();", "struct Bar { friend void ^foo(); };"); testWalk("struct $explicit^Foo {};", "struct Bar { friend struct ^Foo; };"); } } // namespace } // namespace clang::include_cleaner Loading
clang-tools-extra/include-cleaner/lib/WalkAST.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ #include "clang/AST/ASTFwd.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" Loading Loading @@ -243,6 +244,14 @@ public: return true; } bool VisitFriendDecl(FriendDecl *D) { // We already visit the TypeLoc properly, but need to special case the decl // case. if (auto *FD = D->getFriendDecl()) report(D->getLocation(), FD); return true; } bool VisitConceptReference(const ConceptReference *CR) { report(CR->getConceptNameLoc(), CR->getFoundDecl()); return true; Loading
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -550,5 +550,10 @@ TEST(WalkAST, Concepts) { // FIXME: Foo should be explicitly referenced. testWalk("template<typename T> concept Foo = true;", "void func() { ^Foo auto x = 1; }"); } TEST(WalkAST, FriendDecl) { testWalk("void $explicit^foo();", "struct Bar { friend void ^foo(); };"); testWalk("struct $explicit^Foo {};", "struct Bar { friend struct ^Foo; };"); } } // namespace } // namespace clang::include_cleaner