[all-commits] [llvm/llvm-project] f51a31: [ASTMatchers] Enhanced support for matchers taking...

Nathan James via All-commits all-commits at lists.llvm.org
Thu Jul 2 06:52:48 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f51a319cacd44819b4fb9fa9f005c2445bcee984
      https://github.com/llvm/llvm-project/commit/f51a319cacd44819b4fb9fa9f005c2445bcee984
  Author: Nathan James <n.james93 at hotmail.co.uk>
  Date:   2020-07-02 (Thu, 02 Jul 2020)

  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/include/clang/ASTMatchers/ASTMatchersMacros.h
    M clang/lib/ASTMatchers/ASTMatchersInternal.cpp
    M clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
    M clang/lib/ASTMatchers/Dynamic/Marshallers.h
    M clang/lib/ASTMatchers/Dynamic/Registry.cpp
    M clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
    M clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
    M llvm/include/llvm/Support/Regex.h
    M llvm/lib/Support/Regex.cpp

  Log Message:
  -----------
  [ASTMatchers] Enhanced support for matchers taking Regex arguments

Added new Macros `AST(_POLYMORPHIC)_MATCHER_REGEX(_OVERLOAD)` that define a matchers that take a regular expression string and optionally regular expression flags. This lets users match against nodes while ignoring the case without having to manually use `[Aa]` or `[A-Fa-f]` in their regex. The other point this addresses is in the current state, matchers that use regular expressions have to compile them for each node they try to match on, Now the regular expression is compiled once when you define the matcher and used for every node that it tries to match against. If there is an error while compiling the regular expression an error will be logged to stderr showing the bad regex string and the reason it couldn't be compiled. The old behaviour of this was down to the Matcher implementation and some would assert, whereas others just would never match. Support for this has been added to the documentation script as well. Support for this has been added to dynamic matchers ensuring functionality is the same between the 2 use cases.

Reviewed By: aaron.ballman

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




More information about the All-commits mailing list