llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines
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
..
AvoidGotoCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
AvoidGotoCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt Add the misc-init-local-variables check. 2019-10-02 17:18:57 +00:00
CppCoreGuidelinesTidyModule.cpp Add the misc-init-local-variables check. 2019-10-02 17:18:57 +00:00
InitVariablesCheck.cpp Add the misc-init-local-variables check. 2019-10-02 17:18:57 +00:00
InitVariablesCheck.h Add the misc-init-local-variables check. 2019-10-02 17:18:57 +00:00
InterfacesGlobalInitCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
InterfacesGlobalInitCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MacroUsageCheck.cpp [clang-tools-extra] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:52:23 +00:00
MacroUsageCheck.h [clang-tidy] Move all checks to the new registerPPCallbacks API 2019-03-22 18:58:12 +00:00
NarrowingConversionsCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
NarrowingConversionsCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
NoMallocCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
NoMallocCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
OwningMemoryCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
OwningMemoryCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProBoundsArrayToPointerDecayCheck.cpp [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
ProBoundsArrayToPointerDecayCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProBoundsConstantArrayIndexCheck.cpp [clang-tools-extra] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:52:23 +00:00
ProBoundsConstantArrayIndexCheck.h [clang-tidy] Move all checks to the new registerPPCallbacks API 2019-03-22 18:58:12 +00:00
ProBoundsPointerArithmeticCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProBoundsPointerArithmeticCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeConstCastCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeConstCastCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeCstyleCastCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeCstyleCastCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeMemberInitCheck.cpp NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
ProTypeMemberInitCheck.h Remove \brief commands from doxygen comments. 2019-08-22 11:32:57 +00:00
ProTypeReinterpretCastCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeReinterpretCastCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeStaticCastDowncastCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeStaticCastDowncastCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeUnionAccessCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeUnionAccessCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeVarargCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProTypeVarargCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SlicingCheck.cpp NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
SlicingCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SpecialMemberFunctionsCheck.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SpecialMemberFunctionsCheck.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00