本文整理汇总了C++中ASTContext::getASTRecordLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTContext::getASTRecordLayout方法的具体用法?C++ ASTContext::getASTRecordLayout怎么用?C++ ASTContext::getASTRecordLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTContext
的用法示例。
在下文中一共展示了ASTContext::getASTRecordLayout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
static uint64_t
ComputeNonVirtualBaseClassOffset(ASTContext &Context, CXXBasePaths &Paths,
unsigned Start) {
uint64_t Offset = 0;
const CXXBasePath &Path = Paths.front();
for (unsigned i = Start, e = Path.size(); i != e; ++i) {
const CXXBasePathElement& Element = Path[i];
// Get the layout.
const ASTRecordLayout &Layout = Context.getASTRecordLayout(Element.Class);
const CXXBaseSpecifier *BS = Element.Base;
// FIXME: enable test3 from virt.cc to not abort.
if (BS->isVirtual())
return 0;
assert(!BS->isVirtual() && "Should not see virtual bases here!");
const CXXRecordDecl *Base =
cast<CXXRecordDecl>(BS->getType()->getAs<RecordType>()->getDecl());
// Add the offset.
Offset += Layout.getBaseClassOffset(Base) / 8;
}
return Offset;
}
示例2: Ctx
VTTBuilder::VTTBuilder(ASTContext &Ctx,
const CXXRecordDecl *MostDerivedClass,
bool GenerateDefinition)
: Ctx(Ctx), MostDerivedClass(MostDerivedClass),
MostDerivedClassLayout(Ctx.getASTRecordLayout(MostDerivedClass)),
GenerateDefinition(GenerateDefinition) {
// Lay out this VTT.
LayoutVTT(BaseSubobject(MostDerivedClass, CharUnits::Zero()),
/*BaseIsVirtual=*/false);
}
示例3: assert
static void
AddIndirectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context,
CXXIndirectPrimaryBaseSet& Bases) {
// If the record has a virtual primary base class, add it to our set.
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
if (Layout.isPrimaryBaseVirtual())
Bases.insert(Layout.getPrimaryBase());
for (const auto &I : RD->bases()) {
assert(!I.getType()->isDependentType() &&
"Cannot get indirect primary bases for class with dependent bases.");
const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(I.getType()->castAs<RecordType>()->getDecl());
// Only bases with virtual bases participate in computing the
// indirect primary virtual base classes.
if (BaseDecl->getNumVBases())
AddIndirectPrimaryBases(BaseDecl, Context, Bases);
}
}