[all-commits] [llvm/llvm-project] a71014: [ASTMatchers] Add mapAnyOf matcher

Stephen Kelly via All-commits all-commits at lists.llvm.org
Sat Jan 16 04:53:46 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a7101450a42e4f1ed5af1a38a6def08f1b5b58fe
      https://github.com/llvm/llvm-project/commit/a7101450a42e4f1ed5af1a38a6def08f1b5b58fe
  Author: Stephen Kelly <steveire at gmail.com>
  Date:   2021-01-16 (Sat, 16 Jan 2021)

  Changed paths:
    M clang/docs/LibASTMatchersReference.html
    M clang/docs/tools/dump_ast_matchers.py
    M clang/include/clang/ASTMatchers/ASTMatchers.h
    M clang/include/clang/ASTMatchers/ASTMatchersInternal.h
    M clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

  Log Message:
  -----------
  [ASTMatchers] Add mapAnyOf matcher

Make it possible to compose a matcher for different base nodes.

This accepts one or more node matcher functors and zero or more
matchers, composing the latter into the former.

This allows composing of matchers where the same inner matcher name is
used for the same concept, but with a different node functor. Currently,
there is a limitation that the nodes must be in the same "clade", so
while

  mapAnyOf(ifStmt, forStmt).with(hasBody(stmt()))

can be used, functionDecl can not be added to the tuple.

It is possible to use this in clang-query, but it will require changes
to the QueryParser, so is deferred to a future review.

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




More information about the All-commits mailing list