[all-commits] [llvm/llvm-project] dd6894: [AST] Add TypeLoc support to node introspection

Stephen Kelly via All-commits all-commits at lists.llvm.org
Sat Apr 17 15:16:26 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dd68942f1d79986267a58c9a9924522680d5c82b
      https://github.com/llvm/llvm-project/commit/dd68942f1d79986267a58c9a9924522680d5c82b
  Author: Stephen Kelly <steveire at gmail.com>
  Date:   2021-04-17 (Sat, 17 Apr 2021)

  Changed paths:
    M clang/include/clang/Tooling/NodeIntrospection.h
    M clang/lib/Tooling/CMakeLists.txt
    M clang/lib/Tooling/DumpTool/APIData.h
    M clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
    M clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
    M clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
    M clang/unittests/Introspection/IntrospectionTest.cpp

  Log Message:
  -----------
  [AST] Add TypeLoc support to node introspection

Extend the matchers gathering API for types to record template
parameters.  The TypeLoc type hierarchy has some types which are
templates used in CRTP such as PointerLikeTypeLoc.  Record the inherited
template and template arguments of types inheriting those CRTP types in
the ClassInheritance map.  Because the name inherited from is now
computed, the value type in that map changes from StringRef to
std::string.  This also causes the toJSON override signature used to
serialize that map to change.

Remove the logic for skipping over empty ClassData instances.  Several
classes such as TypeOfExprTypeLoc inherit a CRTP class which provides
interesting locations though the derived class does not.  Record it as a
class to make the locations it inherits available.

Record the typeSourceInfo accessors too as they provide access to
TypeLocs in many classes.

The existing unit tests use UnorderedElementsAre to compare the
introspection result with the expected result.  Our current
implementation of google mock (in gmock-generated-matchers.h) is limited
to support for comparing a container of 10 elements.  As we are now
returning more than 10 results for one of the introspection tests,
change it to instead compare against an ordered vector of pairs.

Because a macro is used to generate API strings and API calls, disable
clang-format in blocks of expected results.  Otherwise clang-format
would insert whitespaces which would then be compared against the
introspected strings and fail the test.

Introduce a recursion guard in the generated code.  The TypeLoc class
has IgnoreParens() API which by default returns itself, so it would
otherwise recurse infinitely.

Differential Revision: https://reviews.llvm.org/D100516




More information about the All-commits mailing list