Skip to content

Commit 877fef0

Browse files
fix: Use standard API for dependent name lookup (#300)
This takes inheritance into account correctly
1 parent a81897e commit 877fef0

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

indexer/Indexer.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "spdlog/fmt/fmt.h"
1212

1313
#include "clang/AST/ASTContext.h"
14+
#include "clang/AST/CXXInheritance.h"
1415
#include "clang/AST/Decl.h"
1516
#include "clang/AST/DeclCXX.h"
1617
#include "clang/AST/DeclTemplate.h"
@@ -856,10 +857,9 @@ void TuIndexer::trySaveMemberReferenceViaLookup(
856857
if (!recordDecl) {
857858
return;
858859
}
859-
// FIXME(issue: https://github.com/sourcegraph/scip-clang/issues/296):
860-
// We should try to use more standard code which takes
861-
// inheritance into account.
862-
auto lookupResult = recordDecl->lookup(memberNameInfo.getName());
860+
auto lookupResult = recordDecl->lookupDependentName(
861+
memberNameInfo.getName(),
862+
[](const clang::NamedDecl *) -> bool { return true; });
863863
for (auto *namedDecl : lookupResult) {
864864
auto optSymbol = this->symbolFormatter.getNamedDeclSymbol(*namedDecl);
865865
if (optSymbol) {

test/index/functions/template_body.snapshot.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,17 @@
7575
void ff0() {
7676
// ^^^ definition [..] ZZ#ff0(49f6e7a06ebc5aa8).
7777
this->f0();
78+
// ^^ reference [..] Z#f0(49f6e7a06ebc5aa8).
7879
}
7980

8081
template <typename U>
8182
// ^ definition local 6
8283
void gg0() {
8384
// ^^^ definition [..] ZZ#gg0(49f6e7a06ebc5aa8).
8485
this->f0();
86+
// ^^ reference [..] Z#f0(49f6e7a06ebc5aa8).
8587
this->template g0<U>();
88+
// ^^ reference [..] Z#g0(49f6e7a06ebc5aa8).
8689
// ^ reference local 6
8790
}
8891
};

test/index/functions/templates.snapshot.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// ^ reference local 2
2626
// ^ definition local 3
2727
this->f0(t);
28+
// ^^ reference [..] T0#f0(9b289cee16747614).
2829
// ^ reference local 3
2930
}
3031

@@ -35,6 +36,7 @@
3536
// ^ reference local 4
3637
// ^ definition local 5
3738
this->template g0<U>(u);
39+
// ^^ reference [..] T0#g0(b07662a27bd562f9).
3840
// ^ reference local 4
3941
// ^ reference local 5
4042
}

0 commit comments

Comments
 (0)