[PATCH] D126684: [Interpreter] Implment Interpreter::Restore to clean up lookup table
Jun Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 30 23:32:40 PDT 2022
junaire updated this revision to Diff 433022.
junaire added a comment.
Format the patch
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126684/new/
https://reviews.llvm.org/D126684
Files:
clang/include/clang/Interpreter/Interpreter.h
clang/lib/Interpreter/IncrementalParser.cpp
clang/lib/Interpreter/IncrementalParser.h
clang/lib/Interpreter/Interpreter.cpp
Index: clang/lib/Interpreter/Interpreter.cpp
===================================================================
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -228,6 +228,10 @@
return llvm::Error::success();
}
+void Interpreter::Restore(PartialTranslationUnit &PTU) {
+ IncrParser->Restore(PTU);
+}
+
llvm::Expected<llvm::JITTargetAddress>
Interpreter::getSymbolAddress(GlobalDecl GD) const {
if (!IncrExecutor)
Index: clang/lib/Interpreter/IncrementalParser.h
===================================================================
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
///\returns the mangled name of a \c GD.
llvm::StringRef GetMangledName(GlobalDecl GD) const;
+ void Restore(PartialTranslationUnit &PTU);
+
private:
llvm::Expected<PartialTranslationUnit &> ParseOrWrapTopLevelDecl();
};
Index: clang/lib/Interpreter/IncrementalParser.cpp
===================================================================
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -293,6 +293,24 @@
return PTU;
}
+void IncrementalParser::Restore(PartialTranslationUnit &PTU) {
+ TranslationUnitDecl *MostRecentTU = PTU.TUPart;
+ TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
+ if (StoredDeclsMap *Map = FirstTU->getLookupPtr()) {
+ for (auto I = Map->begin(); I != Map->end(); ++I) {
+ StoredDeclsList &List = I->second;
+ DeclContextLookupResult R = List.getLookupResult();
+ for (NamedDecl *D : R) {
+ if (D->getTranslationUnitDecl() == MostRecentTU) {
+ List.remove(D);
+ }
+ }
+ if (List.isNull())
+ Map->erase(I);
+ }
+ }
+}
+
llvm::StringRef IncrementalParser::GetMangledName(GlobalDecl GD) const {
CodeGenerator *CG = getCodeGen(Act.get());
assert(CG);
Index: clang/include/clang/Interpreter/Interpreter.h
===================================================================
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -69,6 +69,8 @@
return llvm::Error::success();
}
+ void Restore(PartialTranslationUnit &PTU);
+
/// \returns the \c JITTargetAddress of a \c GlobalDecl. This interface uses
/// the CodeGenModule's internal mangling cache to avoid recomputing the
/// mangled name.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126684.433022.patch
Type: text/x-patch
Size: 2424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220531/b3a879ac/attachment.bin>
More information about the cfe-commits
mailing list