本文整理汇总了C++中GlobalVariable::getContext方法的典型用法代码示例。如果您正苦于以下问题:C++ GlobalVariable::getContext方法的具体用法?C++ GlobalVariable::getContext怎么用?C++ GlobalVariable::getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalVariable
的用法示例。
在下文中一共展示了GlobalVariable::getContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mapAppendingVariable
void Mapper::mapAppendingVariable(GlobalVariable &GV, Constant *InitPrefix,
bool IsOldCtorDtor,
ArrayRef<Constant *> NewMembers) {
SmallVector<Constant *, 16> Elements;
if (InitPrefix) {
unsigned NumElements =
cast<ArrayType>(InitPrefix->getType())->getNumElements();
for (unsigned I = 0; I != NumElements; ++I)
Elements.push_back(InitPrefix->getAggregateElement(I));
}
PointerType *VoidPtrTy;
Type *EltTy;
if (IsOldCtorDtor) {
// FIXME: This upgrade is done during linking to support the C API. See
// also IRLinker::linkAppendingVarProto() in IRMover.cpp.
VoidPtrTy = Type::getInt8Ty(GV.getContext())->getPointerTo();
auto &ST = *cast<StructType>(NewMembers.front()->getType());
Type *Tys[3] = {ST.getElementType(0), ST.getElementType(1), VoidPtrTy};
EltTy = StructType::get(GV.getContext(), Tys, false);
}
for (auto *V : NewMembers) {
Constant *NewV;
if (IsOldCtorDtor) {
auto *S = cast<ConstantStruct>(V);
auto *E1 = cast<Constant>(mapValue(S->getOperand(0)));
auto *E2 = cast<Constant>(mapValue(S->getOperand(1)));
Constant *Null = Constant::getNullValue(VoidPtrTy);
NewV = ConstantStruct::get(cast<StructType>(EltTy), E1, E2, Null);
} else {
NewV = cast_or_null<Constant>(mapValue(V));
}
Elements.push_back(NewV);
}
GV.setInitializer(ConstantArray::get(
cast<ArrayType>(GV.getType()->getElementType()), Elements));
}