clang 24.0.0git
Type.cpp File Reference
#include "clang/AST/Type.h"
#include "Linkage.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclFriend.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DependenceFlags.h"
#include "clang/AST/Expr.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/TemplateBase.h"
#include "clang/AST/TemplateName.h"
#include "clang/AST/TypeVisitor.h"
#include "clang/Basic/AddressSpaces.h"
#include "clang/Basic/ExceptionSpecificationType.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Linkage.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Basic/TargetCXXABI.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Visibility.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <optional>
#include "clang/AST/TypeNodes.inc"
#include "clang/Basic/AArch64ACLETypes.def"
#include "clang/Basic/WebAssemblyReferenceTypes.def"
#include "clang/Basic/HLSLIntangibleTypes.def"
#include "clang/Basic/RISCVVTypes.def"
#include "clang/Basic/OpenCLImageTypes.def"
#include "clang/Basic/OpenCLExtensionTypes.def"
#include "clang/Basic/PPCTypes.def"
#include "clang/Basic/AMDGPUTypes.def"
#include "clang/Basic/SPIRVTypes.def"
#include "clang/AST/BuiltinTypes.def"

Go to the source code of this file.

Classes

class  clang::TypePropertyCache< Private >
 The type-property cache. More...

Namespaces

namespace  clang
 Top level wrappers for InstallAPI frontend operations.

Macros

#define TYPE(CLASS, BASE)
#define TYPE(CLASS, BASE)
#define ABSTRACT_TYPE(Class, Parent)
#define TYPE(Class, Parent)
#define ABSTRACT_TYPE(Class, Parent)
#define TYPE(Class, Parent)
#define ABSTRACT_TYPE(Class, Parent)
#define TYPE(Class, Parent)
#define ABSTRACT_TYPE(Class, Parent)
#define TYPE(Class, Parent)
#define ABSTRACT_TYPE(Class, Parent)
#define TYPE(Class, Parent)
#define TYPE(Class, Base)
#define DEPENDENT_TYPE(Class, Base)
#define TRIVIAL_TYPE_CLASS(Class)
#define SUGARED_TYPE_CLASS(Class)
#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, IsSigned)
#define WASM_TYPE(Name, Id, SingletonId)
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId)
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId)
#define RVV_TYPE(Name, Id, SingletonId)
#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, IsFP, IsBF)
#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls)
#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls)
#define ABSTRACT_TYPE(Derived, Base)
#define TYPE(Derived, Base)
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext)
#define SVE_TYPE(Name, Id, SingletonId)
#define PPC_VECTOR_TYPE(Name, Id, Size)
#define RVV_TYPE(Name, Id, SingletonId)
#define WASM_TYPE(Name, Id, SingletonId)
#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
#define SPIRV_TYPE(Name, Id, SingletonId)
#define CC_VLS_CASE(ABI_VLEN)
#define ENUMERATE_ATTRS(PREFIX)
#define TYPE(Class, Base)
#define NON_CANONICAL_TYPE(Class, Base)
#define TYPE(Class, Base)
#define DEPENDENT_TYPE(Class, Base)
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
#define TYPE(Class, Base)
#define NON_CANONICAL_TYPE(Class, Base)
#define TYPE(Class, Base)
#define DEPENDENT_TYPE(Class, Base)
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
#define NON_CANONICAL_TYPE(Class, Parent)
#define TYPE(Class, Parent)
#define SIGNED_TYPE(Id, SingletonId)
#define UNSIGNED_TYPE(Id, SingletonId)
#define FLOATING_TYPE(Id, SingletonId)
#define BUILTIN_TYPE(Id, SingletonId)
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext)
#define SVE_TYPE(Name, Id, SingletonId)
#define PPC_VECTOR_TYPE(Name, Id, Size)
#define RVV_TYPE(Name, Id, SingletonId)
#define WASM_TYPE(Name, Id, SingletonId)
#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
#define SPIRV_TYPE(Name, Id, SingletonId)

Typedefs

using Cache = TypePropertyCache<Private>

Enumerations

enum class  MemoryRegion {
  Global , Local , Private , Generic ,
  Constant , GlobalDevice , GlobalHost , Unknown
}

Functions

static MemoryRegion getMemoryRegion (LangAS AS)
static bool isConvertibleOpenCLSYCLAddressSpace (LangAS To, LangAS From)
template<typename T>
static const T * getAsSugar (const Type *Cur)
 This will check for a T (which should be a Type which can act as sugar, such as a TypedefType) by removing any existing sugar until it reaches a T or a non-sugared type.
static bool isTriviallyCopyableTypeImpl (const QualType &type, const ASTContext &Context, bool IsCopyConstructible)
static ArrayRef< TypeCoupledDeclRefInfoallocateCoupledDecls (const ASTContext &Ctx, ArrayRef< TypeCoupledDeclRefInfo > Decls)
 Copy Decls into Ctx so a CountAttributedType can retain it by reference.
static TypeDependence getTemplateSpecializationTypeDependence (QualType Underlying, TemplateName T)
static CachedProperties computeCachedProperties (const Type *T)
static bool isAMDGPUNamedBarrierTypeImpl (const Type *Ty, bool AllowWrappers)
static bool requiresBuiltinLaunderImpl (const ASTContext &Context, QualType Ty, llvm::SmallPtrSetImpl< const Decl * > &Seen)
raw_ostream & clang::operator<< (raw_ostream &OS, const FunctionEffectWithCondition &CFE)

Macro Definition Documentation

◆ ABSTRACT_TYPE [1/6]

#define ABSTRACT_TYPE ( Class,
Parent )

◆ ABSTRACT_TYPE [2/6]

#define ABSTRACT_TYPE ( Class,
Parent )

◆ ABSTRACT_TYPE [3/6]

#define ABSTRACT_TYPE ( Class,
Parent )

◆ ABSTRACT_TYPE [4/6]

#define ABSTRACT_TYPE ( Class,
Parent )

◆ ABSTRACT_TYPE [5/6]

#define ABSTRACT_TYPE ( Class,
Parent )

◆ ABSTRACT_TYPE [6/6]

#define ABSTRACT_TYPE ( Derived,
Base )

◆ AMDGPU_TYPE [1/2]

#define AMDGPU_TYPE ( Name,
Id,
SingletonId,
Width,
Align )
Value:
case Id: \
return Name;

◆ AMDGPU_TYPE [2/2]

#define AMDGPU_TYPE ( Name,
Id,
SingletonId,
Width,
Align )
Value:
case BuiltinType::Id:

◆ BUILTIN_TYPE

#define BUILTIN_TYPE ( Id,
SingletonId )

◆ CC_VLS_CASE

#define CC_VLS_CASE ( ABI_VLEN)
Value:
case CC_RISCVVLSCall_##ABI_VLEN: return "riscv_vls_cc(" #ABI_VLEN ")";

◆ DEPENDENT_TYPE [1/3]

#define DEPENDENT_TYPE ( Class,
Base )
Value:
QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
A (possibly-)qualified type.
Definition TypeBase.h:938
The base class of the type hierarchy.
Definition TypeBase.h:1879
const FunctionProtoType * T
@ Type
The name was classified as a type.
Definition Sema.h:558

Definition at line 1124 of file Type.cpp.

◆ DEPENDENT_TYPE [2/3]

#define DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

Definition at line 1124 of file Type.cpp.

◆ DEPENDENT_TYPE [3/3]

#define DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

Definition at line 1124 of file Type.cpp.

◆ ENUMERATE_ATTRS

#define ENUMERATE_ATTRS ( PREFIX)
Value:
do { \
if (isCountInBytes()) { \
if (isOrNull()) \
return PREFIX "sized_by_or_null"; \
return PREFIX "sized_by"; \
} \
if (isOrNull()) \
return PREFIX "counted_by_or_null"; \
return PREFIX "counted_by"; \
} while (0)

Referenced by clang::CountAttributedType::getAttributeName().

◆ EXT_OPAQUE_TYPE [1/2]

#define EXT_OPAQUE_TYPE ( ExtType,
Id,
Ext )
Value:
case Id: \
return #ExtType;

◆ EXT_OPAQUE_TYPE [2/2]

#define EXT_OPAQUE_TYPE ( ExtType,
Id,
Ext )
Value:
case BuiltinType::Id:

◆ FLOATING_TYPE

#define FLOATING_TYPE ( Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ HLSL_INTANGIBLE_TYPE [1/3]

#define HLSL_INTANGIBLE_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ HLSL_INTANGIBLE_TYPE [2/3]

#define HLSL_INTANGIBLE_TYPE ( Name,
Id,
SingletonId )
Value:
case Id: \
return #Name;

◆ HLSL_INTANGIBLE_TYPE [3/3]

#define HLSL_INTANGIBLE_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ IMAGE_TYPE [1/2]

#define IMAGE_TYPE ( ImgType,
Id,
SingletonId,
Access,
Suffix )
Value:
case Id: \
return "__" #Access " " #ImgType "_t";

◆ IMAGE_TYPE [2/2]

#define IMAGE_TYPE ( ImgType,
Id,
SingletonId,
Access,
Suffix )
Value:
case BuiltinType::Id:

◆ NON_CANONICAL_TYPE [1/3]

#define NON_CANONICAL_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ NON_CANONICAL_TYPE [2/3]

#define NON_CANONICAL_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ NON_CANONICAL_TYPE [3/3]

#define NON_CANONICAL_TYPE ( Class,
Parent )
Value:
/* We'll only see canonical types here. */ \
case Type::Class: \
llvm_unreachable("non-canonical type");

◆ NON_CANONICAL_UNLESS_DEPENDENT_TYPE [1/2]

#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ NON_CANONICAL_UNLESS_DEPENDENT_TYPE [2/2]

#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ PPC_VECTOR_TYPE [1/2]

#define PPC_VECTOR_TYPE ( Name,
Id,
Size )
Value:
case Id: \
return #Name;

◆ PPC_VECTOR_TYPE [2/2]

#define PPC_VECTOR_TYPE ( Name,
Id,
Size )
Value:
case BuiltinType::Id:

◆ RVV_PREDICATE_TYPE [1/2]

#define RVV_PREDICATE_TYPE ( Name,
Id,
SingletonId,
NumEls )
Value:
case BuiltinType::Id: \
return true;

◆ RVV_PREDICATE_TYPE [2/2]

#define RVV_PREDICATE_TYPE ( Name,
Id,
SingletonId,
NumEls )
Value:
case BuiltinType::Id: \
return Ctx.UnsignedCharTy;

◆ RVV_TYPE [1/3]

#define RVV_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ RVV_TYPE [2/3]

#define RVV_TYPE ( Name,
Id,
SingletonId )
Value:
case Id: \
return Name;

◆ RVV_TYPE [3/3]

#define RVV_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ RVV_VECTOR_TYPE

#define RVV_VECTOR_TYPE ( Name,
Id,
SingletonId,
NumEls,
ElBits,
NF,
IsSigned,
IsFP,
IsBF )
Value:
case BuiltinType::Id: \
return NF == 1;

◆ SIGNED_TYPE

#define SIGNED_TYPE ( Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ SPIRV_TYPE [1/2]

#define SPIRV_TYPE ( Name,
Id,
SingletonId )
Value:
case Id: \
return Name;

◆ SPIRV_TYPE [2/2]

#define SPIRV_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ SUGARED_TYPE_CLASS

#define SUGARED_TYPE_CLASS ( Class)
Value:
QualType Visit##Class##Type(const Class##Type *T) { \
if (!T->isSugared()) \
return QualType(T, 0); \
QualType desugaredType = recurse(T->desugar()); \
if (desugaredType.isNull()) \
return {}; \
if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
return QualType(T, 0); \
return desugaredType; \
}
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1005
void * getAsOpaquePtr() const
Definition TypeBase.h:985

Definition at line 1130 of file Type.cpp.

◆ SVE_OPAQUE_TYPE

#define SVE_OPAQUE_TYPE ( Name,
MangledName,
Id,
SingletonId )
Value:
case BuiltinType::Id: \
return true;

◆ SVE_PREDICATE_TYPE

#define SVE_PREDICATE_TYPE ( Name,
MangledName,
Id,
SingletonId )
Value:
case BuiltinType::Id: \
return true;

◆ SVE_TYPE [1/2]

#define SVE_TYPE ( Name,
Id,
SingletonId )
Value:
case Id: \
return #Name;

◆ SVE_TYPE [2/2]

#define SVE_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ SVE_VECTOR_TYPE

#define SVE_VECTOR_TYPE ( Name,
MangledName,
Id,
SingletonId )
Value:
case BuiltinType::Id: \
return true;

◆ SVE_VECTOR_TYPE_INT

#define SVE_VECTOR_TYPE_INT ( Name,
MangledName,
Id,
SingletonId,
NumEls,
ElBits,
NF,
IsSigned )
Value:
case BuiltinType::Id: \
return IsSigned;

◆ TRIVIAL_TYPE_CLASS

#define TRIVIAL_TYPE_CLASS ( Class)
Value:
QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }

Definition at line 1128 of file Type.cpp.

◆ TYPE [1/14]

#define TYPE ( CLASS,
BASE )
Value:
static_assert(!std::is_polymorphic<CLASS##Type>::value, \
#CLASS "Type should not be polymorphic!");

Definition at line 628 of file Type.cpp.

◆ TYPE [2/14]

#define TYPE ( CLASS,
BASE )
Value:
static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
#CLASS "Type should be trivially destructible!");

Definition at line 628 of file Type.cpp.

◆ TYPE [3/14]

#define TYPE ( Class,
Base )

Definition at line 628 of file Type.cpp.

◆ TYPE [4/14]

#define TYPE ( Class,
Base )

Definition at line 628 of file Type.cpp.

◆ TYPE [5/14]

#define TYPE ( Class,
Base )

Definition at line 628 of file Type.cpp.

◆ TYPE [6/14]

#define TYPE ( Class,
Base )

Definition at line 628 of file Type.cpp.

◆ TYPE [7/14]

#define TYPE ( Class,
Base )

Definition at line 628 of file Type.cpp.

◆ TYPE [8/14]

#define TYPE ( Class,
Parent )
Value:
case Type::Class: { \
const auto *ty = cast<Class##Type>(this); \
if (!ty->isSugared()) \
return QualType(ty, 0); \
return ty->desugar(); \
}
U cast(CodeGen::Address addr)
Definition Address.h:327

Definition at line 628 of file Type.cpp.

◆ TYPE [9/14]

#define TYPE ( Class,
Parent )
Value:
case Type::Class: { \
const auto *Ty = cast<Class##Type>(CurTy); \
if (!Ty->isSugared()) \
return SplitQualType(Ty, Qs); \
Cur = Ty->desugar(); \
break; \
}
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition TypeBase.h:871

Definition at line 628 of file Type.cpp.

◆ TYPE [10/14]

#define TYPE ( Class,
Parent )
Value:
case Type::Class: { \
const auto *ty = cast<Class##Type>(split.Ty); \
if (!ty->isSugared()) \
goto done; \
next = ty->desugar(); \
break; \
}

Definition at line 628 of file Type.cpp.

◆ TYPE [11/14]

#define TYPE ( Class,
Parent )
Value:
case Type::Class: { \
const auto *Ty = cast<Class##Type>(Cur); \
if (!Ty->isSugared()) \
return 0; \
Cur = Ty->desugar().getTypePtr(); \
break; \
}

Definition at line 628 of file Type.cpp.

◆ TYPE [12/14]

#define TYPE ( Class,
Parent )
Value:
case Class: { \
const auto *Ty = cast<Class##Type>(Cur); \
if (!Ty->isSugared()) \
return Cur; \
Cur = Ty->desugar().getTypePtr(); \
break; \
}

Definition at line 628 of file Type.cpp.

◆ TYPE [13/14]

#define TYPE ( Class,
Parent )

Definition at line 628 of file Type.cpp.

◆ TYPE [14/14]

#define TYPE ( Derived,
Base )
Value:
case Derived: \
return #Derived;

Definition at line 628 of file Type.cpp.

◆ UNSIGNED_TYPE

#define UNSIGNED_TYPE ( Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ WASM_TYPE [1/3]

#define WASM_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ WASM_TYPE [2/3]

#define WASM_TYPE ( Name,
Id,
SingletonId )
Value:
case Id: \
return Name;

◆ WASM_TYPE [3/3]

#define WASM_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

Typedef Documentation

◆ Cache

Definition at line 5077 of file Type.cpp.

Enumeration Type Documentation

◆ MemoryRegion

enum class MemoryRegion
strong
Enumerator
Global 
Local 
Private 
Generic 
Constant 
GlobalDevice 
GlobalHost 
Unknown 

Definition at line 74 of file Type.cpp.

Function Documentation

◆ allocateCoupledDecls()

ArrayRef< TypeCoupledDeclRefInfo > allocateCoupledDecls ( const ASTContext & Ctx,
ArrayRef< TypeCoupledDeclRefInfo > Decls )
static

Copy Decls into Ctx so a CountAttributedType can retain it by reference.

The node owns this allocation rather than its callers, so both Create and complete route through here.

Definition at line 4287 of file Type.cpp.

References clang::ASTContext::Allocate().

◆ computeCachedProperties()

CachedProperties computeCachedProperties ( const Type * T)
static

◆ getAsSugar()

template<typename T>
const T * getAsSugar ( const Type * Cur)
static

This will check for a T (which should be a Type which can act as sugar, such as a TypedefType) by removing any existing sugar until it reaches a T or a non-sugared type.

Definition at line 736 of file Type.cpp.

References clang::Type::getTypeClass(), and clang::T.

Referenced by clang::Type::getAs().

◆ getMemoryRegion()

◆ getTemplateSpecializationTypeDependence()

◆ isAMDGPUNamedBarrierTypeImpl()

bool isAMDGPUNamedBarrierTypeImpl ( const Type * Ty,
bool AllowWrappers )
static

◆ isConvertibleOpenCLSYCLAddressSpace()

bool isConvertibleOpenCLSYCLAddressSpace ( LangAS To,
LangAS From )
static

Definition at line 119 of file Type.cpp.

References Constant, Generic, getMemoryRegion(), and Unknown.

Referenced by clang::Qualifiers::isTargetAddressSpaceSupersetOf().

◆ isTriviallyCopyableTypeImpl()

◆ requiresBuiltinLaunderImpl()

bool requiresBuiltinLaunderImpl ( const ASTContext & Context,
QualType Ty,
llvm::SmallPtrSetImpl< const Decl * > & Seen )
static