class CanQual
Declaration
template <typename T = clang::Type>
class CanQual { /* full declaration omitted */ };
Description
Represents a canonical, potentially-qualified type. The CanQual template is a lightweight smart pointer that provides access to the canonical representation of a type, where all typedefs and other syntactic sugar has been eliminated. A CanQualType may also have various qualifiers (const, volatile, restrict) attached to it. The template type parameter @p T is one of the Type classes (PointerType, BuiltinType, etc.). The type stored within @c CanQual<T> will be of that type (or some subclass of that type). The typedef @c CanQualType is just a shorthand for @c CanQual<Type>. An instance of @c CanQual<T> can be implicitly converted to a@c CanQual<U> when T is derived from U, which essentially provides an implicit upcast. For example, @c CanQual<LValueReferenceType> can be converted to @c CanQual<ReferenceType>. Note that any @c CanQual type can be implicitly converted to a QualType, but the reverse operation requires a call to ASTContext::getCanonicalType().
Declared at: clang/include/clang/AST/CanonicalType.h:65
Templates
- T = clang::Type
Member Variables
- private clang::QualType Stored
- The actual, canonical type.
Method Overview
- public CanQual<type-parameter-0-0>()
- public template <typename U> CanQual<type-parameter-0-0>(const CanQual<U> & Other, std::enable_if_t<std::is_base_of<T, U>::value, int> = 0)
- public static CanQual<T> CreateUnsafe(clang::QualType Other)
- public void Profile(llvm::FoldingSetNodeID & ID) const
- public template <typename U>CanProxy<U> castAs() const
- public void dump() const
- public template <typename U>CanProxy<U> getAs() const
- public void * getAsOpaquePtr() const
- public unsigned int getCVRQualifiers() const
- public static CanQual<T> getFromOpaquePtr(void * Ptr)
- public CanQual<clang::Type> getNonReferenceType() const
- public clang::Qualifiers getQualifiers() const
- public const T * getTypePtr() const
- public const T * getTypePtrOrNull() const
- public CanQual<T> getUnqualifiedType() const
- public bool hasQualifiers() const
- public bool isAtLeastAsQualifiedAs(CanQual<T> Other) const
- public bool isCanonicalAsParam() const
- public bool isConstQualified() const
- public bool isMoreQualifiedThan(CanQual<T> Other) const
- public bool isNull() const
- public bool isRestrictQualified() const
- public bool isVolatileQualified() const
- public clang::QualType operator QualType() const
- public bool operator bool() const
- public clang::SplitQualType split() const
- public clang::QualType withConst() const
Methods
¶CanQual<type - parameter - 0 - 0>()
CanQual<type - parameter - 0 - 0>()
Description
Constructs a NULL canonical type.
Declared at: clang/include/clang/AST/CanonicalType.h:71
¶template <typename U>
CanQual<type - parameter - 0 - 0>(
const CanQual<U>& Other,
std::enable_if_t<std::is_base_of<T, U>::value,
int> = 0)
template <typename U>
CanQual<type - parameter - 0 - 0>(
const CanQual<U>& Other,
std::enable_if_t<std::is_base_of<T, U>::value,
int> = 0)
Description
Converting constructor that permits implicit upcasting of canonical type pointers.
Declared at: clang/include/clang/AST/CanonicalType.h:76
Templates
- U
Parameters
- const CanQual<U>& Other
- std::enable_if_t<std::is_base_of<T, U>::value, int> = 0
¶static CanQual<T> CreateUnsafe(
clang::QualType Other)
static CanQual<T> CreateUnsafe(
clang::QualType Other)
Description
Builds a canonical type from a QualType. This routine is inherently unsafe, because it requires the user to ensure that the given type is a canonical type with the correct
Declared at: clang/include/clang/AST/CanonicalType.h:192
Parameters
- clang::QualType Other
¶void Profile(llvm::FoldingSetNodeID& ID) const
void Profile(llvm::FoldingSetNodeID& ID) const
Declared at: clang/include/clang/AST/CanonicalType.h:196
Parameters
¶template <typename U>
CanProxy<U> castAs() const
template <typename U>
CanProxy<U> castAs() const
Declared at: clang/include/clang/AST/CanonicalType.h:122
Templates
- U
¶void dump() const
void dump() const
Declared at: clang/include/clang/AST/CanonicalType.h:194
¶template <typename U>
CanProxy<U> getAs() const
template <typename U>
CanProxy<U> getAs() const
Description
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed. The getAs() function is typically used to try to downcast to a more specific (canonical) type in the type system. For example:
Declared at: clang/include/clang/AST/CanonicalType.h:120
Templates
- U
Returns
A proxy pointer to the same type, but with the specified static type (@p U). If the dynamic type is not the specified static type or a derived class thereof, a NULL canonical type.
¶void* getAsOpaquePtr() const
void* getAsOpaquePtr() const
Description
Retrieve the internal representation of this canonical type.
Declared at: clang/include/clang/AST/CanonicalType.h:182
¶unsigned int getCVRQualifiers() const
unsigned int getCVRQualifiers() const
Description
Retrieve the const/volatile/restrict qualifiers.
Declared at: clang/include/clang/AST/CanonicalType.h:132
¶static CanQual<T> getFromOpaquePtr(void* Ptr)
static CanQual<T> getFromOpaquePtr(void* Ptr)
Description
Construct a canonical type from its internal representation.
Declared at: clang/include/clang/AST/CanonicalType.h:185
Parameters
- void* Ptr
¶CanQual<clang::Type> getNonReferenceType() const
CanQual<clang::Type> getNonReferenceType() const
Description
If the canonical type is a reference type, returns the type that it refers to; otherwise, returns the type itself.
Declared at: clang/include/clang/AST/CanonicalType.h:179
¶clang::Qualifiers getQualifiers() const
clang::Qualifiers getQualifiers() const
Description
Retrieve all qualifiers.
Declared at: clang/include/clang/AST/CanonicalType.h:129
¶const T* getTypePtr() const
const T* getTypePtr() const
Description
Retrieve the underlying type pointer, which refers to a canonical type. The underlying pointer must not be nullptr.
Declared at: clang/include/clang/AST/CanonicalType.h:83
¶const T* getTypePtrOrNull() const
const T* getTypePtrOrNull() const
Description
Retrieve the underlying type pointer, which refers to a canonical type, or nullptr.
Declared at: clang/include/clang/AST/CanonicalType.h:87
¶CanQual<T> getUnqualifiedType() const
CanQual<T> getUnqualifiedType() const
Description
Retrieve the unqualified form of this type.
Declared at: clang/include/clang/AST/CanonicalType.h:157
¶bool hasQualifiers() const
bool hasQualifiers() const
Description
Determines whether this type has any qualifiers
Declared at: clang/include/clang/AST/CanonicalType.h:135
¶bool isAtLeastAsQualifiedAs(
CanQual<T> Other) const
bool isAtLeastAsQualifiedAs(
CanQual<T> Other) const
Description
Determines whether this canonical type is at least as qualified as the @p Other canonical type.
Declared at: clang/include/clang/AST/CanonicalType.h:173
Parameters
- CanQual<T> Other
¶bool isCanonicalAsParam() const
bool isCanonicalAsParam() const
Description
Determines if this canonical type is furthermore canonical as a parameter. The parameter-canonicalization process decays arrays to pointers and drops top-level qualifiers.
Declared at: clang/include/clang/AST/CanonicalType.h:152
¶bool isConstQualified() const
bool isConstQualified() const
Declared at: clang/include/clang/AST/CanonicalType.h:137
¶bool isMoreQualifiedThan(CanQual<T> Other) const
bool isMoreQualifiedThan(CanQual<T> Other) const
Description
Determines whether this canonical type is more qualified than the @p Other canonical type.
Declared at: clang/include/clang/AST/CanonicalType.h:167
Parameters
- CanQual<T> Other
¶bool isNull() const
bool isNull() const
Declared at: clang/include/clang/AST/CanonicalType.h:97
¶bool isRestrictQualified() const
bool isRestrictQualified() const
Declared at: clang/include/clang/AST/CanonicalType.h:145
¶bool isVolatileQualified() const
bool isVolatileQualified() const
Declared at: clang/include/clang/AST/CanonicalType.h:141
¶clang::QualType operator QualType() const
clang::QualType operator QualType() const
Description
Implicit conversion to a qualified type.
Declared at: clang/include/clang/AST/CanonicalType.h:92
¶bool operator bool() const
bool operator bool() const
Description
Implicit conversion to bool.
Declared at: clang/include/clang/AST/CanonicalType.h:95
¶clang::SplitQualType split() const
clang::SplitQualType split() const
Declared at: clang/include/clang/AST/CanonicalType.h:101
¶clang::QualType withConst() const
clang::QualType withConst() const
Description
Retrieves a version of this type with const applied. Note that this does not always yield a canonical type.
Declared at: clang/include/clang/AST/CanonicalType.h:161