clang 20.0.0git
|
Represents a canonical, potentially-qualified type. More...
#include "clang/AST/CanonicalType.h"
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 T * | getTypePtr () const |
Retrieve the underlying type pointer, which refers to a canonical type. | |
const T * | getTypePtrOrNull () 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< U > | getAs () const |
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed. | |
template<typename U > | |
CanProxy< U > | castAs () const |
CanProxy< T > | operator-> () 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< T > | getUnqualifiedType () 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< Type > | getNonReferenceType () 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< T > | getFromOpaquePtr (void *Ptr) |
Construct a canonical type from its internal representation. | |
static CanQual< T > | CreateUnsafe (QualType Other) |
Builds a canonical type from a QualType. | |
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.
|
default |
Constructs a NULL canonical type.
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.
Definition at line 667 of file CanonicalType.h.
References clang::CanQual< T >::CreateUnsafe(), clang::CanQual< T >::getTypePtr(), clang::CanQual< T >::isNull(), and clang::CanProxyBase< T >::Stored.
Referenced by clang::CodeGen::CodeGenTypes::arrangeFunctionDeclaration(), clang::CodeGen::CodeGenModule::ConstructAttributeList(), emitReduceInitFunction(), and clang::Sema::IsFunctionConversion().
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().
|
inline |
Definition at line 194 of file CanonicalType.h.
References clang::QualType::dump().
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:
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().
|
inline |
Retrieve the internal representation of this canonical type.
Definition at line 182 of file CanonicalType.h.
References clang::QualType::getAsOpaquePtr().
Referenced by clang::DeclarationNameTable::getCXXConstructorName(), clang::DeclarationNameTable::getCXXConversionFunctionName(), clang::DeclarationNameTable::getCXXDestructorName(), llvm::DenseMapInfo< clang::CanQualType >::getHashValue(), clang::operator!=(), clang::operator==(), and clang::CanQual< T >::Profile().
|
inline |
Retrieve the const/volatile/restrict qualifiers.
Definition at line 132 of file CanonicalType.h.
References clang::QualType::getLocalCVRQualifiers().
Referenced by clang::CXXConstructorDecl::isCopyOrMoveConstructor().
|
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().
|
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().
|
inline |
Retrieve all qualifiers.
Definition at line 129 of file CanonicalType.h.
References clang::QualType::getLocalQualifiers().
Referenced by clang::Sema::BuildFieldReferenceExpr(), DiagnoseBadConversion(), clang::ASTContext::getCanonicalFunctionResultType(), clang::ASTContext::InitBuiltinTypes(), InitCatchParam(), IsModifiable(), LookupMemberExpr(), and MightInstantiateTo().
|
inline |
Retrieve the underlying type pointer, which refers to a canonical type.
The underlying pointer must not be nullptr.
Definition at line 83 of file CanonicalType.h.
References clang::QualType::getTypePtr().
Referenced by clang::Sema::ActOnTag(), appendParameterTypes(), clang::CodeGen::CodeGenTypes::arrangeCXXConstructorCall(), clang::CanQual< T >::castAs(), clang::Sema::CheckImplicitConversion(), clang::CodeGen::CodeGenModule::ConstructAttributeList(), clang::CodeGen::CodeGenTypes::ConvertTypeForMem(), clang::CodeGen::RequiredArgs::forPrototype(), clang::CodeGen::RequiredArgs::forPrototypePlus(), clang::CanQual< T >::getAs(), clang::ASTContext::getIntegerTypeOrder(), GetKeyForBase(), clang::CodeGen::CGOpenCLRuntime::getSamplerType(), llvm::simplify_type< ::clang::CanQual< T > >::getSimplifiedValue(), clang::CodeGen::CodeGenTBAA::getTBAAStructInfo(), clang::CodeGen::CodeGenTBAA::getTypeInfo(), clang::CanProxyBase< T >::getTypePtr(), clang::ASTContext::hasSameUnqualifiedType(), IsImplicitBoolFloatConversion(), and matchTypes().
|
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 *().
|
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().
|
inline |
Determines whether this type has any qualifiers.
Definition at line 135 of file CanonicalType.h.
References clang::QualType::hasLocalQualifiers().
|
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().
|
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().
|
inline |
Definition at line 137 of file CanonicalType.h.
References clang::QualType::isLocalConstQualified().
Referenced by IsModifiable(), and clang::cross_tu::shouldImport().
|
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.
|
inline |
Definition at line 97 of file CanonicalType.h.
References clang::QualType::isNull().
Referenced by clang::CanQual< T >::castAs(), clang::CanQual< T >::getAs(), clang::ASTContext::InitBuiltinTypes(), and clang::CanQual< T >::operator bool().
|
inline |
Definition at line 145 of file CanonicalType.h.
References clang::QualType::isLocalRestrictQualified().
|
inline |
Definition at line 141 of file CanonicalType.h.
References clang::QualType::isLocalVolatileQualified().
Referenced by AddBuiltinAssignmentOperatorCandidates(), and clang::Expr::isUnusedResultAWarning().
|
inlineexplicit |
Implicit conversion to bool.
Definition at line 95 of file CanonicalType.h.
References clang::CanQual< T >::isNull().
|
inline |
Implicit conversion to a qualified type.
Definition at line 92 of file CanonicalType.h.
CanProxy< T > clang::CanQual< T >::operator-> |
Overloaded arrow operator that produces a canonical type proxy.
Definition at line 676 of file CanonicalType.h.
|
inline |
Definition at line 196 of file CanonicalType.h.
References clang::CanQual< T >::getAsOpaquePtr(), and ID.
Referenced by clang::CodeGen::CGFunctionInfo::Profile().
|
inline |
Definition at line 101 of file CanonicalType.h.
References clang::QualType::split().
Referenced by clang::ASTContext::getConstantArrayType(), clang::ASTContext::getDependentSizedArrayType(), clang::ASTContext::getIncompleteArrayType(), and clang::ASTContext::getVariableArrayType().
|
inline |
Retrieves a version of this type with const applied.
Note that this does not always yield a canonical type.
Definition at line 161 of file CanonicalType.h.
References clang::QualType::withConst().
Referenced by clang::Sema::ActOnIndirectGotoStmt(), clang::Sema::ActOnNumericConstant(), clang::SemaObjC::BuildObjCBoxedExpr(), clang::Sema::BuildPredefinedExpr(), clang::SYCLUniqueStableNameExpr::Create(), clang::SYCLUniqueStableNameExpr::CreateEmpty(), clang::ASTContext::getCFConstantStringDecl(), getParallelRegionParams(), getTargetRegionParams(), getTaskloopRegionParams(), getTaskRegionParams(), and LookupStdSourceLocationImpl().