llvm-project/clang-tools-extra
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
..
clang-apply-replacements NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
clang-change-namespace Revert "Use InitLLVM to setup a pretty stack printer" 2019-11-25 21:06:56 -05:00
clang-doc NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
clang-include-fixer NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
clang-move NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
clang-query Fix newline handling in clang-query parser 2019-12-29 14:58:56 +00:00
clang-reorder-fields [clang-tools-extra] [cmake] Link against libclang-cpp whenever possible 2019-10-04 20:30:02 +00:00
clang-tidy [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
clangd Include <cstdlib> for std::abort() in clangd 2020-01-24 20:52:37 +01:00
docs Extend misc-misplaced-const to detect using declarations as well as typedef 2020-01-22 15:26:11 -05:00
modularize NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
pp-trace NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
test Extend misc-misplaced-const to detect using declarations as well as typedef 2020-01-22 15:26:11 -05:00
tool-template Revert "Use InitLLVM to setup a pretty stack printer" 2019-11-25 21:06:56 -05:00
unittests NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
.arcconfig [clang-tools-extra] Set up .arcconfig to point to new Diffusion CTE repository 2017-11-27 15:58:25 +00:00
.gitignore
CMakeLists.txt Remove clang-tidy-vs from clang-tools-extra (PR41791) 2019-08-27 18:36:08 +00:00
CODE_OWNERS.TXT Update CODE_OWNERS.txt for clang-doc 2019-06-28 17:32:26 +00:00
LICENSE.TXT Fix typos throughout the license files that somehow I and my reviewers 2019-01-21 09:52:34 +00:00
README.txt

README.txt

//===----------------------------------------------------------------------===//
// Clang Tools repository
//===----------------------------------------------------------------------===//

Welcome to the repository of extra Clang Tools.  This repository holds tools
that are developed as part of the LLVM compiler infrastructure project and the
Clang frontend.  These tools are kept in a separate "extra" repository to
allow lighter weight checkouts of the core Clang codebase.

This repository is only intended to be checked out inside of a full LLVM+Clang
tree, and in the 'tools/extra' subdirectory of the Clang checkout.

All discussion regarding Clang, Clang-based tools, and code in this repository
should be held using the standard Clang mailing lists:
  http://lists.llvm.org/mailman/listinfo/cfe-dev

Code review for this tree should take place on the standard Clang patch and
commit lists:
  http://lists.llvm.org/mailman/listinfo/cfe-commits

If you find a bug in these tools, please file it in the LLVM bug tracker:
  http://llvm.org/bugs/