clang: lib/AST/ByteCode/InterpBuiltinBitCast.cpp File Reference (original) (raw)

Go to the source code of this file.

Functions
static bool enumerateData (const Pointer &P, const Context &Ctx, Bits Offset, Bits BitsToRead, DataFunc F)
We use this to recursively iterate over all fields and elements of a pointer and extract relevant data for a bitcast.
static bool enumeratePointerFields (const Pointer &P, const Context &Ctx, Bits BitsToRead, DataFunc F)
static bool CheckBitcastType (InterpState &S, CodePtr OpPC, QualType T, bool IsToType)

BITCAST_TYPE_SWITCH

| #define BITCAST_TYPE_SWITCH | ( | | Expr, | | ----------------------------- | - | | ------------------------------------ | | | B | | | | | ) | | | |

Value:

do { \

switch (Expr) { \

TYPE_SWITCH_CASE(PT_Bool, B) \

default: \

llvm_unreachable("Unhandled bitcast type"); \

} \

} while (0)

This represents one expression.

Definition at line 40 of file InterpBuiltinBitCast.cpp.

BITCAST_TYPE_SWITCH_FIXED_SIZE

| #define BITCAST_TYPE_SWITCH_FIXED_SIZE | ( | | Expr, | | ------------------------------------------ | - | | ------------------------------------ | | | B | | | | | ) | | | |

Value:

do { \

switch (Expr) { \

TYPE_SWITCH_CASE(PT_Bool, B) \

default: \

llvm_unreachable("Unhandled bitcast type"); \

} \

} while (0)

Definition at line 59 of file InterpBuiltinBitCast.cpp.

DataFunc

Implement __builtin_bit_cast and related operations.

Since our internal representation for data is more complex than something we can simply memcpy or memcmp, we first bitcast all the data into a buffer, which we then later use to copy the data into the target. Used to iterate over pointer fields.

Definition at line 36 of file InterpBuiltinBitCast.cpp.

CheckBitcastType()

Definition at line 170 of file InterpBuiltinBitCast.cpp.

References CheckBitcastType(), E, clang::Type::getAs(), clang::Type::getAsRecordDecl(), clang::Sema::getASTContext(), clang::ASTContext::getBaseElementType(), clang::ASTContext::getCharWidth(), clang::ASTContext::getFloatTypeSemantics(), clang::Stmt::getSourceRange(), clang::ASTContext::getTypeSize(), clang::Type::isArrayType(), clang::Type::isExtVectorBoolType(), clang::Type::isMemberPointerType(), clang::Type::isPointerType(), clang::Type::isRealFloatingType(), clang::Type::isUnionType(), and clang::T.

Referenced by CheckBitcastType(), clang::interp::DoBitCast(), and clang::interp::DoBitCastPtr().

enumerateData()

We use this to recursively iterate over all fields and elements of a pointer and extract relevant data for a bitcast.

Definition at line 78 of file InterpBuiltinBitCast.cpp.

References clang::interp::Record::bases(), clang::interp::Context::classify(), clang::interp::Descriptor::ElemRecord, enumerateData(), clang::interp::Record::fields(), clang::interp::Context::getASTContext(), clang::ASTContext::getASTRecordLayout(), clang::ASTRecordLayout::getBaseClassOffset(), clang::interp::Record::getDecl(), clang::interp::Descriptor::getElemQualType(), clang::ASTRecordLayout::getFieldOffset(), clang::interp::Descriptor::getNumElems(), clang::interp::Descriptor::getPrimType(), clang::interp::Descriptor::getType(), clang::ASTContext::getTypeSize(), clang::interp::Pointer::initialize(), clang::interp::Descriptor::isCompositeArray(), clang::Type::isExtVectorBoolType(), clang::interp::Descriptor::isPrimitive(), clang::interp::Descriptor::isPrimitiveArray(), clang::interp::Descriptor::isRecord(), Ok, P, and clang::ASTContext::toBits().

Referenced by enumerateData(), and enumeratePointerFields().

enumeratePointerFields()