当前位置: 首页>>代码示例>>C++>>正文


C++ DIBuilder::insertDeclare方法代码示例

本文整理汇总了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;
}
开发者ID:Sumith1896,项目名称:precimonious,代码行数:60,代码来源:Variables.cpp

示例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);
}
开发者ID:go-llvm,项目名称:llvm,代码行数:9,代码来源:dibuilder.cpp

示例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);
}
开发者ID:Drup,项目名称:llvm,代码行数:11,代码来源:DIBuilderBindings.cpp

示例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);
}
开发者ID:RodneyBates,项目名称:M3Devel,代码行数:14,代码来源:DIBuilderBindings.cpp

示例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);
}
开发者ID:1995hnagamin,项目名称:llvm,代码行数:15,代码来源:DIBuilderBindings.cpp


注:本文中的DIBuilder::insertDeclare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。