[clangd] Handle MemberPointerTypeLoc in SelectionTree (#183242)
This is another type loc that overlaps the name of the declaration whose type it is, and so needs special handling to allow the declaration itself to be targeted. Fixes https://github.com/clangd/clangd/issues/2608
This commit is contained in:
parent
bc9d5b01d3
commit
0fa0bb1067
@ -959,6 +959,10 @@ private:
|
||||
claimRange(PTL.getStarLoc(), Result);
|
||||
return;
|
||||
}
|
||||
if (auto MPTL = TL->getAs<MemberPointerTypeLoc>()) {
|
||||
claimRange(MPTL.getLocalSourceRange(), Result);
|
||||
return;
|
||||
}
|
||||
if (auto FTL = TL->getAs<FunctionTypeLoc>()) {
|
||||
claimRange(SourceRange(FTL.getLParenLoc(), FTL.getEndLoc()), Result);
|
||||
return;
|
||||
|
||||
@ -2370,6 +2370,16 @@ TEST(FindReferences, WithinAST) {
|
||||
[$(Bar)[[F^oo]]...$(Bar)[[Fo^o]] + 1] = 0,
|
||||
[$(Bar)[[^Foo]] + 2] = 1
|
||||
};
|
||||
)cpp",
|
||||
// Field of pointer-to-member type
|
||||
R"cpp(
|
||||
struct S { void foo(); };
|
||||
struct A {
|
||||
void (S::*$def(A)[[fi^eld]])();
|
||||
};
|
||||
void bar(A& a, S& s) {
|
||||
(s.*(a.$(bar)[[field]]))();
|
||||
}
|
||||
)cpp"};
|
||||
for (const char *Test : Tests)
|
||||
checkFindRefs(Test);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user