clang  16.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
clang::ASTNodeKind Class Reference

Kind identifier. More...

#include "clang/AST/ASTTypeTraits.h"

Classes

struct  DenseMapInfo
 Hooks for using ASTNodeKind as a key in a DenseMap. More...
 

Public Member Functions

constexpr ASTNodeKind ()
 Empty identifier. It matches nothing. More...
 
constexpr bool isSame (ASTNodeKind Other) const
 Returns true if this and Other represent the same kind. More...
 
constexpr bool isNone () const
 Returns true only for the default ASTNodeKind() More...
 
bool isBaseOf (ASTNodeKind Other, unsigned *Distance=nullptr) const
 Returns true if this is a base kind of (or same as) Other. More...
 
StringRef asStringRef () const
 String representation of the kind. More...
 
constexpr bool operator< (const ASTNodeKind &Other) const
 Strict weak ordering for ASTNodeKind. More...
 
ASTNodeKind getCladeKind () const
 
constexpr bool hasPointerIdentity () const
 Check if the given ASTNodeKind identifies a type that offers pointer identity. More...
 

Static Public Member Functions

template<class T >
static constexpr ASTNodeKind getFromNodeKind ()
 Construct an identifier for T. More...
 
static ASTNodeKind getMostDerivedType (ASTNodeKind Kind1, ASTNodeKind Kind2)
 Return the most derived type between Kind1 and Kind2. More...
 
static ASTNodeKind getMostDerivedCommonAncestor (ASTNodeKind Kind1, ASTNodeKind Kind2)
 Return the most derived common ancestor between Kind1 and Kind2. More...
 
static ASTNodeKind getFromNode (const Decl &D)
 
static ASTNodeKind getFromNode (const Stmt &S)
 
static ASTNodeKind getFromNode (const Type &T)
 
static ASTNodeKind getFromNode (const TypeLoc &T)
 
static ASTNodeKind getFromNode (const LambdaCapture &L)
 
static ASTNodeKind getFromNode (const OMPClause &C)
 
static ASTNodeKind getFromNode (const Attr &A)
 

Detailed Description

Kind identifier.

It can be constructed from any node kind and allows for runtime type hierarchy checks. Use getFromNodeKind<T>() to construct them.

Definition at line 51 of file ASTTypeTraits.h.

Constructor & Destructor Documentation

◆ ASTNodeKind()

constexpr clang::ASTNodeKind::ASTNodeKind ( )
inlineconstexpr

Member Function Documentation

◆ asStringRef()

StringRef ASTNodeKind::asStringRef ( ) const

◆ getCladeKind()

ASTNodeKind ASTNodeKind::getCladeKind ( ) const

◆ getFromNode() [1/7]

ASTNodeKind ASTNodeKind::getFromNode ( const Attr A)
static

Definition at line 161 of file ASTTypeTraits.cpp.

References clang::Attr::getKind().

◆ getFromNode() [2/7]

ASTNodeKind ASTNodeKind::getFromNode ( const Decl D)
static

Construct an identifier for the dynamic type of the node

Definition at line 105 of file ASTTypeTraits.cpp.

References clang::Decl::getKind().

◆ getFromNode() [3/7]

static ASTNodeKind clang::ASTNodeKind::getFromNode ( const LambdaCapture L)
static

◆ getFromNode() [4/7]

ASTNodeKind ASTNodeKind::getFromNode ( const OMPClause C)
static

Definition at line 147 of file ASTTypeTraits.cpp.

◆ getFromNode() [5/7]

ASTNodeKind ASTNodeKind::getFromNode ( const Stmt S)
static

Definition at line 115 of file ASTTypeTraits.cpp.

◆ getFromNode() [6/7]

ASTNodeKind ASTNodeKind::getFromNode ( const Type T)
static

Definition at line 126 of file ASTTypeTraits.cpp.

References clang::Type::getTypeClass().

◆ getFromNode() [7/7]

ASTNodeKind ASTNodeKind::getFromNode ( const TypeLoc T)
static

Definition at line 136 of file ASTTypeTraits.cpp.

References clang::TypeLoc::getTypeLocClass().

◆ getFromNodeKind()

template<class T >
static constexpr ASTNodeKind clang::ASTNodeKind::getFromNodeKind ( )
inlinestaticconstexpr

Construct an identifier for T.

Definition at line 57 of file ASTTypeTraits.h.

References ASTNodeKind(), and Id.

◆ getMostDerivedCommonAncestor()

ASTNodeKind ASTNodeKind::getMostDerivedCommonAncestor ( ASTNodeKind  Kind1,
ASTNodeKind  Kind2 
)
static

Return the most derived common ancestor between Kind1 and Kind2.

Return ASTNodeKind() if they are not related.

Definition at line 96 of file ASTTypeTraits.cpp.

References ASTNodeKind(), isBaseOf(), and Parent.

◆ getMostDerivedType()

ASTNodeKind ASTNodeKind::getMostDerivedType ( ASTNodeKind  Kind1,
ASTNodeKind  Kind2 
)
static

Return the most derived type between Kind1 and Kind2.

Return ASTNodeKind() if they are not related.

Definition at line 89 of file ASTTypeTraits.cpp.

References ASTNodeKind(), and isBaseOf().

◆ hasPointerIdentity()

constexpr bool clang::ASTNodeKind::hasPointerIdentity ( ) const
inlineconstexpr

Check if the given ASTNodeKind identifies a type that offers pointer identity.

This is useful for the fast path in DynTypedNode.

Definition at line 123 of file ASTTypeTraits.h.

Referenced by clang::DynTypedNode::getMemoizationData().

◆ isBaseOf()

bool ASTNodeKind::isBaseOf ( ASTNodeKind  Other,
unsigned Distance = nullptr 
) const

Returns true if this is a base kind of (or same as) Other.

Parameters
DistanceIf non-null, used to return the distance between this and Other in the class hierarchy.

Definition at line 59 of file ASTTypeTraits.cpp.

Referenced by getMostDerivedCommonAncestor(), getMostDerivedType(), and clang::ast_matchers::dynamic::ArgKind::isConvertibleTo().

◆ isNone()

constexpr bool clang::ASTNodeKind::isNone ( ) const
inlineconstexpr

Returns true only for the default ASTNodeKind()

Definition at line 78 of file ASTTypeTraits.h.

◆ isSame()

constexpr bool clang::ASTNodeKind::isSame ( ASTNodeKind  Other) const
inlineconstexpr

Returns true if this and Other represent the same kind.

Definition at line 73 of file ASTTypeTraits.h.

Referenced by clang::diff::ComparisonOptions::isMatchingAllowed(), clang::DynTypedNode::operator<(), and clang::DynTypedNode::operator==().

◆ operator<()

constexpr bool clang::ASTNodeKind::operator< ( const ASTNodeKind Other) const
inlineconstexpr

Strict weak ordering for ASTNodeKind.

Definition at line 89 of file ASTTypeTraits.h.


The documentation for this class was generated from the following files: