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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D46940: [... Richard Smith - zygoloid via Phabricator via cfe-commits

Reply via email to