kbobyrev created this revision. kbobyrev added a reviewer: sammccall. Herald added subscribers: usaxena95, kadircet, arphaman. kbobyrev requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang-tools-extra.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114287 Files: clang-tools-extra/clangd/IncludeCleaner.cpp clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp +++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp @@ -97,6 +97,10 @@ "inline void ^foo() {}", "void bar() { foo(); }", }, + { + "template <typename T> void ^foo(T &&F) {}", + "template <typename U> void bar() { foo([](){}); }", + }, // Static function { "struct ^X { static bool ^foo(); }; bool X::^foo() {}", Index: clang-tools-extra/clangd/IncludeCleaner.cpp =================================================================== --- clang-tools-extra/clangd/IncludeCleaner.cpp +++ clang-tools-extra/clangd/IncludeCleaner.cpp @@ -13,6 +13,7 @@ #include "SourceCode.h" #include "support/Logger.h" #include "support/Trace.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Basic/SourceLocation.h" #include "clang/Lex/HeaderSearch.h" @@ -104,6 +105,14 @@ return true; } + // Some expressions might be not resolved yet due to ADL: conservatively mark + // all resolution candidates as used. + bool VisitOverloadExpr(OverloadExpr *E) { + for (const auto *ResolutionDecl : E->decls()) + add(ResolutionDecl); + return true; + } + private: using Base = RecursiveASTVisitor<ReferencedLocationCrawler>;
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp +++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp @@ -97,6 +97,10 @@ "inline void ^foo() {}", "void bar() { foo(); }", }, + { + "template <typename T> void ^foo(T &&F) {}", + "template <typename U> void bar() { foo([](){}); }", + }, // Static function { "struct ^X { static bool ^foo(); }; bool X::^foo() {}", Index: clang-tools-extra/clangd/IncludeCleaner.cpp =================================================================== --- clang-tools-extra/clangd/IncludeCleaner.cpp +++ clang-tools-extra/clangd/IncludeCleaner.cpp @@ -13,6 +13,7 @@ #include "SourceCode.h" #include "support/Logger.h" #include "support/Trace.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Basic/SourceLocation.h" #include "clang/Lex/HeaderSearch.h" @@ -104,6 +105,14 @@ return true; } + // Some expressions might be not resolved yet due to ADL: conservatively mark + // all resolution candidates as used. + bool VisitOverloadExpr(OverloadExpr *E) { + for (const auto *ResolutionDecl : E->decls()) + add(ResolutionDecl); + return true; + } + private: using Base = RecursiveASTVisitor<ReferencedLocationCrawler>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits