[PATCH] D82568: [clang][CrossTU] Invalidate parent map after get cross TU definition.

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 1 07:00:20 PDT 2020


balazske marked an inline comment as done.
balazske added inline comments.


================
Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:723
+  // Parent map is invalidated after changing the AST.
+  ToDecl->getASTContext().getParentMapContext().clear();
+
----------------
balazske wrote:
> balazske wrote:
> > martong wrote:
> > > > ... the TU is modified by getCrossTUDefinition the parent map does not
> > > contain the newly imported objects and has to be re-created.
> > > 
> > > I see we clear it here, but when/where will be the parent map re-created?
> > It should be created at any access to it. (Actually I did not check how this works after the test showed that the fix works.)
> `ASTContext::getParentMapContext` does the job.
More precisely, `ParentMapContext::getParents` re-creates the parent map after it was cleared. The parent maps in the `ParentMapContext` are cleared, not the parent map pointer in `ASTContext`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82568/new/

https://reviews.llvm.org/D82568





More information about the cfe-commits mailing list