class VariantMatcher
Declaration
class VariantMatcher { /* full declaration omitted */ };
Description
A variant matcher object. The purpose of this object is to abstract simple and polymorphic matchers into a single object type. Polymorphic matchers might be implemented as a list of all the possible overloads of the matcher. \c VariantMatcher knows how to select the appropriate overload when needed. To get a real matcher object out of a \c VariantMatcher you can do: - getSingleMatcher() which returns a matcher, only if it is not ambiguous to decide which matcher to return. Eg. it contains only a single matcher, or a polymorphic one with only one overload. - hasTypedMatcher <T >()/getTypedMatcher <T >(): These calls will determine if the underlying matcher(s) can unambiguously return a Matcher <T >.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:105
Member Variables
- private std::shared_ptr<const Payload> Value
Method Overview
- public static clang::ast_matchers::dynamic::VariantMatcher PolymorphicMatcher(std::vector<DynTypedMatcher> Matchers)
- public static clang::ast_matchers::dynamic::VariantMatcher SingleMatcher(const clang::ast_matchers::internal::DynTypedMatcher & Matcher)
- public static clang::ast_matchers::dynamic::VariantMatcher VariadicOperatorMatcher(DynTypedMatcher::VariadicOperator Op, std::vector<VariantMatcher> Args)
- public VariantMatcher()
- private VariantMatcher(std::shared_ptr<Payload> Value)
- public llvm::Optional<DynTypedMatcher> getSingleMatcher() const
- public std::string getTypeAsString() const
- public clang::ast_matchers::internal::DynTypedMatcher getTypedMatcher(clang::ASTNodeKind NK) const
- public template <class T>ast_matchers::internal::Matcher<T> getTypedMatcher() const
- public bool hasTypedMatcher(clang::ASTNodeKind NK) const
- public template <class T>bool hasTypedMatcher() const
- public bool isConvertibleTo(clang::ASTNodeKind Kind, unsigned int * Specificity) const
- public bool isNull() const
- public void reset()
Methods
¶static clang::ast_matchers::dynamic::
VariantMatcher
PolymorphicMatcher(
std::vector<DynTypedMatcher> Matchers)
static clang::ast_matchers::dynamic::
VariantMatcher
PolymorphicMatcher(
std::vector<DynTypedMatcher> Matchers)
Description
Clones the provided matchers. They should be the result of a polymorphic matcher.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:154
Parameters
- std::vector<DynTypedMatcher> Matchers
¶static clang::ast_matchers::dynamic::
VariantMatcher
SingleMatcher(
const clang::ast_matchers::internal::
DynTypedMatcher& Matcher)
static clang::ast_matchers::dynamic::
VariantMatcher
SingleMatcher(
const clang::ast_matchers::internal::
DynTypedMatcher& Matcher)
Description
Clones the provided matcher.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:148
Parameters
- const clang::ast_matchers::internal:: DynTypedMatcher& Matcher
¶static clang::ast_matchers::dynamic::
VariantMatcher
VariadicOperatorMatcher(
DynTypedMatcher::VariadicOperator Op,
std::vector<VariantMatcher> Args)
static clang::ast_matchers::dynamic::
VariantMatcher
VariadicOperatorMatcher(
DynTypedMatcher::VariadicOperator Op,
std::vector<VariantMatcher> Args)
Description
Creates a 'variadic' operator matcher. It will bind to the appropriate type on getTypedMatcher <T >().
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:160
Parameters
- DynTypedMatcher::VariadicOperator Op
- std::vector<VariantMatcher> Args
¶VariantMatcher()
VariantMatcher()
Description
A null matcher.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:145
¶VariantMatcher(std::shared_ptr<Payload> Value)
VariantMatcher(std::shared_ptr<Payload> Value)
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:229
Parameters
- std::shared_ptr<Payload> Value
¶llvm::Optional<DynTypedMatcher> getSingleMatcher()
const
llvm::Optional<DynTypedMatcher> getSingleMatcher()
const
Description
Return a single matcher, if there is no ambiguity.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:174
Returns
the matcher, if there is only one matcher. An empty Optional, if the underlying matcher is a polymorphic matcher with more than one representation.
¶std::string getTypeAsString() const
std::string getTypeAsString() const
Description
String representation of the type of the value. If the underlying matcher is a polymorphic one, the string will show all the types.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:226
¶clang::ast_matchers::internal::DynTypedMatcher
getTypedMatcher(clang::ASTNodeKind NK) const
clang::ast_matchers::internal::DynTypedMatcher
getTypedMatcher(clang::ASTNodeKind NK) const
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:217
Parameters
¶template <class T>
ast_matchers::internal::Matcher<T>
getTypedMatcher() const
template <class T>
ast_matchers::internal::Matcher<T>
getTypedMatcher() const
Description
Return this matcher as a \c Matcher<T>. Handles the different types (Single, Polymorphic) accordingly. Asserts that \c hasTypedMatcher<T>() is true.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:211
Templates
- T
¶bool hasTypedMatcher(clang::ASTNodeKind NK) const
bool hasTypedMatcher(clang::ASTNodeKind NK) const
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:189
Parameters
¶template <class T>
bool hasTypedMatcher() const
template <class T>
bool hasTypedMatcher() const
Description
Determines if the contained matcher can be converted to\c Matcher<T>. For the Single case, it returns true if it can be converted to\c Matcher<T>. For the Polymorphic case, it returns true if one, and only one, of the overloads can be converted to \c Matcher<T>. If there are more than one that can, the result would be ambiguous and false is returned.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:185
Templates
- T
¶bool isConvertibleTo(
clang::ASTNodeKind Kind,
unsigned int* Specificity) const
bool isConvertibleTo(
clang::ASTNodeKind Kind,
unsigned int* Specificity) const
Description
Determines if the contained matcher can be converted to \p Kind.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:200
Parameters
- clang::ASTNodeKind Kind
- the requested destination type.
- unsigned int* Specificity
- value corresponding to the "specificity" of the conversion.
¶bool isNull() const
bool isNull() const
Description
Whether the matcher is null.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:167
¶void reset()
void reset()
Description
Makes the matcher the "null" matcher.
Declared at: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h:164