================
@@ -54,6 +54,7 @@
namespace clang {
class ASTContext;
+class DeclStateReverter;
----------------
jaredwy wrote:
> I'm fine with either approach. We can have separate ASTDeclCommitter,
> ASTDeclRestorer, and ASTDeclUnmerger classes with the required friend access,
> or one shared class to provide access to them.
Neither. I want this on `ASTDeclUnmerger`, which is what Vassil is asking for
too. It's the class that already does this job, it's already a `DeclVisitor`,
and it already holds the `Redeclarable` and `CXXRecordDecl` grants. This PR
adds `friend class DeclStateReverter` eight lines under it in DeclCXX.h. That's
the duplication I was pointing at in the first comment.
> we are not performing one single operation for each declaration kind.
> Instead, there are separate operations, and each operation has its own
> dispatch.
The Unmerger already does several per kind. `VisitDeclContext` unlinks, removes
from lookup and puts the survivors back. `VisitTagDecl` unlinks and then nulls
`DefinitionData` across the survivor's redecls. That second one is restoring a
surviving decl's state, not unlinking a new one, so restore is already unmerge.
The footprint restore, the exception spec type, spec info, `Common` and the
specialization lists are more of the same, and they get the typed pointer from
the visitor instead of `cast<TYPE>(D)` off `DeclShape`.
Commit is the recording side of the same thing and needs one private read,
`data()`. Put it on the Unmerger too. The code that undoes a write is the code
that should snapshot it, so a footprint and its restore live in one place.
The new part of your PR is the ledger. `findSurvivor can call
`Ledger.isFromThisPTU` and the Unmerger has allocation provenance, which is
what catches the implicit decls and out-of-line members that lexical
containment misses
How restore is driven off `Mutations` versus the TU walk is detail, both end in
the same typed writes on the Unmerger. What I'm after is one class, one friend
grant, `DeclVisitor` dispatch, ledger membership. For `Rec`, carry it on the
visitor the way `ASTDeclReader` carries `Record` rather than adding a
dispatcher with extra params.
https://github.com/llvm/llvm-project/pull/223305
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits