[PATCH] D46940: [ASTImporter] make sure that ACtx::getParents still works

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 28 16:42:39 PDT 2018


rsmith added a comment.

This is not specific to the `ASTImporter`; any change to the AST after a call to `getParents` would have similar problems. Generally, responsibility for dealing with this must lie with the consumer of the parent map, not with the `ASTContext`, since the `ASTContext` generally doesn't even know when the AST gets mutated.

I think that the parent map should not be a member of the `ASTContext` at all. That'd make it much clearer that the responsibility for not reusing it across AST mutations lies with the consumer, not with the mutator of the AST. (Also, having it in `ASTContext` invites bugs; we do not want the parent map to ever be used by anything in `Sema`, for instance, largely due to the invalidation problems. In fact, I don't think the `clang` binary needs the parent map code at all; it really belongs in libTooling.)


https://reviews.llvm.org/D46940





More information about the cfe-commits mailing list