[all-commits] [llvm/llvm-project] 8a81da: [AST] Split parent map traversal logic into Parent...
Reid Kleckner via All-commits
all-commits at lists.llvm.org
Fri Jan 24 13:42:33 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 8a81daaa8b58aeaa192a47c4ce7f94b4d59ce082
https://github.com/llvm/llvm-project/commit/8a81daaa8b58aeaa192a47c4ce7f94b4d59ce082
Author: Reid Kleckner <rnk at google.com>
Date: 2020-01-24 (Fri, 24 Jan 2020)
Changed paths:
M clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
M clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
M clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
M clang/include/clang/AST/ASTContext.h
M clang/include/clang/AST/ASTNodeTraverser.h
A clang/include/clang/AST/ParentMapContext.h
M clang/include/clang/ASTMatchers/ASTMatchers.h
M clang/include/clang/Sema/Sema.h
M clang/lib/AST/ASTContext.cpp
M clang/lib/AST/CMakeLists.txt
M clang/lib/AST/Linkage.h
A clang/lib/AST/ParentMapContext.cpp
M clang/lib/ASTMatchers/ASTMatchFinder.cpp
M clang/lib/ASTMatchers/ASTMatchersInternal.cpp
M clang/lib/CodeGen/CGCall.h
M clang/lib/Tooling/ASTDiff/ASTDiff.cpp
M clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
M lldb/include/lldb/Symbol/TypeSystemClang.h
Log Message:
-----------
[AST] Split parent map traversal logic into ParentMapContext.h
The only part of ASTContext.h that requires most AST types to be
complete is the parent map. Nothing in Clang proper uses the ParentMap,
so split it out into its own class. Make ASTContext own the
ParentMapContext so there is still a one-to-one relationship.
After this change, 562 fewer files depend on ASTTypeTraits.h, and 66
fewer depend on TypeLoc.h:
$ diff -u deps-before.txt deps-after.txt | \
grep '^[-+] ' | sort | uniq -c | sort -nr | less
562 - ../clang/include/clang/AST/ASTTypeTraits.h
340 + ../clang/include/clang/AST/ParentMapContext.h
66 - ../clang/include/clang/AST/TypeLocNodes.def
66 - ../clang/include/clang/AST/TypeLoc.h
15 - ../clang/include/clang/AST/TemplateBase.h
...
I computed deps-before.txt and deps-after.txt with `ninja -t deps`.
This removes a common and key dependency on TemplateBase.h and
TypeLoc.h.
This also has the effect of breaking the ParentMap RecursiveASTVisitor
instantiation into its own file, which roughly halves the compilation
time of ASTContext.cpp (29.75s -> 17.66s). The new file takes 13.8s to
compile.
I left behind forwarding methods for getParents(), but clients will need
to include a new header to make them work:
#include "clang/AST/ParentMapContext.h"
I noticed that this parent map functionality is unfortunately duplicated
in ParentMap.h, which only works for Stmt nodes.
Reviewed By: rsmith
Differential Revision: https://reviews.llvm.org/D71313
More information about the All-commits
mailing list