llvm-project/clang/lib
Reid Kleckner 8a81daaa8b [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
2020-01-24 13:42:28 -08:00
..
ARCMigrate Fix "pointer is null" static analyzer warning. NFCI. 2020-01-10 17:21:20 +00:00
AST [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
ASTMatchers [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
Analysis [DataFlow] Factor two worklist implementations out 2020-01-17 08:11:15 -08:00
Basic Support Swift calling convention for WebAssembly targets 2020-01-24 10:30:46 -08:00
CodeGen [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
CrossTU [CrossTU] Fix problem with CrossTU AST load limit and progress messages. 2019-08-12 07:15:29 +00:00
DirectoryWatcher [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
Driver [Frontend] Delete some unneeded CC1 options 2020-01-23 22:01:04 -08:00
Edit [C++2a] Add __builtin_bit_cast, used to implement std::bit_cast 2019-07-02 18:28:13 +00:00
Format [Format] Fix 'auto x(T&&, T &&)->F' with PAS_Left. 2020-01-24 11:03:46 +01:00
Frontend [Frontend] Delete some unneeded CC1 options 2020-01-23 22:01:04 -08:00
FrontendTool [analyzer] Don't run the analyzer for -analyzer-list-enabled-checkers 2019-09-12 18:53:48 +00:00
Headers [CUDA] Fix order of memcpy arguments in __shfl_*(<64-bit type>). 2020-01-23 13:17:52 -08:00
Index [clang][index] Index the injected class name types. 2020-01-22 10:07:54 +01:00
Lex [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag. 2020-01-15 11:28:57 +00:00
Parse [Concepts] Make constraint expressions unevaluated until satisfaction checking 2020-01-24 02:24:21 +02:00
Rewrite [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug 2019-08-15 21:17:48 +00:00
Sema [Sema] Provide declarations for MaximumAlignment, MaxAlignmentExponent variables 2020-01-24 18:18:15 +03:00
Serialization [Concepts] Placeholder constraints and abbreviated templates 2020-01-23 19:39:43 +02:00
StaticAnalyzer [analyzer] PthreadLock: Implement dead region cleanup. 2020-01-24 18:43:24 +03:00
Tooling [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
CMakeLists.txt Reland [clang] DirectoryWatcher 2019-07-12 20:34:10 +00:00