In AutoloadingVisitor only unload enum decl that comes from the rootmap file

This commit is contained in:
Philippe Canal 2016-11-08 15:52:58 -06:00 committed by sftnight
parent 7c9379ac93
commit 8b1afa0e6b

View File

@ -74,6 +74,19 @@ namespace cling {
const clang::FileEntry* m_PrevFE;
std::string m_PrevFileName;
private:
bool IsAutoloadEntry(Decl *D) {
AnnotateAttr* attr = D->getAttr<AnnotateAttr>();
if (attr) {
llvm::StringRef annotation = attr->getAnnotation();
assert(!annotation.empty() && "Empty annotation!");
if (annotation.startswith(llvm::StringRef(annoTag, lenAnnoTag))) {
// autoload annotation.
return true;
}
}
return false;
}
void InsertIntoAutoloadingState (Decl* decl, llvm::StringRef annotation) {
assert(!annotation.empty() && "Empty annotation!");
@ -229,7 +242,8 @@ namespace cling {
return true;
// Now that we will read the full enum, unload the forward decl.
UnloadDecl(m_Sema, D);
if (IsAutoloadEntry(D))
UnloadDecl(m_Sema, D);
return true;
}
};