Go to the documentation of this file.
17 #ifndef LLVM_CLANG_ASTMATCHERS_DYNAMIC_VARIANTVALUE_H
18 #define LLVM_CLANG_ASTMATCHERS_DYNAMIC_VARIANTVALUE_H
22 #include "llvm/ADT/IntrusiveRefCntPtr.h"
23 #include "llvm/ADT/Optional.h"
28 namespace ast_matchers {
77 return NodeKind < Other.NodeKind;
90 using ast_matchers::internal::DynTypedMatcher;
111 bool canConstructFrom(
const DynTypedMatcher &Matcher,
112 bool &IsExactMatch)
const;
116 DynTypedMatcher convertMatcher(
const DynTypedMatcher &Matcher)
const;
122 constructVariadicOperator(DynTypedMatcher::VariadicOperator Op,
140 unsigned *Specificity)
const = 0;
161 std::vector<VariantMatcher> Args);
190 if (!
Value)
return false;
191 return Value->getTypedMatcher(MatcherOps(NK)).has_value();
202 return Value->isConvertibleTo(
Kind, Specificity);
212 assert(hasTypedMatcher<T>() &&
"hasTypedMatcher<T>() == false");
213 return Value->getTypedMatcher(MatcherOps(ASTNodeKind::getFromNodeKind<T>()))
214 ->template convertTo<T>();
219 return *
Value->getTypedMatcher(MatcherOps(NK));
234 class PolymorphicPayload;
235 class VariadicOpPayload;
237 std::shared_ptr<const Payload>
Value;
347 VariantMatcher *Matcher;
359 #endif // LLVM_CLANG_ASTMATCHERS_DYNAMIC_VARIANTVALUE_H
void setMatcher(const VariantMatcher &Matcher)
ASTNodeKind getNodeKind() const
bool isNull() const
Whether the matcher is null.
ArgKind(Kind K)
Constructor for non-matcher types.
std::string getTypeAsString() const
String representation of the type of the value.
VariantValue(int Signed)
Constructs an unsigned value (disambiguation from bool).
std::string asString() const
String representation of the type.
bool hasTypedMatcher() const
Determines if the contained matcher can be converted to Matcher<T>.
static VariantMatcher VariadicOperatorMatcher(DynTypedMatcher::VariadicOperator Op, std::vector< VariantMatcher > Args)
Creates a 'variadic' operator matcher.
bool isUnsigned() const
Unsigned value functions.
VariantMatcher()
A null matcher.
std::string getTypeAsString() const
String representation of the type of the value.
The base class of the type hierarchy.
void setString(StringRef String)
bool operator<(const ArgKind &Other) const
const std::string & getString() const
bool hasTypedMatcher(ASTNodeKind NK) const
llvm::Optional< DynTypedMatcher > getSingleMatcher() const
Return a single matcher, if there is no ambiguity.
void setNodeKind(ASTNodeKind NodeKind)
bool isConvertibleTo(ArgKind Kind, unsigned *Specificity) const
Determines if the contained value can be converted to Kind.
bool isString() const
String value functions.
void reset()
Makes the matcher the "null" matcher.
const VariantMatcher & getMatcher() const
bool isDouble() const
Double value functions.
A variant matcher object.
unsigned getUnsigned() const
void setUnsigned(unsigned Unsigned)
bool isMatcher() const
Matcher value functions.
static VariantMatcher PolymorphicMatcher(std::vector< DynTypedMatcher > Matchers)
Clones the provided matchers.
ast_matchers::internal::Matcher< T > getTypedMatcher() const
Return this matcher as a Matcher<T>.
VariantValue & operator=(const VariantValue &Other)
NodeKind
A kind of a syntax node, used for implementing casts.
bool isBoolean() const
Boolean value functions.
DynTypedMatcher getTypedMatcher(ASTNodeKind NK) const
bool isConvertibleTo(ArgKind To, unsigned *Specificity) const
Determines if this type can be converted to To.
void setDouble(double Double)
const ASTNodeKind & getNodeKind() const
static ArgKind MakeNodeArg(ASTNodeKind MatcherKind)
static VariantMatcher SingleMatcher(const DynTypedMatcher &Matcher)
Clones the provided matcher.
static ArgKind MakeMatcherArg(ASTNodeKind MatcherKind)
Constructor for matcher types.
ASTNodeKind getMatcherKind() const
void setBoolean(bool Boolean)
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity) const
Determines if the contained matcher can be converted to Kind.