llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Florian Mayer (fmayer) <details> <summary>Changes</summary> This is useful for matching functions whose name is given as a parameter, e.g. --- Full diff: https://github.com/llvm/llvm-project/pull/139594.diff 1 Files Affected: - (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+18) ``````````diff diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index e6b684b24b080..255f7d3487f9d 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -3144,6 +3144,24 @@ extern const internal::VariadicFunction<internal::Matcher<NamedDecl>, StringRef, internal::hasAnyNameFunc> hasAnyName; +/// Matches NamedDecl nodes that have any of the names in vector. +/// +/// This is useful for matching a list of names that are only known at runtime, +/// e.g. through a command line argument. +/// +/// \code +/// hasAnyName({a, b, c}) +/// \endcode +/// is equivalent to +/// \code +/// anyOf(hasName(a), hasName(b), hasName(c)) +/// \endcode +inline internal::Matcher<NamedDecl> +hasAnyNameInVector(std::vector<std::string> Names) { + return internal::Matcher<NamedDecl>( + new internal::HasNameMatcher(std::move(Names))); +} + /// Matches NamedDecl nodes whose fully qualified names contain /// a substring matched by the given RegExp. /// `````````` </details> https://github.com/llvm/llvm-project/pull/139594 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits