DeclUnloader: Remove extra check isInstantiatedInPCH

This effectively reverts commit 74472caaa9 ("[cling] Fixes issue in
DeclUnloader: do not unload templates intantiated in the PCH"), it's
not needed anymore, all tests pass and the snippet in the summary of
https://github.com/root-project/root/pull/4447 works, but it filters
too many declarations from the unloader.
This commit is contained in:
Jonas Hahnfeld 2023-11-24 14:39:34 +01:00 committed by jenkins
parent d3e42235c1
commit aeba3fa2c7
2 changed files with 1 additions and 18 deletions

View File

@ -473,21 +473,6 @@ namespace {
namespace cling {
using namespace clang;
///\brief Return whether `D' is a template that was first instantiated non-
/// locally, i.e. in a PCH/module. If `D' is not an instantiation, return
/// false.
bool DeclUnloader::isInstantiatedInPCH(const Decl* D) {
SourceManager& SM = D->getASTContext().getSourceManager();
if (const auto FD = dyn_cast<FunctionDecl>(D))
return FD->isTemplateInstantiation() &&
!SM.isLocalSourceLocation(FD->getPointOfInstantiation());
else if (const auto CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
return !SM.isLocalSourceLocation(CTSD->getPointOfInstantiation());
else if (const auto VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
return !SM.isLocalSourceLocation(VTSD->getPointOfInstantiation());
return false;
}
void DeclUnloader::resetDefinitionData(TagDecl* decl) {
auto canon = dyn_cast<CXXRecordDecl>(decl->getCanonicalDecl());
assert(canon && "Only CXXRecordDecl have DefinitionData");

View File

@ -60,7 +60,7 @@ namespace cling {
///\returns true on success.
///
bool UnloadDecl(clang::Decl* D) {
if (D->isFromASTFile() || isInstantiatedInPCH(D))
if (D->isFromASTFile())
return true;
return Visit(D);
}
@ -270,8 +270,6 @@ namespace cling {
///
void CollectFilesToUncache(clang::SourceLocation Loc);
bool isInstantiatedInPCH(const clang::Decl *D);
template <typename T>
bool VisitRedeclarable(clang::Redeclarable<T>* R, clang::DeclContext* DC);
};