clang  6.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 38 of file CharUnits.h.

Member Typedef Documentation

◆ QuantityType

Definition at line 40 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 190 of file CharUnits.h.

References CharUnits().

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

◆ alignmentOfArrayElement()

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

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

References alignmentAtOffset().

Referenced by clang::CodeGen::CodeGenFunction::emitDestroy(), emitNonZeroVLAInit(), EmitOMPAggregateInit(), EmitOMPAggregateReduction(), forConstantArrayExpansion(), getArrayElementAlign(), and isTrivialFiller().

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

References CharUnits().

Referenced by computeBlockInfo(), emitVoidPtrDirectVAArg(), clang::CodeGen::CodeGenFunction::getBlockByrefInfo(), 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 63 of file CharUnits.h.

References CharUnits().

Referenced by addOrSubLValueAsInteger(), BuildAggStore(), CheckAggExprForMemSetUse(), convertUnsignedAPIntToCharUnits(), createPlaceholderSlot(), CreateTempAllocaForCoercion(), emitAddressAtOffset(), clang::CodeGen::CodeGenFunction::EmitARCStoreStrong(), clang::CodeGen::CodeGenFunction::EmitBlockLiteral(), clang::CodeGen::CodeGenFunction::EmitCall(), clang::CodeGen::CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(), clang::CodeGen::CGOpenMPRuntime::emitOMPIfClause(), clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTeamsCall(), clang::CodeGen::CGObjCRuntime::EmitValueForIvarAtOffset(), EmitX86_64VAArgFromMemory(), EvaluatePointer(), clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString(), GetAlignOfExpr(), clang::CodeGen::CGFunctionInfo::getArgStructAlignment(), clang::CodeGen::CodeGenFunction::getBlockByrefInfo(), clang::CodeGen::swiftcall::SwiftAggLowering::getCoerceAndExpandTypes(), GetConstantStringEntry(), clang::CodeGen::CodeGenFunction::getEHSelectorSlot(), llvm::DenseMapInfo< clang::BaseSubobject >::getEmptyKey(), llvm::DenseMapInfo< clang::CharUnits >::getEmptyKey(), GetGCAttrTypeForType(), clang::VTableComponent::getGlobalDecl(), getIdentSize(), clang::CodeGen::ABIArgInfo::getIndirectAlign(), getLowBit(), getMaxAtomicAccessSize(), clang::CodeGen::swiftcall::getNaturalAlignment(), clang::CodeGen::CodeGenFunction::getNaturalTypeAlignment(), getOffsetAtStartOfUnit(), getOffsetOfIdentField(), llvm::DenseMapInfo< clang::BaseSubobject >::getTombstoneKey(), llvm::DenseMapInfo< clang::CharUnits >::getTombstoneKey(), getTypeAllocSize(), getTypeStoreSize(), initializeForBlockHeader(), isArgInAlloca(), clang::CodeGen::CGBitFieldInfo::MakeInfo(), performTypeAdjustment(), recordUsesEBO(), roundUpSizeToCharAlignment(), clang::analyze_os_log::OSLogBufferLayout::size(), and clang::ASTContext::toCharUnitsFromBits().

◆ getQuantity()

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

getQuantity - Get the raw integer representation of this quantity.

Definition at line 179 of file CharUnits.h.

Referenced by addOrSubLValueAsInteger(), clang::CodeGen::CodeGenModule::AddVTableTypeMetadata(), ApplyNonVirtualAndVirtualOffset(), buildBlockDescriptor(), buildGlobalBlock(), buildMemcpyForAssignmentOp(), clang::ento::StoreManager::castRegion(), charUnitsToString(), CheckAggExprForMemSetUse(), computeBlockInfo(), ContainsFloatAtOffset(), clang::CodeGen::CGBuilderTy::CreateAlignedStore(), createLoadInstBefore(), clang::CodeGen::CGBuilderTy::CreateMemSet(), createRuntimeShuffleFunction(), clang::CodeGen::CGBuilderTy::CreateStore(), createStoreInstBefore(), detectAmbiguousBases(), clang::CodeGen::CodeGenFunction::EmitAsanPrologueOrEpilogue(), clang::CodeGen::CodeGenFunction::EmitConstructorBody(), emitCXXDestructor(), EmitCXXNewAllocSize(), clang::CodeGen::CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(), EmitDeclInvariant(), emitNonZeroVLAInit(), emitRoundPointerUpToAlignment(), emitRTtypeidCall(), clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(), clang::CodeGen::CodeGenFunction::EmitTypeCheck(), EmitX86_64VAArgFromMemory(), clang::CodeGen::AggValueSlot::forAddr(), clang::CodeGen::CodeGenFunction::ParamValue::forIndirect(), clang::CodeGen::CodeGenVTables::GenerateConstructionVTable(), GenerateStringLiteral(), clang::CodeGen::RValue::getAggregate(), GetAlignOfExpr(), clang::ento::MemRegion::getAsOffset(), getBadTypeidFn(), clang::CodeGen::CodeGenFunction::getBlockByrefInfo(), 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(), getTypeInfoVTable(), clang::CodeGen::CodeGenTBAA::getVTablePtrAccessInfo(), hasMRCWeakIvars(), initializeForBlockHeader(), clang::CodeGen::CodeGenFunction::InitTempAlloca(), isFullSizeType(), clang::CodeGen::SwiftABIInfo::isLegalVectorTypeForSwift(), clang::CodeGen::CGBlockInfo::Capture::makeIndex(), clang::CodeGen::CGBitFieldInfo::print(), PrintOffset(), 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(), clang::ASTContext::toBits(), 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 137 of file CharUnits.h.

Referenced by clang::CodeGen::swiftcall::SwiftAggLowering::addTypedData().

◆ isNegative()

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

isNegative - Test whether the quantity is less than zero.

Definition at line 125 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 122 of file CharUnits.h.

Referenced by clang::ASTContext::getObjCEncodingTypeSize().

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

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

◆ operator%() [1/2]

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

Definition at line 159 of file CharUnits.h.

References CharUnits().

◆ operator%() [2/2]

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

Definition at line 162 of file CharUnits.h.

◆ operator*()

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

Definition at line 142 of file CharUnits.h.

References CharUnits().

◆ operator*=()

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

Definition at line 145 of file CharUnits.h.

◆ operator+()

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

Definition at line 165 of file CharUnits.h.

References CharUnits().

◆ operator++() [1/2]

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

Definition at line 72 of file CharUnits.h.

◆ operator++() [2/2]

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

Definition at line 76 of file CharUnits.h.

References CharUnits().

◆ operator+=()

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

Definition at line 68 of file CharUnits.h.

◆ operator-() [1/2]

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

Definition at line 168 of file CharUnits.h.

References CharUnits().

◆ operator-() [2/2]

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

Definition at line 171 of file CharUnits.h.

References CharUnits().

◆ operator--() [1/2]

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

Definition at line 83 of file CharUnits.h.

◆ operator--() [2/2]

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

Definition at line 87 of file CharUnits.h.

References CharUnits().

◆ operator-=()

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

Definition at line 79 of file CharUnits.h.

◆ operator/() [1/2]

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

Definition at line 149 of file CharUnits.h.

References CharUnits().

◆ operator/() [2/2]

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

Definition at line 156 of file CharUnits.h.

◆ operator/=()

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

Definition at line 152 of file CharUnits.h.

◆ operator<()

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

Definition at line 100 of file CharUnits.h.

◆ operator<=()

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

Definition at line 103 of file CharUnits.h.

◆ operator==()

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

Definition at line 92 of file CharUnits.h.

◆ operator>()

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

Definition at line 106 of file CharUnits.h.

◆ operator>=()

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

Definition at line 109 of file CharUnits.h.

◆ Zero()

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

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