本文整理汇总了C++中DIBuilder::insertDeclare方法的典型用法代码示例。如果您正苦于以下问题:C++ DIBuilder::insertDeclare方法的具体用法?C++ DIBuilder::insertDeclare怎么用?C++ DIBuilder::insertDeclare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIBuilder
的用法示例。
在下文中一共展示了DIBuilder::insertDeclare方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateMetadata
void Variables::updateMetadata(Module& module, Value* oldTarget, Value* newTarget, Type* newType) {
vector<Instruction*> to_remove;
if (newTarget) {
errs() << "\tChanging metadata for: " << newTarget->getName() << "\n";
bool changed = false;
for(Module::iterator f = module.begin(), fe = module.end(); f != fe; f++) {
for(Function::iterator b = f->begin(), be = f->end(); b != be; b++) {
for(BasicBlock::iterator i = b->begin(), ie = b->end(); i != ie; i++) {
if (DbgDeclareInst *oldDeclare = dyn_cast<DbgDeclareInst>(i)) {
if (Value *address = oldDeclare->getAddress()) {
if (AllocaInst *allocaInst = dyn_cast<AllocaInst>(address)) {
if (allocaInst == oldTarget) { // the alloca we are looking for
DIVariable oldDIVar(oldDeclare->getVariable());
MDNode* newDIType = getTypeMetadata(module, oldDIVar, newType);
// construct new DIVariable with new type descriptor
vector<Value*> doperands;
for(unsigned i = 0; i < oldDIVar->getNumOperands(); i++) {
if (i == 5) { // the argument that corresponds to the type descriptor
doperands.push_back(newDIType);
}
else {
doperands.push_back(oldDIVar->getOperand(i)); // preserve other descriptors
}
}
ArrayRef<Value*> *arrayRefDOperands = new ArrayRef<Value*>(doperands);
MDNode* newMDNode = MDNode::get(module.getContext(), *arrayRefDOperands);
DIVariable newDIVar(newMDNode);
// insert new declare instruction
DIBuilder* builder = new DIBuilder(module);
Instruction *newDeclare = builder->insertDeclare(newTarget, newDIVar, oldDeclare);
// make sure the declare instruction preserves its own metadata
unsigned id = 0;
if (oldDeclare->getMetadata(id)) {
newDeclare->setMetadata(id, oldDeclare->getMetadata(id));
}
to_remove.push_back(oldDeclare); // can't erase while iterating through instructions
changed = true;
}
}
}
}
}
}
}
for(unsigned i = 0; i < to_remove.size(); i++) {
to_remove[i]->eraseFromParent();
}
if (!changed) {
errs() << "\tNo metadata to change\n";
}
}
return;
}
示例2: DIBuilderInsertDeclareAtEnd
LLVMValueRef DIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef dref,
LLVMValueRef storage,
LLVMValueRef varInfo,
LLVMBasicBlockRef block) {
DIBuilder *d = unwrap(dref);
Instruction *instr = d->insertDeclare(
unwrap(storage), unwrapDI<DIVariable>(varInfo), unwrap(block));
return wrap(instr);
}
示例3: LLVMDIBuilderInsertDeclareAtEnd
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Dref,
LLVMValueRef Storage,
LLVMValueRef VarInfo,
LLVMValueRef Expr,
LLVMBasicBlockRef Block) {
DIBuilder *D = unwrap(Dref);
Instruction *Instr =
D->insertDeclare(unwrap(Storage), unwrapDI<DIVariable>(VarInfo),
unwrapDI<DIExpression>(Expr), unwrap(Block));
return wrap(Instr);
}
示例4: LLVMDIBuilderInsertDeclareAtEnd
//could do the before equivs of the next 2
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
LLVMDIBuilderRef D,
LLVMValueRef Storage,
LLVMValueRef VarInfo,
LLVMBasicBlockRef Block)
{
DIBuilder *db = unwrap(D);
Instruction *Instr = db->insertDeclare(
unwrap(Storage),
unwrapDI<DIVariable>(VarInfo),
unwrap(Block));
return wrap(Instr);
}
示例5: LLVMDIBuilderInsertDeclareAtEnd
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Dref,
LLVMValueRef Storage,
LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr,
LLVMBasicBlockRef Block) {
// Fail immediately here until the llgo folks update their bindings. The
// called function is going to assert out anyway.
llvm_unreachable("DIBuilder API change requires a DebugLoc");
DIBuilder *D = unwrap(Dref);
Instruction *Instr = D->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), /* DebugLoc */ nullptr, unwrap(Block));
return wrap(Instr);
}