clang 20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
clang::CanQual< T > Class Template Reference

Represents a canonical, potentially-qualified type. More...

#include "clang/AST/CanonicalType.h"

Inheritance diagram for clang::CanQual< T >:
Inheritance graph
[legend]

Public Member Functions

 CanQual ()=default
 Constructs a NULL canonical type.
 
template<typename U >
 CanQual (const CanQual< U > &Other, std::enable_if_t< std::is_base_of< T, U >::value, int >=0)
 Converting constructor that permits implicit upcasting of canonical type pointers.
 
const TgetTypePtr () const
 Retrieve the underlying type pointer, which refers to a canonical type.
 
const TgetTypePtrOrNull () const
 Retrieve the underlying type pointer, which refers to a canonical type, or nullptr.
 
 operator QualType () const
 Implicit conversion to a qualified type.
 
 operator bool () const
 Implicit conversion to bool.
 
bool isNull () const
 
SplitQualType split () const
 
template<typename U >
CanProxy< UgetAs () const
 Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
 
template<typename U >
CanProxy< UcastAs () const
 
CanProxy< Toperator-> () const
 Overloaded arrow operator that produces a canonical type proxy.
 
Qualifiers getQualifiers () const
 Retrieve all qualifiers.
 
unsigned getCVRQualifiers () const
 Retrieve the const/volatile/restrict qualifiers.
 
bool hasQualifiers () const
 Determines whether this type has any qualifiers.
 
bool isConstQualified () const
 
bool isVolatileQualified () const
 
bool isRestrictQualified () const
 
bool isCanonicalAsParam () const
 Determines if this canonical type is furthermore canonical as a parameter.
 
CanQual< TgetUnqualifiedType () const
 Retrieve the unqualified form of this type.
 
QualType withConst () const
 Retrieves a version of this type with const applied.
 
bool isMoreQualifiedThan (CanQual< T > Other) const
 Determines whether this canonical type is more qualified than the Other canonical type.
 
bool isAtLeastAsQualifiedAs (CanQual< T > Other) const
 Determines whether this canonical type is at least as qualified as the Other canonical type.
 
CanQual< TypegetNonReferenceType () const
 If the canonical type is a reference type, returns the type that it refers to; otherwise, returns the type itself.
 
void * getAsOpaquePtr () const
 Retrieve the internal representation of this canonical type.
 
void dump () const
 
void Profile (llvm::FoldingSetNodeID &ID) const
 

Static Public Member Functions

static CanQual< TgetFromOpaquePtr (void *Ptr)
 Construct a canonical type from its internal representation.
 
static CanQual< TCreateUnsafe (QualType Other)
 Builds a canonical type from a QualType.
 

Detailed Description

template<typename T = Type>
class clang::CanQual< T >

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 T is one of the Type classes (PointerType, BuiltinType, etc.). The type stored within CanQual<T> will be of that type (or some subclass of that type). The typedef CanQualType is just a shorthand for CanQual<Type>.

An instance of CanQual<T> can be implicitly converted to a CanQual when T is derived from U, which essentially provides an implicit upcast. For example, CanQual<LValueReferenceType> can be converted to CanQual<ReferenceType>. Note that any CanQual type can be implicitly converted to a QualType, but the reverse operation requires a call to ASTContext::getCanonicalType().

Definition at line 65 of file CanonicalType.h.

Constructor & Destructor Documentation

◆ CanQual() [1/2]

template<typename T = Type>
clang::CanQual< T >::CanQual ( )
default

Constructs a NULL canonical type.

◆ CanQual() [2/2]

template<typename T = Type>
template<typename U >
clang::CanQual< T >::CanQual ( const CanQual< U > &  Other,
std::enable_if_t< std::is_base_of< T, U >::value, int = 0 
)

Converting constructor that permits implicit upcasting of canonical type pointers.

Member Function Documentation

◆ castAs()

template<typename T >
template<typename U >
CanProxy< U > clang::CanQual< T >::castAs

◆ CreateUnsafe()

template<typename T >
CanQual< T > clang::CanQual< T >::CreateUnsafe ( QualType  Other)
static

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

Definition at line 641 of file CanonicalType.h.

References clang::Other, and clang::Result.

Referenced by clang::CanQual< T >::castAs(), and clang::CanQual< T >::getUnqualifiedType().

◆ dump()

template<typename T = Type>
void clang::CanQual< T >::dump ( ) const
inline

Definition at line 194 of file CanonicalType.h.

References clang::QualType::dump().

◆ getAs()

template<typename T >
template<typename U >
CanProxy< U > clang::CanQual< T >::getAs

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:

void f(CanQual<Type> T) {
// look at Ptr's pointee type
}
}
Represents a canonical, potentially-qualified type.
Definition: CanonicalType.h:65
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:3192
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8545
const FunctionProtoType * T
Returns
A proxy pointer to the same type, but with the specified static type (U). If the dynamic type is not the specified static type or a derived class thereof, a NULL canonical type.

Definition at line 652 of file CanonicalType.h.

References clang::CanQual< T >::getTypePtr(), clang::CanQual< T >::isNull(), and clang::CanProxyBase< T >::Stored.

Referenced by clang::CodeGen::CodeGenTypes::arrangeCXXMethodDeclaration(), clang::CodeGen::CodeGenTypes::arrangeCXXMethodType(), clang::CodeGen::CodeGenTypes::arrangeFunctionDeclaration(), CheckOperatorNewDeleteTypes(), DiagnoseBadConversion(), GetFormalType(), IsModifiable(), MightInstantiateTo(), setCUDAKernelCallingConvention(), and TryStaticDowncast().

◆ getAsOpaquePtr()

template<typename T = Type>
void * clang::CanQual< T >::getAsOpaquePtr ( ) const
inline

◆ getCVRQualifiers()

template<typename T = Type>
unsigned clang::CanQual< T >::getCVRQualifiers ( ) const
inline

Retrieve the const/volatile/restrict qualifiers.

Definition at line 132 of file CanonicalType.h.

References clang::QualType::getLocalCVRQualifiers().

Referenced by clang::CXXConstructorDecl::isCopyOrMoveConstructor().

◆ getFromOpaquePtr()

template<typename T >
CanQual< T > clang::CanQual< T >::getFromOpaquePtr ( void *  Ptr)
static

Construct a canonical type from its internal representation.

Definition at line 632 of file CanonicalType.h.

References clang::QualType::getFromOpaquePtr(), and clang::Result.

Referenced by llvm::PointerLikeTypeTraits< clang::CanQual< T > >::getFromVoidPointer().

◆ getNonReferenceType()

template<typename T >
CanQual< Type > clang::CanQual< T >::getNonReferenceType
inline

If the canonical type is a reference type, returns the type that it refers to; otherwise, returns the type itself.

Definition at line 624 of file CanonicalType.h.

Referenced by clang::ConversionFixItGenerator::compareTypesSimple().

◆ getQualifiers()

template<typename T = Type>
Qualifiers clang::CanQual< T >::getQualifiers ( ) const
inline

◆ getTypePtr()

template<typename T = Type>
const T * clang::CanQual< T >::getTypePtr ( ) const
inline

◆ getTypePtrOrNull()

template<typename T = Type>
const T * clang::CanQual< T >::getTypePtrOrNull ( ) const
inline

Retrieve the underlying type pointer, which refers to a canonical type, or nullptr.

Definition at line 87 of file CanonicalType.h.

References clang::QualType::getTypePtrOrNull().

Referenced by clang::CanProxyBase< BlockPointerType >::operator const BlockPointerType *().

◆ getUnqualifiedType()

template<typename T >
CanQual< T > clang::CanQual< T >::getUnqualifiedType
inline

Retrieve the unqualified form of this type.

Definition at line 619 of file CanonicalType.h.

References clang::CanQual< T >::CreateUnsafe(), and clang::CanProxyBase< T >::Stored.

Referenced by clang::Sema::ActOnConversionDeclarator(), clang::SemaObjC::ActOnPropertyImplDecl(), clang::Sema::AddConversionCandidate(), clang::CodeGen::CodeGenTypes::arrangeFreeFunctionType(), arrangeLLVMFunctionInfo(), clang::Sema::AttachBaseSpecifiers(), clang::Sema::CheckAssignmentConstraints(), clang::Sema::CheckConstructor(), clang::Sema::CheckDerivedToBaseConversion(), clang::CheckEquivalentExceptionSpecImpl(), clang::SemaObjC::CheckObjCARCUnavailableWeakConversion(), CheckOperatorNewDeleteTypes(), clang::Sema::CheckPtrComparisonWithNullChar(), clang::Sema::CheckSubtractionOperands(), clang::ConversionFixItGenerator::compareTypesSimple(), DiagnoseBadConversion(), clang::SemaObjC::DiagnosePropertyAccessorMismatch(), clang::Sema::ExtractUnqualifiedFunctionType(), findDirectBaseWithType(), clang::ASTContext::getCanonicalFunctionResultType(), clang::DeclarationNameTable::getCXXConstructorName(), clang::DeclarationNameTable::getCXXDestructorName(), clang::ento::MemRegionManager::getElementRegion(), GetReturnType(), clang::ASTContext::InitBuiltinTypes(), clang::CXXBasePaths::isAmbiguous(), clang::CXXConstructorDecl::isCopyOrMoveConstructor(), clang::CXXConstructorDecl::isSpecializationCopyingObject(), IsStringInit(), matchTypes(), clang::ASTContext::mergeFunctionTypes(), NoteIndirectBases(), OpenCLArithmeticConversions(), TryStaticDowncast(), and TryUserDefinedConversion().

◆ hasQualifiers()

template<typename T = Type>
bool clang::CanQual< T >::hasQualifiers ( ) const
inline

Determines whether this type has any qualifiers.

Definition at line 135 of file CanonicalType.h.

References clang::QualType::hasLocalQualifiers().

◆ isAtLeastAsQualifiedAs()

template<typename T = Type>
bool clang::CanQual< T >::isAtLeastAsQualifiedAs ( CanQual< T Other) const
inline

Determines whether this canonical type is at least as qualified as the Other canonical type.

Definition at line 173 of file CanonicalType.h.

References clang::QualType::isAtLeastAsQualifiedAs(), and clang::Other.

Referenced by clang::ConversionFixItGenerator::compareTypesSimple(), DiagnoseBadConversion(), and TryStaticDowncast().

◆ isCanonicalAsParam()

template<typename T = Type>
bool clang::CanQual< T >::isCanonicalAsParam ( ) const
inline

Determines if this canonical type is furthermore canonical as a parameter.

The parameter-canonicalization process decays arrays to pointers and drops top-level qualifiers.

Definition at line 152 of file CanonicalType.h.

References clang::QualType::isCanonicalAsParam().

◆ isConstQualified()

template<typename T = Type>
bool clang::CanQual< T >::isConstQualified ( ) const
inline

◆ isMoreQualifiedThan()

template<typename T = Type>
bool clang::CanQual< T >::isMoreQualifiedThan ( CanQual< T Other) const
inline

Determines whether this canonical type is more qualified than the Other canonical type.

Definition at line 167 of file CanonicalType.h.

References clang::QualType::isMoreQualifiedThan(), and clang::Other.

◆ isNull()

template<typename T = Type>
bool clang::CanQual< T >::isNull ( ) const
inline

◆ isRestrictQualified()

template<typename T = Type>
bool clang::CanQual< T >::isRestrictQualified ( ) const
inline

Definition at line 145 of file CanonicalType.h.

References clang::QualType::isLocalRestrictQualified().

◆ isVolatileQualified()

template<typename T = Type>
bool clang::CanQual< T >::isVolatileQualified ( ) const
inline

◆ operator bool()

template<typename T = Type>
clang::CanQual< T >::operator bool ( ) const
inlineexplicit

Implicit conversion to bool.

Definition at line 95 of file CanonicalType.h.

References clang::CanQual< T >::isNull().

◆ operator QualType()

template<typename T = Type>
clang::CanQual< T >::operator QualType ( ) const
inline

Implicit conversion to a qualified type.

Definition at line 92 of file CanonicalType.h.

◆ operator->()

template<typename T >
CanProxy< T > clang::CanQual< T >::operator->

Overloaded arrow operator that produces a canonical type proxy.

Definition at line 676 of file CanonicalType.h.

◆ Profile()

template<typename T = Type>
void clang::CanQual< T >::Profile ( llvm::FoldingSetNodeID &  ID) const
inline

Definition at line 196 of file CanonicalType.h.

References clang::CanQual< T >::getAsOpaquePtr(), and ID.

Referenced by clang::CodeGen::CGFunctionInfo::Profile().

◆ split()

template<typename T = Type>
SplitQualType clang::CanQual< T >::split ( ) const
inline

◆ withConst()

template<typename T = Type>
QualType clang::CanQual< T >::withConst ( ) const
inline

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