Skip to content

Commit 256f6e4

Browse files
fix: Emit refs for templated free functions (#291)
1 parent 1ad98fc commit 256f6e4

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

indexer/ClangAstMacros.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
F(Enum) \
88
F(Field) \
99
F(Function) \
10+
F(FunctionTemplate) \
1011
F(Namespace) \
1112
F(NonTypeTemplateParm) \
1213
F(Record) \

indexer/Indexer.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,11 @@ void TuIndexer::saveFunctionDecl(const clang::FunctionDecl &functionDecl) {
474474
}
475475
}
476476

477+
void TuIndexer::saveFunctionTemplateDecl(const clang::FunctionTemplateDecl &) {
478+
// Handled by saveFunctionDecl.
479+
return;
480+
}
481+
477482
void TuIndexer::saveNamespaceDecl(const clang::NamespaceDecl &namespaceDecl) {
478483
auto optSymbol = this->symbolFormatter.getNamespaceSymbol(namespaceDecl);
479484
if (!optSymbol.has_value()) {

indexer/SymbolFormatter.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,11 @@ SymbolFormatter::getFunctionSymbol(const clang::FunctionDecl &functionDecl) {
447447
});
448448
}
449449

450+
std::optional<std::string_view> SymbolFormatter::getFunctionTemplateSymbol(
451+
const clang::FunctionTemplateDecl &functionTemplateDecl) {
452+
return this->getFunctionSymbol(*functionTemplateDecl.getTemplatedDecl());
453+
}
454+
450455
std::optional<std::string_view>
451456
SymbolFormatter::getFieldSymbol(const clang::FieldDecl &fieldDecl) {
452457
if (fieldDecl.getDeclName().isEmpty()) {

test/index/functions/ctors_dtors.snapshot.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@
8888
C c3{move(c1)};
8989
// ^ reference [..] C#
9090
// ^^ definition local 10
91+
// ^^^^ reference [..] move(721d19cf58c53974).
9192
// ^^ reference local 7
9293
D d3{move(d1)};
9394
// ^ reference [..] D#
9495
// ^^ definition local 11
9596
// ^^ reference [..] D#D(ece7426db7e2c886).
97+
// ^^^^ reference [..] move(721d19cf58c53974).
9698
// ^^ reference local 8
9799

98100
C c4 = {};
@@ -130,10 +132,12 @@
130132
C c10 = move(c1);
131133
// ^ reference [..] C#
132134
// ^^^ definition local 20
135+
// ^^^^ reference [..] move(721d19cf58c53974).
133136
// ^^ reference local 7
134137
D d10 = move(d1);
135138
// ^ reference [..] D#
136139
// ^^^ definition local 21
137140
// ^^^^ reference [..] D#D(ece7426db7e2c886).
141+
// ^^^^ reference [..] move(721d19cf58c53974).
138142
// ^^ reference local 8
139143
}

test/index/functions/templates.snapshot.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@
8484
// ^^ reference [..] T0#g0(b07662a27bd562f9).
8585

8686
h0<int>(0);
87+
// ^^ reference [..] h0(9b289cee16747614).
8788
h0<void *>(0);
89+
// ^^ reference [..] h0(9b289cee16747614).
8890
h1<int>(0);
91+
// ^^ reference [..] h1(9b289cee16747614).
8992
h1<char>(0);
93+
// ^^ reference [..] h1(9b289cee16747614).
9094
}

0 commit comments

Comments
 (0)