conrade-ctc wrote:
> I guess what you want to happen is to roll back the AST as if the erroneous
> declaration never happened, but I'm not sure what that would look like.
I reworked the PR: it now resets the implicit instantiations of a failed input
instead of keeping them.
The interpreter records the implicit instantiations of each input with an
`ASTMutationListener`, as `ASTWriter` does. When the input fails, it drops
their bodies or initializers, deduced return types and points of instantiation,
and withdraws out-of-line static data member definitions. The next use then
instantiates them again, without the declarations of the failed input.
Your example now gives `use of undeclared identifier 'value'` for the later
`readv(S{})`, and a later `int value(const S &)` gets a fresh instantiation.
One gap: a class template specialization that a failed input instantiated keeps
its definition, because its layout is cached by declaration and earlier inputs
can name the type. I think that case is rare, but I would appreciate a pointer
if Sema has a better hook for it.
https://github.com/llvm/llvm-project/pull/226253
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits