clang 20.0.0git
|
CharUnits - This is an opaque type for sizes expressed in character units. More...
#include "clang/AST/CharUnits.h"
Public Types | |
typedef int64_t | QuantityType |
Public Member Functions | |
CharUnits ()=default | |
CharUnits - A default constructor. | |
CharUnits & | operator+= (const CharUnits &Other) |
CharUnits & | operator++ () |
CharUnits | operator++ (int) |
CharUnits & | operator-= (const CharUnits &Other) |
CharUnits & | operator-- () |
CharUnits | operator-- (int) |
bool | operator== (const CharUnits &Other) const |
bool | operator!= (const CharUnits &Other) const |
bool | operator< (const CharUnits &Other) const |
bool | operator<= (const CharUnits &Other) const |
bool | operator> (const CharUnits &Other) const |
bool | operator>= (const CharUnits &Other) const |
bool | isZero () const |
isZero - Test whether the quantity equals zero. | |
bool | isOne () const |
isOne - Test whether the quantity equals one. | |
bool | isPositive () const |
isPositive - Test whether the quantity is greater than zero. | |
bool | isNegative () const |
isNegative - Test whether the quantity is less than zero. | |
bool | isPowerOfTwo () const |
isPowerOfTwo - Test whether the quantity is a power of two. | |
bool | isMultipleOf (CharUnits N) const |
Test whether this is a multiple of the other value. | |
CharUnits | operator* (QuantityType N) const |
CharUnits & | operator*= (QuantityType N) |
CharUnits | operator/ (QuantityType N) const |
CharUnits & | operator/= (QuantityType N) |
QuantityType | operator/ (const CharUnits &Other) const |
CharUnits | operator% (QuantityType N) const |
QuantityType | operator% (const CharUnits &Other) const |
CharUnits | operator+ (const CharUnits &Other) const |
CharUnits | operator- (const CharUnits &Other) const |
CharUnits | operator- () const |
QuantityType | getQuantity () const |
getQuantity - Get the raw integer representation of this quantity. | |
llvm::Align | getAsAlign () const |
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit bytes. | |
llvm::MaybeAlign | getAsMaybeAlign () const |
getAsMaybeAlign - Returns Quantity as a valid llvm::Align or std::nullopt, Beware llvm::MaybeAlign assumes power of two 8-bit bytes. | |
CharUnits | alignTo (const CharUnits &Align) const |
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is a multiple of Align . | |
CharUnits | alignmentAtOffset (CharUnits offset) const |
Given that this is a non-zero alignment value, what is the alignment at the given offset? | |
CharUnits | alignmentOfArrayElement (CharUnits elementSize) const |
Given that this is the alignment of the first element of an array, return the minimum alignment of any element in the array. | |
Static Public Member Functions | |
static CharUnits | Zero () |
Zero - Construct a CharUnits quantity of zero. | |
static CharUnits | One () |
One - Construct a CharUnits quantity of one. | |
static CharUnits | fromQuantity (QuantityType Quantity) |
fromQuantity - Construct a CharUnits quantity from a raw integer type. | |
static CharUnits | fromQuantity (llvm::Align Quantity) |
fromQuantity - Construct a CharUnits quantity from an llvm::Align quantity. | |
CharUnits - This is an opaque type for sizes expressed in character units.
Instances of this type represent a quantity as a multiple of the size of the standard C type, char, on the target architecture. As an opaque type, CharUnits protects you from accidentally combining operations on quantities in bit units and character units.
In both C and C++, an object of type 'char', 'signed char', or 'unsigned char' occupies exactly one byte, so 'character unit' and 'byte' refer to the same quantity of storage. However, we use the term 'character unit' rather than 'byte' to avoid an implication that a character unit is exactly 8 bits.
For portability, never assume that a target character is 8 bits wide. Use CharUnit values wherever you calculate sizes, offsets, or alignments in character units.
Definition at line 38 of file CharUnits.h.
typedef int64_t clang::CharUnits::QuantityType |
Definition at line 40 of file CharUnits.h.
|
default |
CharUnits - A default constructor.
Referenced by alignmentAtOffset(), alignTo(), fromQuantity(), One(), operator%(), operator*(), operator+(), operator++(), operator-(), operator--(), operator/(), and Zero().
Given that this is a non-zero alignment value, what is the alignment at the given offset?
Definition at line 207 of file CharUnits.h.
References CharUnits().
Referenced by alignmentOfArrayElement(), ApplyNonVirtualAndVirtualOffset(), clang::CodeGen::CGBuilderTy::CreateConstArrayGEP(), clang::CodeGen::CGBuilderTy::CreateConstByteGEP(), clang::CodeGen::CGBuilderTy::CreateConstGEP(), clang::CodeGen::CGBuilderTy::CreateConstInBoundsByteGEP(), clang::CodeGen::CGBuilderTy::CreateConstInBoundsGEP(), clang::CodeGen::CGBuilderTy::CreatePreserveStructAccessIndex(), clang::CodeGen::CGBuilderTy::CreateStructGEP(), getArrayElementAlign(), getBlockCaptureStr(), and clang::interp::interp__builtin_is_aligned_up_down().
Given that this is the alignment of the first element of an array, return the minimum alignment of any element in the array.
Definition at line 214 of file CharUnits.h.
References alignmentAtOffset().
Referenced by clang::CodeGen::CGBuilderTy::CreateGEP(), EmitArrayDelete(), emitNonZeroVLAInit(), EmitOMPAggregateInit(), EmitOMPAggregateReduction(), clang::CodeGen::CGOpenMPRuntime::emitUserDefinedMapper(), and getArrayElementAlign().
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is a multiple of Align
.
Align must be non-zero.
Definition at line 201 of file CharUnits.h.
References CharUnits().
Referenced by clang::CodeGen::ConstantAggregateBuilderBase::addPlaceholderWithSize(), computeBlockInfo(), clang::CodeGen::CGOpenMPRuntime::emitDepobjDependClause(), clang::CodeGen::emitVoidPtrDirectVAArg(), clang::CodeGen::CGOpenMPRuntime::getAddressOfLocalVariable(), and clang::CodeGen::CodeGenFunction::OMPBuilderCBHelpers::getAddressOfLocalVariable().
|
inlinestatic |
fromQuantity - Construct a CharUnits quantity from an llvm::Align quantity.
Definition at line 69 of file CharUnits.h.
References CharUnits().
|
inlinestatic |
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Definition at line 63 of file CharUnits.h.
References CharUnits().
Referenced by addOrSubLValueAsInteger(), clang::CodeGen::ConstantAggregateBuilderBase::addPlaceholderWithSize(), CheckAggExprForMemSetUse(), CheckAtomicAlignment(), computeOffsetHint(), convertUnsignedAPIntToCharUnits(), clang::CodeGen::CGBuilderTy::CreateConstArrayGEP(), clang::CodeGen::CGBuilderTy::CreateConstGEP(), clang::CodeGen::CGBuilderTy::CreateConstInBoundsGEP(), clang::CodeGen::CGBuilderTy::CreateGEP(), createPlaceholderSlot(), clang::CodeGen::CGBuilderTy::CreatePreserveStructAccessIndex(), clang::CodeGen::CGBuilderTy::CreateStructGEP(), CreateTempAllocaForCoercion(), DumpRecordLayout(), emitAddressAtOffset(), clang::CodeGen::CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(), emitStoresForConstant(), clang::CodeGen::CGObjCRuntime::EmitValueForIvarAtOffset(), EmitX86_64VAArgFromMemory(), clang::CodeGen::CGOpenMPRuntime::getAddressOfLocalVariable(), clang::CodeGen::CodeGenFunction::OMPBuilderCBHelpers::getAddressOfLocalVariable(), clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString(), clang::CodeGen::CodeGenModule::GetAddrOfMSGuidDecl(), clang::CodeGen::CGFunctionInfo::getArgStructAlignment(), clang::ento::ElementRegion::getAsArrayOffset(), clang::ASTContext::getASTRecordLayout(), getBaseAlignmentAndOffsetFromLValue(), clang::CodeGen::swiftcall::SwiftAggLowering::getCoerceAndExpandTypes(), getConstantArrayInfoInChars(), llvm::DenseMapInfo< clang::BaseSubobject >::getEmptyKey(), llvm::DenseMapInfo< clang::CharUnits >::getEmptyKey(), clang::CodeGen::ABIArgInfo::getIndirectAlign(), clang::CodeGen::CodeGenTypeCache::getIntAlign(), clang::CodeGen::CodeGenTypeCache::getIntSize(), getLowBit(), getMaxAtomicAccessSize(), clang::CodeGen::swiftcall::getNaturalAlignment(), clang::CodeGen::CodeGenModule::getNaturalTypeAlignment(), clang::CodeGen::CGBlockInfo::Capture::getOffset(), getOffsetAtStartOfUnit(), getOffsetOfFullPath(), clang::CodeGen::CodeGenModule::getOMPAllocateAlignment(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::CodeGen::CodeGenTypeCache::getPointerSize(), clang::CodeGen::CodeGenTypeCache::getSizeAlign(), clang::CodeGen::CodeGenTypeCache::getSizeSize(), llvm::DenseMapInfo< clang::BaseSubobject >::getTombstoneKey(), llvm::DenseMapInfo< clang::CharUnits >::getTombstoneKey(), getTypeAllocSize(), getTypeStoreSize(), initializeForBlockHeader(), clang::interp::interp__builtin_atomic_lock_free(), clang::interp::interp__builtin_is_aligned_up_down(), isVarDeclStrongDefinition(), clang::LayoutOverrideSource::LayoutOverrideSource(), clang::CodeGen::CGBitFieldInfo::MakeInfo(), performTypeAdjustment(), clang::CodeGen::DominatingLLVMValue::save(), clang::analyze_os_log::OSLogBufferLayout::size(), clang::interp::FunctionPointer::toAPValue(), clang::interp::Pointer::toAPValue(), clang::ASTContext::toCharUnitsFromBits(), clang::CodeGen::CodeGenTypes::typeRequiresSplitIntoByteArray(), and clang::ento::ExprEngine::VisitUnaryExprOrTypeTraitExpr().
|
inline |
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit bytes.
Definition at line 189 of file CharUnits.h.
Referenced by buildGlobalBlock(), clang::CodeGen::CodeGenModule::ConstructAttributeList(), clang::CodeGen::CGBuilderTy::CreateAlignedLoad(), clang::CodeGen::CGBuilderTy::CreateAlignedStore(), clang::CodeGen::CGBuilderTy::CreateAtomicCmpXchg(), clang::CodeGen::CGBuilderTy::CreateAtomicRMW(), CreateCoercedLoad(), clang::CodeGen::CGBuilderTy::CreateLoad(), createLoadInstBefore(), clang::CodeGen::CGBuilderTy::CreateMemCpy(), clang::CodeGen::CGBuilderTy::CreateMemCpyInline(), clang::CodeGen::CGBuilderTy::CreateMemMove(), clang::CodeGen::CGBuilderTy::CreateMemSet(), clang::CodeGen::CGBuilderTy::CreateMemSetInline(), createReferenceTemporary(), clang::CodeGen::CGBuilderTy::CreateStore(), createStoreInstBefore(), clang::CodeGen::CodeGenModule::createUnnamedGlobalFrom(), clang::CodeGen::CGOpenMPRuntime::emitLastprivateConditionalUpdate(), EmitNullBaseClassInitialization(), GenerateStringLiteral(), clang::CodeGen::CGOpenMPRuntimeGPU::getAddressOfLocalVariable(), clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString(), clang::CodeGen::CodeGenModule::GetAddrOfConstantCString(), clang::CodeGen::CodeGenModule::GetAddrOfConstantStringFromLiteral(), clang::CodeGen::CodeGenModule::GetAddrOfGlobalTemporary(), clang::CodeGen::CodeGenModule::GetAddrOfUnnamedGlobalConstantDecl(), getInitThreadEpochPtr(), and clang::CodeGen::CodeGenFunction::setBeforeOutermostConditional().
|
inline |
getAsMaybeAlign - Returns Quantity as a valid llvm::Align or std::nullopt, Beware llvm::MaybeAlign assumes power of two 8-bit bytes.
Definition at line 194 of file CharUnits.h.
|
inline |
getQuantity - Get the raw integer representation of this quantity.
Definition at line 185 of file CharUnits.h.
Referenced by clang::Sema::AddAlignedAttr(), AddPointerLayoutOffset(), AddRelativeLayoutOffset(), clang::ODRHash::AddStructuralValue(), ApplyNonVirtualAndVirtualOffset(), clang::interp::IntPointer::atOffset(), clang::ASTContext::AtomicUsesUnsupportedLibcall(), buildBlockDescriptor(), clang::Sema::BuildCXXNew(), buildGlobalBlock(), buildMemcpyForAssignmentOp(), clang::Sema::BuildPredefinedExpr(), calculateOffset(), clang::ento::StoreManager::castRegion(), charUnitsToString(), clang::SemaPPC::checkAIXMemberAlignment(), clang::Sema::CheckAlignasUnderalignment(), clang::Sema::checkArrayElementAlignment(), CheckAtomicAlignment(), clang::Sema::CheckCastAlign(), clang::Sema::CheckCXXThrowOperand(), clang::Sema::CheckThreadLocalForLargeAlignment(), computeBlockInfo(), computeOffset(), clang::CodeGen::CodeGenModule::ConstructAttributeList(), clang::CodeGen::CodeGenTypes::convertTypeForLoadStore(), clang::CodeGen::CodeGenTypes::ConvertTypeForMem(), clang::CodeGen::CodeGenModule::createUnnamedGlobalFrom(), clang::Sema::DefaultArgumentPromotion(), clang::Sema::DiagnoseSizeOfParametersAndReturnValue(), clang::CodeGen::ABIArgInfo::dump(), DumpRecordLayout(), clang::ento::RegionRawOffset::dumpToStream(), emitAlignedClause(), EmitCXXNewAllocSize(), clang::CodeGen::CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(), clang::CodeGen::CGOpenMPRuntime::emitDeclareSimdFunction(), clang::CodeGen::CGOpenMPRuntime::emitDeclareTargetFunction(), EmitISOVolatileLoad(), emitNonZeroVLAInit(), clang::CodeGen::emitRoundPointerUpToAlignment(), clang::CodeGen::CGOpenMPRuntime::emitUDMapperArrayInitOrDel(), clang::CodeGen::CGOpenMPRuntime::emitUserDefinedMapper(), encodeTypeForFunctionPointerAuth(), EvaluateComparisonBinaryOperator(), clang::Sema::FillInlineAsmIdentifierInfo(), clang::CodeGen::CodeGenTBAA::getAccessInfo(), clang::CodeGen::CodeGenModule::GetAddrOfConstantCString(), clang::CodeGen::CodeGenModule::GetAddrOfConstantStringFromLiteral(), GetAlignedMapping(), getBlockDescriptorName(), getConstantArrayInfoInChars(), getCopyDestroyHelperFuncName(), getExceedsMsgs(), llvm::DenseMapInfo< clang::CharUnits >::getHashValue(), getIndex(), clang::CodeGen::CGOpenMPRuntimeGPU::getKmpcAllocShared(), clang::CodeGen::swiftcall::getNaturalAlignment(), clang::CodeGen::CodeGenModule::getNaturalTypeAlignment(), clang::ConstantArrayType::getNumAddressingBits(), getOffsetAtStartOfUnit(), clang::CodeGen::CodeGenModule::getOMPAllocateAlignment(), clang::CodeGen::CGOpenCLRuntime::getPipeElemAlign(), clang::CodeGen::CGOpenCLRuntime::getPipeElemSize(), clang::CodeGen::CGBuilderTy::getSize(), clang::CodeGen::CodeGenModule::getSize(), clang::analyze_os_log::OSLogBufferItem::getSizeByte(), HandleOperatorNewCall(), initializeForBlockHeader(), clang::interp::interp__builtin_is_aligned_up_down(), clang::interp::interp__builtin_os_log_format_buffer_size(), clang::CodeGen::SwiftABIInfo::isLegalVectorType(), clang::CodeGen::CGBlockInfo::Capture::makeIndex(), mergeAlignedAttrs(), clang::CodeGen::CGBitFieldInfo::print(), clang::APValue::printPretty(), clang::CodeGen::BlockByrefHelpers::Profile(), clang::CodeGen::CodeGenModule::Release(), clang::CodeGen::CGFunctionInfo::setArgStruct(), clang::CodeGen::ABIArgInfo::setIndirectAlign(), setUsedBits(), clang::ASTContext::toBits(), tryToInvalidateFReadBufferByElements(), clang::Value::Value(), and clang::ento::ExprEngine::VisitUnaryExprOrTypeTraitExpr().
Test whether this is a multiple of the other value.
Among other things, this promises that self.alignTo(N) will just return self.
Definition at line 143 of file CharUnits.h.
|
inline |
isNegative - Test whether the quantity is less than zero.
Definition at line 131 of file CharUnits.h.
Referenced by EmitNullBaseClassInitialization().
|
inline |
isOne - Test whether the quantity equals one.
Definition at line 125 of file CharUnits.h.
Referenced by clang::Sema::CheckCastAlign(), EmitCXXNewAllocSize(), clang::Sema::RefersToMemberWithReducedAlignment(), and clang::CodeGen::EHCleanupScope::setActiveFlag().
|
inline |
isPositive - Test whether the quantity is greater than zero.
Definition at line 128 of file CharUnits.h.
Referenced by clang::ASTContext::getObjCEncodingForBlock(), clang::ASTContext::getObjCEncodingForFunctionDecl(), clang::ASTContext::getObjCEncodingForMethodDecl(), and clang::ASTContext::getObjCEncodingTypeSize().
|
inline |
isPowerOfTwo - Test whether the quantity is a power of two.
Zero is not a power of two.
Definition at line 135 of file CharUnits.h.
|
inline |
isZero - Test whether the quantity equals zero.
Definition at line 122 of file CharUnits.h.
Referenced by clang::Sema::ActOnFields(), clang::CodeGen::Address::Address(), ApplyNonVirtualAndVirtualOffset(), clang::Sema::BuildAtomicExpr(), clang::ento::StoreManager::castRegion(), castValueToType(), clang::Sema::CheckSubtractionOperands(), clang::CodeGen::CodeGenModule::ConstructAttributeList(), EmitNullBaseClassInitialization(), EmitNullConstant(), EvaluateBuiltinConstantPForLValue(), evenFlexibleArraySize(), clang::CodeGen::CodeGenFunction::ParamValue::forIndirect(), GetAddrOfVTTVTable(), clang::ASTContext::getObjCEncodingForBlock(), clang::ASTContext::getObjCEncodingForFunctionDecl(), clang::ASTContext::getObjCEncodingForMethodDecl(), clang::interp::interp__builtin_constant_p(), clang::APValue::printPretty(), and clang::CodeGen::CodeGenModule::TryEmitBaseDestructorAsAlias().
|
inlinestatic |
One - Construct a CharUnits quantity of one.
Definition at line 58 of file CharUnits.h.
References CharUnits().
Referenced by AlignOfType(), clang::CodeGen::AssignToArrayRange(), clang::CodeGen::CGBuilderTy::CreateFlagLoad(), clang::CodeGen::CGBuilderTy::CreateFlagStore(), EmitBitTestIntrinsic(), emitTlsGuardCheck(), clang::CodeGen::swiftcall::SwiftAggLowering::finish(), GetAlignOfType(), clang::CodeGen::CodeGenModule::getClassPointerAlignment(), clang::CodeGen::CodeGenModule::getMinimumClassObjectSize(), clang::CodeGen::CodeGenModule::getNaturalTypeAlignment(), HandleSizeof(), clang::interp::interp__builtin_atomic_lock_free(), clang::APValue::printPretty(), SetupCleanupBlockActivation(), and clang::interp::Compiler< Emitter >::VisitUnaryExprOrTypeTraitExpr().
Definition at line 101 of file CharUnits.h.
References clang::Other.
|
inline |
Definition at line 168 of file CharUnits.h.
References clang::Other.
|
inline |
Definition at line 165 of file CharUnits.h.
References CharUnits().
|
inline |
Definition at line 148 of file CharUnits.h.
References CharUnits().
|
inline |
Definition at line 151 of file CharUnits.h.
Definition at line 171 of file CharUnits.h.
References CharUnits(), and clang::Other.
|
inline |
Definition at line 78 of file CharUnits.h.
Definition at line 82 of file CharUnits.h.
References CharUnits().
Definition at line 74 of file CharUnits.h.
References clang::Other.
|
inline |
Definition at line 177 of file CharUnits.h.
References CharUnits().
Definition at line 174 of file CharUnits.h.
References CharUnits(), and clang::Other.
|
inline |
Definition at line 89 of file CharUnits.h.
Definition at line 93 of file CharUnits.h.
References CharUnits().
Definition at line 85 of file CharUnits.h.
References clang::Other.
|
inline |
Definition at line 162 of file CharUnits.h.
References clang::Other.
|
inline |
Definition at line 155 of file CharUnits.h.
References CharUnits().
|
inline |
Definition at line 158 of file CharUnits.h.
Definition at line 106 of file CharUnits.h.
References clang::Other.
Definition at line 109 of file CharUnits.h.
References clang::Other.
Definition at line 98 of file CharUnits.h.
References clang::Other.
Definition at line 112 of file CharUnits.h.
References clang::Other.
Definition at line 115 of file CharUnits.h.
References clang::Other.
|
inlinestatic |
Zero - Construct a CharUnits quantity of zero.
Definition at line 53 of file CharUnits.h.
References CharUnits().
Referenced by clang::CodeGen::swiftcall::SwiftAggLowering::addTypedData(), BuildAppleKextVirtualCall(), CalculateCookiePadding(), classifyType(), computeBlockInfo(), computeFullPathsForVFTables(), clang::CodeGen::CodeGenModule::computeNonVirtualBaseClassOffset(), DiagnoseReinterpretUpDownCast(), EmitNullBaseClassInitialization(), clang::SourceLocExpr::EvaluateInContext(), getAlignmentAndOffsetFromBinAddOrSub(), clang::CodeGen::CGCXXABI::GetArrayCookieSize(), clang::CodeGen::CGCXXABI::getArrayCookieSizeImpl(), clang::ASTContext::getASTRecordLayout(), getBaseAlignmentAndOffsetFromLValue(), getBaseAlignmentAndOffsetFromPtr(), clang::CodeGen::swiftcall::SwiftAggLowering::getCoerceAndExpandTypes(), getDerivedToBaseAlignmentAndOffset(), clang::VarDecl::getFlexibleArrayInitChars(), clang::ASTContext::getMemberPointerPathAdjustment(), GetNumNonZeroBytesInInit(), clang::ASTContext::getObjCEncodingForFunctionDecl(), clang::ASTContext::getObjCEncodingTypeSize(), clang::ASTContext::getOffsetOfBaseWithVBPtr(), getOffsetOfFullPath(), getTypeExpansion(), clang::ItaniumVTableContext::getVirtualBaseOffsetOffset(), clang::CodeGen::CGCXXABI::getVirtualFunctionPrologueThisAdjustment(), clang::APValue::printPretty(), clang::CodeGen::CGCXXABI::ReadArrayCookie(), selectBestPath(), clang::interp::FunctionPointer::toAPValue(), clang::interp::Pointer::toAPValue(), and clang::VTTBuilder::VTTBuilder().