本文整理汇总了C++中CodeGenTypes::isRecordLayoutComplete方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenTypes::isRecordLayoutComplete方法的具体用法?C++ CodeGenTypes::isRecordLayoutComplete怎么用?C++ CodeGenTypes::isRecordLayoutComplete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenTypes
的用法示例。
在下文中一共展示了CodeGenTypes::isRecordLayoutComplete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/// isSafeToConvert - Return true if it is safe to convert the specified record
/// decl to IR and lay it out, false if doing so would cause us to get into a
/// recursive compilation mess.
static bool
isSafeToConvert(const RecordDecl *RD, CodeGenTypes &CGT,
llvm::SmallPtrSet<const RecordDecl*, 16> &AlreadyChecked) {
// If we have already checked this type (maybe the same type is used by-value
// multiple times in multiple structure fields, don't check again.
if (!AlreadyChecked.insert(RD)) return true;
const Type *Key = CGT.getContext().getTagDeclType(RD).getTypePtr();
// If this type is already laid out, converting it is a noop.
if (CGT.isRecordLayoutComplete(Key)) return true;
// If this type is currently being laid out, we can't recursively compile it.
if (CGT.isRecordBeingLaidOut(Key))
return false;
// If this type would require laying out bases that are currently being laid
// out, don't do it. This includes virtual base classes which get laid out
// when a class is translated, even though they aren't embedded by-value into
// the class.
if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
for (CXXRecordDecl::base_class_const_iterator I = CRD->bases_begin(),
E = CRD->bases_end(); I != E; ++I)
if (!isSafeToConvert(I->getType()->getAs<RecordType>()->getDecl(),
CGT, AlreadyChecked))
return false;
}
// If this type would require laying out members that are currently being laid
// out, don't do it.
for (RecordDecl::field_iterator I = RD->field_begin(),
E = RD->field_end(); I != E; ++I)
if (!isSafeToConvert(I->getType(), CGT, AlreadyChecked))
return false;
// If there are no problems, lets do it.
return true;
}