Skip to content

[clang] Add hasAnyNameInVector matcher #139594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions clang/include/clang/ASTMatchers/ASTMatchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down