Skip to content

Commit

Permalink
LLVM 18: port to latest master
Browse files Browse the repository at this point in the history
Fixes:
error: 'const class clang::DependentFunctionTemplateSpecializationInfo' has no member named 'getNumTemplates'
  • Loading branch information
marxin committed Oct 8, 2023
1 parent 4b129f7 commit eef2b43
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions clang_delta/RemoveUnusedFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FunctionTemplateDecl *> 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;
}

Expand Down Expand Up @@ -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<FunctionTemplateDecl *> 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;
}

Expand Down

0 comments on commit eef2b43

Please sign in to comment.