[PATCH] D82568: [clang][CrossTU] Invalidate parent map after get cross TU definition.
Endre Fülöp via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 12:02:29 PDT 2020
gamesh411 accepted this revision.
gamesh411 added a comment.
This revision is now accepted and ready to land.
I have found this in ASTContext.h:
// A traversal scope limits the parts of the AST visible to certain analyses.
// RecursiveASTVisitor::TraverseAST will only visit reachable nodes, and
// getParents() will only observe reachable parent edges.
//
// The scope is defined by a set of "top-level" declarations.
// Initially, it is the entire TU: {getTranslationUnitDecl()}.
// Changing the scope clears the parent cache, which is expensive to rebuild.
std::vector<Decl *> getTraversalScope() const { return TraversalScope; }
The setTraversalScope resets the parentmap in ASTContext.cpp:
void ASTContext::setTraversalScope(const std::vector<Decl *> &TopLevelDecls) {
TraversalScope = TopLevelDecls;
getParentMapContext().clear();
}
It seems to me that not resetting this cache could very well cause a bad AST being available.
Just curious: Is there an example that you are aware of, where this caused an actual problem?
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