forked from OSchip/llvm-project
[clangd] IncludeCleaner: Mark possible expr resolutions as used
Fixes: https://github.com/clangd/clangd/issues/934 Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D114287
This commit is contained in:
parent
760d4d03d5
commit
b5f20372a8
|
@ -13,6 +13,7 @@
|
||||||
#include "SourceCode.h"
|
#include "SourceCode.h"
|
||||||
#include "support/Logger.h"
|
#include "support/Logger.h"
|
||||||
#include "support/Trace.h"
|
#include "support/Trace.h"
|
||||||
|
#include "clang/AST/ExprCXX.h"
|
||||||
#include "clang/AST/RecursiveASTVisitor.h"
|
#include "clang/AST/RecursiveASTVisitor.h"
|
||||||
#include "clang/Basic/SourceLocation.h"
|
#include "clang/Basic/SourceLocation.h"
|
||||||
#include "clang/Lex/HeaderSearch.h"
|
#include "clang/Lex/HeaderSearch.h"
|
||||||
|
@ -104,6 +105,13 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the overload is not resolved yet, mark all candidates as used.
|
||||||
|
bool VisitOverloadExpr(OverloadExpr *E) {
|
||||||
|
for (const auto *ResolutionDecl : E->decls())
|
||||||
|
add(ResolutionDecl);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using Base = RecursiveASTVisitor<ReferencedLocationCrawler>;
|
using Base = RecursiveASTVisitor<ReferencedLocationCrawler>;
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,10 @@ TEST(IncludeCleaner, ReferencedLocations) {
|
||||||
"inline void ^foo() {}",
|
"inline void ^foo() {}",
|
||||||
"void bar() { foo(); }",
|
"void bar() { foo(); }",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"int ^foo(char); int ^foo(float);",
|
||||||
|
"template<class T> int x = foo(T{});",
|
||||||
|
},
|
||||||
// Static function
|
// Static function
|
||||||
{
|
{
|
||||||
"struct ^X { static bool ^foo(); }; bool X::^foo() {}",
|
"struct ^X { static bool ^foo(); }; bool X::^foo() {}",
|
||||||
|
|
Loading…
Reference in New Issue