Skip to content

Commit b84a608

Browse files
committed
Fix GetFunctionSignature to return signatures for FunctionTemplateDecls
1 parent f0f59f2 commit b84a608

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

lib/Interpreter/CppInterOp.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -958,20 +958,25 @@ namespace Cpp {
958958
return "<unknown>";
959959

960960
auto *D = (clang::Decl *) func;
961-
if (auto *FD = llvm::dyn_cast<FunctionDecl>(D)) {
962-
std::string Signature;
963-
raw_string_ostream SS(Signature);
964-
PrintingPolicy Policy = getASTContext().getPrintingPolicy();
965-
// Skip printing the body
966-
Policy.TerseOutput = true;
967-
Policy.FullyQualifiedName = true;
968-
Policy.SuppressDefaultTemplateArgs = false;
969-
FD->print(SS, Policy);
970-
SS.flush();
971-
return Signature;
972-
}
961+
clang::FunctionDecl* FD;
962+
963+
if (llvm::dyn_cast<FunctionDecl>(D))
964+
FD = llvm::dyn_cast<FunctionDecl>(D);
965+
else if (auto* FTD = llvm::dyn_cast<clang::FunctionTemplateDecl>(D))
966+
FD = FTD->getTemplatedDecl();
967+
else
968+
return "<unknown>";
973969

974-
return "<unknown>";
970+
std::string Signature;
971+
raw_string_ostream SS(Signature);
972+
PrintingPolicy Policy = getASTContext().getPrintingPolicy();
973+
// Skip printing the body
974+
Policy.TerseOutput = true;
975+
Policy.FullyQualifiedName = true;
976+
Policy.SuppressDefaultTemplateArgs = false;
977+
FD->print(SS, Policy);
978+
SS.flush();
979+
return Signature;
975980
}
976981

977982
// Internal functions that are not needed outside the library are

0 commit comments

Comments
 (0)