[PATCH] D154328: [AST] Add API to iterate already loaded specializations
Jonas Hahnfeld via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 28 07:11:37 PDT 2023
Hahnfeld added a comment.
Right, it's not ideal to land APIs without usage in Clang itself... The context is, once again, ROOT and the Cling interpreter (where we are already using this API via downstream patches): When unloading a "transaction" (now `PartialTranslationUnit` in `clang-repl`) we need to "unload" all contained declarations, ie make the code generator forget that it had already emitted them. For templates, this is a bit tricky so we need to iterate specializations without triggering more deserialization. This will get important with D41416 <https://reviews.llvm.org/D41416> where we only load needed specializations.
When playing a bit earlier this week, I learned that the problem related to "unloading" of template specializations can be observed upstream in `clang-repl`:
clang-repl> template <typename T> void f() {}
clang-repl> f<int>();
clang-repl> %undo
clang-repl> template <> void f<int>() {}
In file included from <<< inputs >>>:1:
input_line_3:1:18: error: explicit specialization of 'f<int>' after instantiation
1 | template <> void f<int>() {}
| ^
input_line_2:1:1: note: implicit instantiation first required here
1 | f<int>();
| ^
error: Parsing failed.
Let me see if I can come up a fix for that in `clang-repl` that would then need this API. But for now, it's also fine for us if the patch stays pending in review, still better than completely disconnected local commits...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154328/new/
https://reviews.llvm.org/D154328
More information about the cfe-commits
mailing list