Skip to content

Commit

Permalink
DeclUnloader: Remove extra check isInstantiatedInPCH
Browse files Browse the repository at this point in the history
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
root-project/root#4447 works, but it filters
too many declarations from the unloader.
  • Loading branch information
hahnjo authored and jenkins committed Nov 30, 2023
1 parent d3e4223 commit aeba3fa
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
15 changes: 0 additions & 15 deletions lib/Interpreter/DeclUnloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 1 addition & 3 deletions lib/Interpreter/DeclUnloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit aeba3fa

Please sign in to comment.