clang  10.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::CharUnits Class Reference

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. More...
 
CharUnitsoperator+= (const CharUnits &Other)
 
CharUnitsoperator++ ()
 
CharUnits operator++ (int)
 
CharUnitsoperator-= (const CharUnits &Other)
 
CharUnitsoperator-- ()
 
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. More...
 
bool isOne () const
 isOne - Test whether the quantity equals one. More...
 
bool isPositive () const
 isPositive - Test whether the quantity is greater than zero. More...
 
bool isNegative () const
 isNegative - Test whether the quantity is less than zero. More...
 
bool isPowerOfTwo () const
 isPowerOfTwo - Test whether the quantity is a power of two. More...
 
bool isMultipleOf (CharUnits N) const
 Test whether this is a multiple of the other value. More...
 
CharUnits operator* (QuantityType N) const
 
CharUnitsoperator*= (QuantityType N)
 
CharUnits operator/ (QuantityType N) const
 
CharUnitsoperator/= (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. More...
 
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. More...
 
CharUnits alignmentAtOffset (CharUnits offset) const
 Given that this is a non-zero alignment value, what is the alignment at the given offset? More...
 
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. More...
 

Static Public Member Functions

static CharUnits Zero ()
 Zero - Construct a CharUnits quantity of zero. More...
 
static CharUnits One ()
 One - Construct a CharUnits quantity of one. More...
 
static CharUnits fromQuantity (QuantityType Quantity)
 fromQuantity - Construct a CharUnits quantity from a raw integer type. More...
 

Detailed Description

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 37 of file CharUnits.h.

Member Typedef Documentation

◆ QuantityType

Definition at line 39 of file CharUnits.h.

Constructor & Destructor Documentation

◆ CharUnits()

clang::CharUnits::CharUnits ( )
default

Member Function Documentation

◆ alignmentAtOffset()

CharUnits clang::CharUnits::alignmentAtOffset ( CharUnits  offset) const
inline

Given that this is a non-zero alignment value, what is the alignment at the given offset?

Definition at line 189 of file CharUnits.h.

References CharUnits().

Referenced by alignmentOfArrayElement(), ApplyNonVirtualAndVirtualOffset(), buildByrefHelpers(), getArrayElementAlign(), and getBlockCaptureStr().

◆ alignmentOfArrayElement()

CharUnits clang::CharUnits::alignmentOfArrayElement ( CharUnits  elementSize) const
inline

◆ alignTo()

CharUnits clang::CharUnits::alignTo ( const CharUnits Align) const
inline

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 183 of file CharUnits.h.

References CharUnits().

Referenced by computeBlockInfo(), clang::CodeGen::CGOpenMPRuntime::emitCall(), emitVoidPtrDirectVAArg(), clang::CodeGen::CodeGenFunction::getBlockByrefInfo(), getTypeString(), isRecordWithSSEVectorType(), recordUsesEBO(), and roundUpSizeToCharAlignment().

◆ fromQuantity()

static CharUnits clang::CharUnits::fromQuantity ( QuantityType  Quantity)
inlinestatic

fromQuantity - Construct a CharUnits quantity from a raw integer type.

Definition at line 62 of file CharUnits.h.

References CharUnits().

Referenced by CheckAggExprForMemSetUse(), convertUnsignedAPIntToCharUnits(), createPlaceholderSlot(), CreateTempAllocaForCoercion(), DumpRecordLayout(), emitAddressAtOffset(), clang::CodeGen::CodeGenFunction::EmitARCStoreStrong(), clang::CodeGen::CodeGenFunction::EmitBlockLiteral(), clang::CodeGen::CGOpenMPRuntime::emitCall(), clang::CodeGen::CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(), emitInterWarpCopyFunction(), clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTeamsOutlinedFunction(), clang::CodeGen::CGObjCRuntime::EmitValueForIvarAtOffset(), EmitX86_64VAArgFromMemory(), EvaluatePointer(), evenFlexibleArraySize(), FindIvarInterface(), clang::CodeGen::CodeGenFunction::GenerateCXXGlobalInitFunc(), clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString(), GetAlignOfExpr(), clang::CodeGen::CGFunctionInfo::getArgStructAlignment(), clang::ento::ElementRegion::getAsArrayOffset(), clang::CodeGen::CodeGenFunction::getBlockByrefInfo(), getBlockLayoutInfoString(), clang::CodeGen::swiftcall::SwiftAggLowering::getCoerceAndExpandTypes(), GetConstantStringEntry(), clang::CodeGen::CodeGenFunction::getEHSelectorSlot(), llvm::DenseMapInfo< clang::BaseSubobject >::getEmptyKey(), llvm::DenseMapInfo< clang::CharUnits >::getEmptyKey(), GetGCAttrTypeForType(), clang::VTableComponent::getGlobalDecl(), clang::CodeGen::ABIArgInfo::getIndirectAlign(), getLowBit(), getMaxAtomicAccessSize(), clang::CodeGen::swiftcall::getNaturalAlignment(), clang::CodeGen::CodeGenFunction::getNaturalTypeAlignment(), getOffsetAtStartOfUnit(), llvm::DenseMapInfo< clang::BaseSubobject >::getTombstoneKey(), llvm::DenseMapInfo< clang::CharUnits >::getTombstoneKey(), getTypeAllocSize(), getTypeStoreSize(), getTypeString(), initializeForBlockHeader(), isArgInAlloca(), isRecordWithSSEVectorType(), isVarDeclStrongDefinition(), performTypeAdjustment(), recordUsesEBO(), roundUpSizeToCharAlignment(), shuffleAndStore(), clang::analyze_os_log::OSLogBufferLayout::size(), clang::ASTContext::toCharUnitsFromBits(), tryEvaluateBuiltinObjectSize(), and clang::ento::ExprEngine::VisitUnaryExprOrTypeTraitExpr().

◆ getQuantity()

QuantityType clang::CharUnits::getQuantity ( ) const
inline

getQuantity - Get the raw integer representation of this quantity.

Definition at line 178 of file CharUnits.h.

Referenced by clang::CodeGen::CodeGenModule::AddVTableTypeMetadata(), ApplyNonVirtualAndVirtualOffset(), clang::ASTContext::AtomicUsesUnsupportedLibcall(), buildBlockDescriptor(), buildGlobalBlock(), buildMemcpyForAssignmentOp(), calculateOffset(), clang::ento::StoreManager::castRegion(), charUnitsToString(), CheckAggExprForMemSetUse(), clang::CodeGen::CGOpenMPRuntimeNVPTX::clear(), computeBlockInfo(), ComputeVMIClassTypeInfoFlags(), clang::CodeGen::CodeGenModule::ConstructAttributeList(), ContainsFloatAtOffset(), clang::CodeGen::CGBuilderTy::CreateAlignedStore(), createLoadInstBefore(), clang::CodeGen::CGBuilderTy::CreateMemCpy(), clang::CodeGen::CGBuilderTy::CreateMemMove(), clang::CodeGen::CGBuilderTy::CreateMemSet(), createRuntimeShuffleFunction(), clang::CodeGen::CGBuilderTy::CreateStore(), createStoreInstBefore(), decomposeTypeForEH(), detectAmbiguousBases(), DiagnoseBadFunctionCast(), DumpRecordLayout(), emitAlignedClause(), clang::CodeGen::CodeGenFunction::EmitArraySubscriptExpr(), clang::CodeGen::CodeGenFunction::EmitAsanPrologueOrEpilogue(), clang::CodeGen::CodeGenFunction::EmitAtomicExpr(), clang::CodeGen::CodeGenFunction::EmitConstructorBody(), EmitCXXNewAllocSize(), clang::CodeGen::CodeGenFunction::EmitCXXNewExpr(), clang::CodeGen::CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(), clang::CodeGen::CodeGenFunction::emitImplicitAssignmentOperatorBody(), emitInterWarpCopyFunction(), clang::CodeGen::CodeGenFunction::EmitInvariantStart(), EmitISOVolatileLoad(), EmitISOVolatileStore(), clang::CodeGen::CodeGenFunction::EmitLValueForField(), emitNonZeroVLAInit(), emitRoundPointerUpToAlignment(), emitRTtypeidCall(), clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(), clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTeamsOutlinedFunction(), clang::CodeGen::CodeGenFunction::EmitTypeCheck(), EmitX86_64VAArgFromMemory(), EvaluateComparisonBinaryOperator(), FindIvarInterface(), clang::CodeGen::AggValueSlot::forAddr(), clang::CodeGen::CodeGenFunction::ParamValue::forIndirect(), clang::CodeGen::CodeGenVTables::GenerateConstructionVTable(), GenerateStringLiteral(), clang::CodeGen::CodeGenTBAA::getAccessInfo(), clang::CodeGen::RValue::getAggregate(), GetAlignOfExpr(), clang::ento::ElementRegion::getAsArrayOffset(), getBadTypeidFn(), clang::CodeGen::CodeGenFunction::getBlockByrefInfo(), getBlockDescriptorName(), getCopyDestroyHelperFuncName(), clang::ento::TypedValueRegion::getExtent(), GetGCAttrTypeForType(), clang::VTableComponent::getGlobalDecl(), llvm::DenseMapInfo< clang::CharUnits >::getHashValue(), getInitThreadEpochPtr(), getLowBit(), clang::CodeGen::swiftcall::getNaturalAlignment(), clang::CodeGen::CodeGenFunction::getNaturalTypeAlignment(), clang::CodeGen::CodeGenModule::GetNonVirtualBaseClassOffset(), getOffsetAtStartOfUnit(), clang::CodeGen::CGBuilderTy::getSize(), clang::CodeGen::CodeGenModule::getSize(), clang::analyze_os_log::OSLogBufferItem::getSizeByte(), clang::CodeGen::CodeGenTBAA::getTBAAStructInfo(), getThreadLocalWrapperLinkage(), getTypeInfoVTable(), getTypeString(), getUsualDeleteParams(), clang::CodeGen::CodeGenTBAA::getVTablePtrAccessInfo(), HandleConstructorCall(), hasDefaultCXXMethodCC(), hasMRCWeakIvars(), initializeForBlockHeader(), clang::CodeGen::CodeGenFunction::InitTempAlloca(), clang::CodeGen::ConstantInitFuture::installInGlobal(), isFullSizeType(), clang::CodeGen::SwiftABIInfo::isLegalVectorTypeForSwift(), isRecordWithSSEVectorType(), isTrivialFiller(), clang::CodeGen::CodeGenFunction::isTrivialInitializer(), isValidBaseType(), clang::CodeGen::CodeGenFunction::LoadPassedObjectSize(), clang::CodeGen::CGBlockInfo::Capture::makeIndex(), clang::CodeGen::CGBitFieldInfo::print(), PrintBitFieldOffset(), PrintOffset(), clang::APValue::printPretty(), clang::CodeGen::BlockByrefHelpers::Profile(), roundUpSizeToCharAlignment(), scaleValue(), clang::CodeGen::LValue::setAddress(), clang::CodeGen::LValue::setAlignment(), clang::CodeGen::CGFunctionInfo::setArgStruct(), clang::CodeGen::CodeGenFunction::setBeforeOutermostConditional(), clang::CodeGen::ABIArgInfo::setIndirectAlign(), shuffleAndStore(), clang::ASTContext::toBits(), treatUnusedNewEscaped(), tryEvaluateBuiltinObjectSize(), clang::ento::ExprEngine::VisitUnaryExprOrTypeTraitExpr(), and Write__ivar_list_t_initializer().

◆ isMultipleOf()

bool clang::CharUnits::isMultipleOf ( CharUnits  N) const
inline

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 136 of file CharUnits.h.

Referenced by clang::CodeGen::swiftcall::SwiftAggLowering::addTypedData(), getTypeString(), and isRecordWithSSEVectorType().

◆ isNegative()

bool clang::CharUnits::isNegative ( ) const
inline

isNegative - Test whether the quantity is less than zero.

Definition at line 124 of file CharUnits.h.

Referenced by EmitNullBaseClassInitialization(), and evenFlexibleArraySize().

◆ isOne()

bool clang::CharUnits::isOne ( ) const
inline

◆ isPositive()

bool clang::CharUnits::isPositive ( ) const
inline

isPositive - Test whether the quantity is greater than zero.

Definition at line 121 of file CharUnits.h.

Referenced by clang::ASTContext::getObjCEncodingTypeSize(), and hasDefaultCXXMethodCC().

◆ isPowerOfTwo()

bool clang::CharUnits::isPowerOfTwo ( ) const
inline

isPowerOfTwo - Test whether the quantity is a power of two.

Zero is not a power of two.

Definition at line 128 of file CharUnits.h.

Referenced by tryEvaluateBuiltinObjectSize().

◆ isZero()

bool clang::CharUnits::isZero ( ) const
inline

◆ One()

static CharUnits clang::CharUnits::One ( )
inlinestatic

◆ operator!=()

bool clang::CharUnits::operator!= ( const CharUnits Other) const
inline

Definition at line 94 of file CharUnits.h.

◆ operator%() [1/2]

CharUnits clang::CharUnits::operator% ( QuantityType  N) const
inline

Definition at line 158 of file CharUnits.h.

References CharUnits().

◆ operator%() [2/2]

QuantityType clang::CharUnits::operator% ( const CharUnits Other) const
inline

Definition at line 161 of file CharUnits.h.

◆ operator*()

CharUnits clang::CharUnits::operator* ( QuantityType  N) const
inline

Definition at line 141 of file CharUnits.h.

References CharUnits().

◆ operator*=()

CharUnits& clang::CharUnits::operator*= ( QuantityType  N)
inline

Definition at line 144 of file CharUnits.h.

◆ operator+()

CharUnits clang::CharUnits::operator+ ( const CharUnits Other) const
inline

Definition at line 164 of file CharUnits.h.

References CharUnits().

◆ operator++() [1/2]

CharUnits& clang::CharUnits::operator++ ( )
inline

Definition at line 71 of file CharUnits.h.

◆ operator++() [2/2]

CharUnits clang::CharUnits::operator++ ( int  )
inline

Definition at line 75 of file CharUnits.h.

References CharUnits().

◆ operator+=()

CharUnits& clang::CharUnits::operator+= ( const CharUnits Other)
inline

Definition at line 67 of file CharUnits.h.

◆ operator-() [1/2]

CharUnits clang::CharUnits::operator- ( const CharUnits Other) const
inline

Definition at line 167 of file CharUnits.h.

References CharUnits().

◆ operator-() [2/2]

CharUnits clang::CharUnits::operator- ( ) const
inline

Definition at line 170 of file CharUnits.h.

References CharUnits().

◆ operator--() [1/2]

CharUnits& clang::CharUnits::operator-- ( )
inline

Definition at line 82 of file CharUnits.h.

◆ operator--() [2/2]

CharUnits clang::CharUnits::operator-- ( int  )
inline

Definition at line 86 of file CharUnits.h.

References CharUnits().

◆ operator-=()

CharUnits& clang::CharUnits::operator-= ( const CharUnits Other)
inline

Definition at line 78 of file CharUnits.h.

◆ operator/() [1/2]

CharUnits clang::CharUnits::operator/ ( QuantityType  N) const
inline

Definition at line 148 of file CharUnits.h.

References CharUnits().

◆ operator/() [2/2]

QuantityType clang::CharUnits::operator/ ( const CharUnits Other) const
inline

Definition at line 155 of file CharUnits.h.

◆ operator/=()

CharUnits& clang::CharUnits::operator/= ( QuantityType  N)
inline

Definition at line 151 of file CharUnits.h.

◆ operator<()

bool clang::CharUnits::operator< ( const CharUnits Other) const
inline

Definition at line 99 of file CharUnits.h.

◆ operator<=()

bool clang::CharUnits::operator<= ( const CharUnits Other) const
inline

Definition at line 102 of file CharUnits.h.

◆ operator==()

bool clang::CharUnits::operator== ( const CharUnits Other) const
inline

Definition at line 91 of file CharUnits.h.

◆ operator>()

bool clang::CharUnits::operator> ( const CharUnits Other) const
inline

Definition at line 105 of file CharUnits.h.

◆ operator>=()

bool clang::CharUnits::operator>= ( const CharUnits Other) const
inline

Definition at line 108 of file CharUnits.h.

◆ Zero()

static CharUnits clang::CharUnits::Zero ( )
inlinestatic

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