Skip to content

Commit a160a0b

Browse files
committedOct 1, 2019
[clangd] Handle OverloadExpr in targetDecl
Reviewers: sammccall Reviewed By: sammccall Subscribers: nridge, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68119 llvm-svn: 373305
1 parent d1337ec commit a160a0b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
 

‎clang-tools-extra/clangd/FindTarget.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ struct TargetFinder {
189189
D = USD;
190190
Outer.add(D, Flags);
191191
}
192+
void VisitOverloadExpr(const OverloadExpr *OE) {
193+
for (auto *D : OE->decls())
194+
Outer.add(D, Flags);
195+
}
192196
void VisitCXXConstructExpr(const CXXConstructExpr *CCE) {
193197
Outer.add(CCE->getConstructor(), Flags);
194198
}

‎clang-tools-extra/clangd/unittests/FindTargetTests.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,32 @@ TEST_F(TargetDeclTest, Lambda) {
393393
EXPECT_DECLS("DeclRefExpr", "auto int x = 1");
394394
}
395395

396+
TEST_F(TargetDeclTest, OverloadExpr) {
397+
Code = R"cpp(
398+
void func(int*);
399+
void func(char*);
400+
401+
template <class T>
402+
void foo(T t) {
403+
[[func]](t);
404+
};
405+
)cpp";
406+
EXPECT_DECLS("UnresolvedLookupExpr", "void func(int *)", "void func(char *)");
407+
408+
Code = R"cpp(
409+
struct X {
410+
void func(int*);
411+
void func(char*);
412+
};
413+
414+
template <class T>
415+
void foo(X x, T t) {
416+
x.[[func]](t);
417+
};
418+
)cpp";
419+
EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
420+
}
421+
396422
TEST_F(TargetDeclTest, ObjC) {
397423
Flags = {"-xobjective-c"};
398424
Code = R"cpp(

0 commit comments

Comments
 (0)