llvm-project/clang/lib/Tooling
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
..
ASTDiff [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
Core [clang] Adopt new FileManager error-returning APIs 2019-08-01 21:31:56 +00:00
DependencyScanning [clang][clang-scan-deps] Aggregate the full dependency information. 2020-01-23 16:58:50 -08:00
Inclusions Allow additional file suffixes/extensions considered as source in main include grouping 2019-11-12 21:26:52 +00:00
Refactoring [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
Syntax Remove trailing `;`. NFC. 2020-01-14 16:52:20 -05:00
Transformer [libTooling] Fix bug in Stencil handling of macro ranges 2020-01-17 12:11:25 -05:00
AllTUsExecution.cpp Prune Pass.h include from DataLayout.h. NFCI 2019-10-21 17:51:54 +00:00
ArgumentsAdjusters.cpp [clang][Tooling] Filter flags that generate output in SyntaxOnlyAdjuster 2019-11-13 15:03:30 +01:00
CMakeLists.txt [clang][Tooling] Add support for .rsp files in compile_commands.json 2019-12-04 15:13:12 +01:00
CommonOptionsParser.cpp [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
CompilationDatabase.cpp [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
Execution.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ExpandResponseFilesCompilationDatabase.cpp [clang][Tooling] Fix potential UB in ExpandResponseFilesCompilationDatabase 2019-12-09 12:24:23 +01:00
FileMatchTrie.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FixIt.cpp [LibTooling] Add "SourceCode" library for functions relating to source-code manipulation. 2019-04-05 14:05:03 +00:00
GuessTargetAndModeCompilationDatabase.cpp [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
InterpolatingCompilationDatabase.cpp [clang][Tooling] Prefer -x over -std when interpolating 2019-12-20 11:10:36 +01:00
JSONCompilationDatabase.cpp Reapply "[llvm][Support] Take in CurrentDirectory as a parameter in ExpandResponseFiles" 2019-12-04 17:00:47 +01:00
Refactoring.cpp [clang] Adopt new FileManager error-returning APIs 2019-08-01 21:31:56 +00:00
RefactoringCallbacks.cpp [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
StandaloneExecution.cpp [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
Tooling.cpp [libTooling] Extend `buildASTFromCodeWithArgs` to take files argument. 2019-11-19 12:18:36 -05:00