本文整理汇总了C++中recorddecl::field_iterator::isBitField方法的典型用法代码示例。如果您正苦于以下问题:C++ field_iterator::isBitField方法的具体用法?C++ field_iterator::isBitField怎么用?C++ field_iterator::isBitField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类recorddecl::field_iterator
的用法示例。
在下文中一共展示了field_iterator::isBitField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accumulateFields
void CGRecordLowering::accumulateFields() {
for (RecordDecl::field_iterator Field = D->field_begin(),
FieldEnd = D->field_end();
Field != FieldEnd;)
if (Field->isBitField()) {
RecordDecl::field_iterator Start = Field;
// Iterate to gather the list of bitfields.
for (++Field; Field != FieldEnd && Field->isBitField(); ++Field);
accumulateBitFields(Start, Field);
} else {
Members.push_back(MemberInfo(
bitsToCharUnits(getFieldBitOffset(*Field)), MemberInfo::Field,
getStorageType(*Field), *Field));
++Field;
}
}
示例2: GetFields
bool GetFields( RecordDecl * rd, Obj * entries) {
//check the fields of this struct, if any one of them is not understandable, then this struct becomes 'opaque'
//that is, we insert the type, and link it to its llvm type, so it can be used in terra code
//but none of its fields are exposed (since we don't understand the layout)
bool opaque = false;
for(RecordDecl::field_iterator it = rd->field_begin(), end = rd->field_end(); it != end; ++it) {
if(it->isBitField() || it->isAnonymousStructOrUnion() || !it->getDeclName()) {
opaque = true;
continue;
}
DeclarationName declname = it->getDeclName();
std::string declstr = declname.getAsString();
QualType FT = it->getType();
Obj fobj;
if(!GetType(FT,&fobj)) {
opaque = true;
continue;
}
lua_newtable(L);
fobj.push();
lua_setfield(L,-2,"type");
lua_pushstring(L,declstr.c_str());
lua_setfield(L,-2,"field");
entries->addentry();
}
return !opaque;
}
示例3: LayoutUnion
void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
assert(D->isUnion() && "Can't call LayoutUnion on a non-union record!");
const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(D);
const llvm::Type *Ty = 0;
uint64_t Size = 0;
unsigned Align = 0;
bool HasOnlyZeroSizedBitFields = true;
unsigned FieldNo = 0;
for (RecordDecl::field_iterator Field = D->field_begin(),
FieldEnd = D->field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
assert(Layout.getFieldOffset(FieldNo) == 0 &&
"Union field offset did not start at the beginning of record!");
if (Field->isBitField()) {
uint64_t FieldSize =
Field->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue();
// Ignore zero sized bit fields.
if (FieldSize == 0)
continue;
// Add the bit field info.
Types.addBitFieldInfo(*Field, 0, 0, FieldSize);
} else
Types.addFieldInfo(*Field, 0);
HasOnlyZeroSizedBitFields = false;
const llvm::Type *FieldTy =
Types.ConvertTypeForMemRecursive(Field->getType());
unsigned FieldAlign = Types.getTargetData().getABITypeAlignment(FieldTy);
uint64_t FieldSize = Types.getTargetData().getTypeAllocSize(FieldTy);
if (FieldAlign < Align)
continue;
if (FieldAlign > Align || FieldSize > Size) {
Ty = FieldTy;
Align = FieldAlign;
Size = FieldSize;
}
}
// Now add our field.
if (Ty) {
AppendField(0, Ty);
if (getTypeAlignment(Ty) > Layout.getAlignment() / 8) {
// We need a packed struct.
Packed = true;
Align = 1;
}
}
if (!Align) {
assert(HasOnlyZeroSizedBitFields &&
"0-align record did not have all zero-sized bit-fields!");
Align = 1;
}
// Append tail padding.
if (Layout.getSize() / 8 > Size)
AppendPadding(Layout.getSize() / 8, Align);
}