From eef2b43463cb3e8349c2cd54d813f498d2d68a0b Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Sun, 8 Oct 2023 11:05:21 +0200 Subject: [PATCH] LLVM 18: port to latest master Fixes: error: 'const class clang::DependentFunctionTemplateSpecializationInfo' has no member named 'getNumTemplates' --- clang_delta/RemoveUnusedFunction.cpp | 32 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/clang_delta/RemoveUnusedFunction.cpp b/clang_delta/RemoveUnusedFunction.cpp index 0252fc1f..ca9d3f7b 100644 --- a/clang_delta/RemoveUnusedFunction.cpp +++ b/clang_delta/RemoveUnusedFunction.cpp @@ -215,11 +215,23 @@ bool RUFAnalysisVisitor::VisitFunctionDecl(FunctionDecl *FD) FD->getDependentSpecializationInfo(); // don't need to track all specs, just associate FD with one // of those + const FunctionDecl *Member = nullptr; + +#if LLVM_VERSION_MAJOR >= 18 + ArrayRef members = Info->getCandidates(); + if (!members.empty()) { + Member = members[0]->getTemplatedDecl(); + } +#else if (Info->getNumTemplates() > 0) { - const FunctionDecl *Member = + Member = Info->getTemplate(0)->getTemplatedDecl(); - ConsumerInstance->addOneMemberSpecialization(FD, Member); } +#endif + + if (Member != nullptr) + ConsumerInstance->addOneMemberSpecialization(FD, Member); + return true; } @@ -921,11 +933,21 @@ void RemoveUnusedFunction::handleOneFunctionDecl(const FunctionDecl *TheFD) TheFD->getDependentSpecializationInfo(); // don't need to track all specs, just associate FD with one // of those + const FunctionDecl *Member = nullptr; + +#if LLVM_VERSION_MAJOR >= 18 + ArrayRef members = Info->getCandidates(); + if (!members.empty()) { + Member = members[0]->getTemplatedDecl(); + } +#else if (Info->getNumTemplates() > 0) { - const FunctionDecl *Member = - Info->getTemplate(0)->getTemplatedDecl(); - createFuncToExplicitSpecs(Member); + Member = Info->getTemplate(0)->getTemplatedDecl(); } +#endif + + if (Member != nullptr) + createFuncToExplicitSpecs(Member); return; }