本文整理汇总了C++中ConstantStruct::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantStruct::getType方法的具体用法?C++ ConstantStruct::getType怎么用?C++ ConstantStruct::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantStruct
的用法示例。
在下文中一共展示了ConstantStruct::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doFinalization
bool CheckInserter::doFinalization(Module &M) {
// We couldn't directly add an element to a constant array, because doing so
// changes the type of the constant array.
// element type of llvm.global_ctors
StructType *ST = StructType::get(IntType,
PointerType::getUnqual(InitFiniType),
NULL); // end with null
// Move all existing elements of <GlobalName> to <Constants>.
vector<Constant *> Constants;
if (GlobalVariable *GlobalCtors = M.getNamedGlobal("llvm.global_ctors")) {
ConstantArray *CA = cast<ConstantArray>(GlobalCtors->getInitializer());
for (unsigned j = 0; j < CA->getNumOperands(); ++j) {
ConstantStruct *CS = cast<ConstantStruct>(CA->getOperand(j));
assert(CS->getType() == ST);
// Assume nobody is using the highest priority, so that <F> will be the
// first to run as a ctor.
assert(!cast<ConstantInt>(CS->getOperand(0))->isMinValue(true));
Constants.push_back(CS);
}
GlobalCtors->eraseFromParent();
}
// Add <F> with the highest priority.
Constants.push_back(ConstantStruct::get(ST,
ConstantInt::get(IntType, INT_MIN),
EnterProcess,
NULL));
// Create the new llvm.global_ctors.
ArrayType *ArrType = ArrayType::get(ST, Constants.size());
new GlobalVariable(M,
ArrType,
true,
GlobalValue::AppendingLinkage,
ConstantArray::get(ArrType, Constants),
"llvm.global_ctors");
return true;
}