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


C++ DIArray类代码示例

本文整理汇总了C++中DIArray的典型用法代码示例。如果您正苦于以下问题:C++ DIArray类的具体用法?C++ DIArray怎么用?C++ DIArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DIArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getOrCreateArray

/// finalize - Construct any deferred debug info descriptors.
void DIBuilder::finalize() {
  DIArray Enums = getOrCreateArray(AllEnumTypes);
  DIType(TempEnumTypes).replaceAllUsesWith(Enums);

  DIArray RetainTypes = getOrCreateArray(AllRetainTypes);
  DIType(TempRetainTypes).replaceAllUsesWith(RetainTypes);

  DIArray SPs = getOrCreateArray(AllSubprograms);
  DIType(TempSubprograms).replaceAllUsesWith(SPs);
  for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
    DISubprogram SP(SPs.getElement(i));
    SmallVector<Value *, 4> Variables;
    if (NamedMDNode *NMD = getFnSpecificMDNode(M, SP)) {
      for (unsigned ii = 0, ee = NMD->getNumOperands(); ii != ee; ++ii)
        Variables.push_back(NMD->getOperand(ii));
      NMD->eraseFromParent();
    }
    if (MDNode *Temp = SP.getVariablesNodes()) {
      DIArray AV = getOrCreateArray(Variables);
      DIType(Temp).replaceAllUsesWith(AV);
    }
  }

  DIArray GVs = getOrCreateArray(AllGVs);
  DIType(TempGVs).replaceAllUsesWith(GVs);
}
开发者ID:ebraheemk,项目名称:llvm-picoblaze,代码行数:27,代码来源:DIBuilder.cpp

示例2: diDesc

void DIEItem::CreateChildren(wxTreeCtrl *tree, const wxTreeItemId& id) {
  DIDescriptor diDesc(node_);
  if (diDesc.isCompileUnit()) {
    CreateCompileUnitChildren(tree, id);
  } else if (diDesc.isSubprogram()) {
    CreateSubprogramChildren(tree, id);
  } else if (diDesc.isGlobalVariable()) {
    DIGlobalVariable diVar(node_);
    CreateChild(tree, id, new DIEItem(module_, diVar.getType()));
  } else if (diDesc.isCompositeType()) {
    DICompositeType diCompType(node_);
    DIArray typeArray = diCompType.getTypeArray();
    unsigned ct = typeArray.getNumElements();
    for (unsigned i = 0; i < ct; ++i) {
      CreateChild(tree, id, new DIEItem(module_, typeArray.getElement(i)));
    }
  } else if (diDesc.isDerivedType()) {
    DIDerivedType diDerivedType(node_);
    CreateChild(tree, id,
        new DIEItem(module_, diDerivedType.getTypeDerivedFrom()));
  } else if (diDesc.isVariable()) {
    DIVariable diVar(node_);
    CreateChild(tree, id, new DIEItem(module_, diVar.getType()));
  }
}
开发者ID:lht,项目名称:llbrowse,代码行数:25,代码来源:TreeView.cpp

示例3: processScope

void DebugInfoFinder::processType(DIType DT) {
  if (!addType(DT))
    return;
  processScope(DT.getContext().resolve(TypeIdentifierMap));
  if (DT.isCompositeType()) {
    DICompositeType DCT(DT);
    processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
    if (DT.isSubroutineType()) {
      DITypeArray DTA = DISubroutineType(DT).getTypeArray();
      for (unsigned i = 0, e = DTA.getNumElements(); i != e; ++i)
        processType(DTA.getElement(i).resolve(TypeIdentifierMap));
      return;
    }
    DIArray DA = DCT.getElements();
    for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
      DIDescriptor D = DA.getElement(i);
      if (D.isType())
        processType(DIType(D));
      else if (D.isSubprogram())
        processSubprogram(DISubprogram(D));
    }
  } else if (DT.isDerivedType()) {
    DIDerivedType DDT(DT);
    processType(DDT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
  }
}
开发者ID:cschreiner,项目名称:llvm,代码行数:26,代码来源:DebugInfo.cpp

示例4: diType

void DebugDatabase::addType(MDNode *type) {
    DIType diType(type);

    string query;

    query = "INSERT INTO VariableType ";
    query +=
        "(designId, dw_tag, name, size, alignment, offset, derivedTypeId) ";
    query += "VALUES (" + std::to_string(designId);
    query += "," + std::to_string(diType.getTag());
    query += "," + addQuotesToStr(diType.getName().str());
    query += "," + std::to_string(diType.getSizeInBits());
    query += "," + std::to_string(diType.getAlignInBits());
    query += "," + std::to_string(diType.getOffsetInBits());

    if (diType.isBasicType()) {
        query += ",NULL";
    } else if (diType.isDerivedType()) {
        DIDerivedType typeDerived(type);
        MDNode *derivedMD = typeDerived.getTypeDerivedFrom().resolve(typeMap);
        if (derivedMD)
            query += "," + std::to_string(getTypeId(derivedMD));
        else
            query += ",NULL";
    } else {
        assert(false);
    }
    query += ");";

    runQuery(query);

    int typeId = mysql_insert_id(connection);
    typeToIds[&(*type)] = typeId;

    if (diType.isCompositeType()) {
        DICompositeType typeComposite(type);

        DIArray members = typeComposite.getTypeArray();
        for (unsigned int i = 0; i < members.getNumElements(); ++i) {
            DIDescriptor s = members.getElement(i);
            query = "INSERT INTO VariableTypeMember ";
            query +=
                "(ownerVariableTypeId, idx, variableTypeId, subrangeCount) ";
            query += "VALUES (" + std::to_string(typeId);
            query += "," + std::to_string(i);
            if (s.isSubrange()) {
                DISubrange subRange = (DISubrange)s;
                assert(subRange.getLo() == 0);
                query += ",NULL";
                query += "," + std::to_string(subRange.getCount());
            } else if (s.isType()) {
                MDNode *mdNode = &*s;
                query += "," + std::to_string(getTypeId(mdNode));
                query += ",NULL";
            }
            query += ");";
            runQuery(query);
        }
    }
}
开发者ID:eddiehung,项目名称:dox-legup,代码行数:60,代码来源:DebugDatabase.cpp

示例5: addUInt

/// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
void CompileUnit::constructArrayTypeDIE(DIE &Buffer,
                                        DICompositeType *CTy) {
  Buffer.setTag(dwarf::DW_TAG_array_type);
  if (CTy->getTag() == dwarf::DW_TAG_vector_type)
    addUInt(&Buffer, dwarf::DW_AT_GNU_vector, dwarf::DW_FORM_flag, 1);

  // Emit derived type.
  addType(&Buffer, CTy->getTypeDerivedFrom());
  DIArray Elements = CTy->getTypeArray();

  // Get an anonymous type for index type.
  DIE *IdxTy = getIndexTyDie();
  if (!IdxTy) {
    // Construct an anonymous type for index type.
    IdxTy = new DIE(dwarf::DW_TAG_base_type);
    addUInt(IdxTy, dwarf::DW_AT_byte_size, 0, sizeof(int32_t));
    addUInt(IdxTy, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
            dwarf::DW_ATE_signed);
    addDie(IdxTy);
    setIndexTyDie(IdxTy);
  }

  // Add subranges to array type.
  for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
    DIDescriptor Element = Elements.getElement(i);
    if (Element.getTag() == dwarf::DW_TAG_subrange_type)
      constructSubrangeDIE(Buffer, DISubrange(Element), IdxTy);
  }
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例6: AddOperand

// Add an operand to an existing MDNode. The new operand will be added at the
// back of the operand list.
static void AddOperand(DICompileUnit CU, DIArray SPs, Metadata *NewSP) {
  SmallVector<Metadata *, 16> NewSPs;
  NewSPs.reserve(SPs->getNumOperands() + 1);
  for (unsigned I = 0, E = SPs->getNumOperands(); I != E; ++I)
    NewSPs.push_back(SPs->getOperand(I));
  NewSPs.push_back(NewSP);
  CU.replaceSubprograms(DIArray(MDNode::get(CU->getContext(), NewSPs)));
}
开发者ID:Fairly,项目名称:opencor,代码行数:10,代码来源:CloneFunction.cpp

示例7: LLVMDIBuilderGetOrCreateArray

LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Dref,
                                              LLVMMetadataRef *Data,
                                              size_t Length) {
  DIBuilder *D = unwrap(Dref);
  Metadata **DataValue = unwrap(Data);
  ArrayRef<Metadata *> Elements(DataValue, Length);
  DIArray A = D->getOrCreateArray(Elements);
  return wrap(A.get());
}
开发者ID:B1ackCat,项目名称:llvm-dsa,代码行数:9,代码来源:DIBuilderBindings.cpp

示例8: CU

void GCOVProfiler::emitGCNO() {
  NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
  if (!CU_Nodes) return;

  for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
    // Each compile unit gets its own .gcno file. This means that whether we run
    // this pass over the original .o's as they're produced, or run it after
    // LTO, we'll generate the same .gcno files.

    DICompileUnit CU(CU_Nodes->getOperand(i));
    std::string ErrorInfo;
    raw_fd_ostream out(mangleName(CU, "gcno").c_str(), ErrorInfo,
                       raw_fd_ostream::F_Binary);
    if (!Use402Format)
      out.write("oncg*404MVLL", 12);
    else
      out.write("oncg*204MVLL", 12);

    DIArray SPs = CU.getSubprograms();
    for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
      DISubprogram SP(SPs.getElement(i));
      if (!SP.Verify()) continue;

      Function *F = SP.getFunction();
      if (!F) continue;
      GCOVFunction Func(SP, &out, Use402Format, UseExtraChecksum);

      for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
        GCOVBlock &Block = Func.getBlock(BB);
        TerminatorInst *TI = BB->getTerminator();
        if (int successors = TI->getNumSuccessors()) {
          for (int i = 0; i != successors; ++i) {
            Block.addEdge(Func.getBlock(TI->getSuccessor(i)));
          }
        } else if (isa<ReturnInst>(TI)) {
          Block.addEdge(Func.getReturnBlock());
        }

        uint32_t Line = 0;
        for (BasicBlock::iterator I = BB->begin(), IE = BB->end();
             I != IE; ++I) {
          const DebugLoc &Loc = I->getDebugLoc();
          if (Loc.isUnknown()) continue;
          if (Line == Loc.getLine()) continue;
          Line = Loc.getLine();
          if (SP != getDISubprogram(Loc.getScope(*Ctx))) continue;

          GCOVLines &Lines = Block.getFile(SP.getFilename());
          Lines.addLine(Loc.getLine());
        }
      }
      Func.writeOut();
    }
    out.write("\0\0\0\0\0\0\0\0", 8);  // EOF
    out.close();
  }
}
开发者ID:chandlerc,项目名称:llvm-hacking,代码行数:57,代码来源:GCOVProfiling.cpp

示例9: getTypeArray

void DICompositeType::addMember(DIDescriptor D) {
  SmallVector<llvm::Value *, 16> M;
  DIArray OrigM = getTypeArray();
  unsigned Elements = OrigM.getNumElements();
  if (Elements == 1 && !OrigM.getElement(0))
    Elements = 0;
  M.reserve(Elements + 1);
  for (unsigned i = 0; i != Elements; ++i)
    M.push_back(OrigM.getElement(i));
  M.push_back(D);
  setTypeArray(DIArray(MDNode::get(DbgNode->getContext(), M)));
}
开发者ID:biometrics,项目名称:llvm,代码行数:12,代码来源:DebugInfo.cpp

示例10: addTemplateParams

/// addTemplateParams - Add template parameters in buffer.
void CompileUnit::addTemplateParams(DIE &Buffer, DIArray TParams) {
  // Add template parameters.
  for (unsigned i = 0, e = TParams.getNumElements(); i != e; ++i) {
    DIDescriptor Element = TParams.getElement(i);
    if (Element.isTemplateTypeParameter())
      Buffer.addChild(getOrCreateTemplateTypeParameterDIE(
                        DITemplateTypeParameter(Element)));
    else if (Element.isTemplateValueParameter())
      Buffer.addChild(getOrCreateTemplateValueParameterDIE(
                        DITemplateValueParameter(Element)));
  }

}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例11: addPubTypes

/// addPubTypes - Add type for pubtypes section.
void CompileUnit::addPubTypes(DISubprogram SP) {
  DICompositeType SPTy = SP.getType();
  unsigned SPTag = SPTy.getTag();
  if (SPTag != dwarf::DW_TAG_subroutine_type)
    return;

  DIArray Args = SPTy.getTypeArray();
  for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) {
    DIType ATy(Args.getElement(i));
    if (!ATy.Verify())
      continue;
    addGlobalType(ATy);
  }
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例12: processSubprograms

void Matcher::processSubprograms(DICompileUnit &DICU)
{
  if (DICU.getRunTimeVersion() > LLVMDebugVersion10) {
    DIArray SPs = DICU.getSubprograms();
    for (unsigned i = 0, e = SPs.getNumElements(); i != e; i++) {
      DISubprogram DISP(SPs.getElement(i));
      DISPCopy Copy(DISP);
      if (Copy.name.empty() || Copy.filename.empty() || Copy.linenumber == 0)
        continue;
      Copy.lastline = ScopeInfoFinder::getLastLine(Copy.function);
      MySPs.push_back(Copy);
    }
  }
}
开发者ID:sdasgup3,项目名称:llvm-slicer,代码行数:14,代码来源:Matcher.cpp

示例13: CreateCompositeTypeEx

/// CreateCompositeType - Create a composite type like array, struct, etc.
DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag,
                                                 DIDescriptor Context,
                                                 const char * Name,
                                                 DICompileUnit CompileUnit,
                                                 unsigned LineNumber,
                                                 Constant *SizeInBits,
                                                 Constant *AlignInBits,
                                                 Constant *OffsetInBits,
                                                 unsigned Flags,
                                                 DIType DerivedFrom,
                                                 DIArray Elements,
                                                 unsigned RuntimeLang) {

  Value *Elts[] = {
    GetTagConstant(Tag),
    Context.getNode(),
    MDString::get(VMContext, Name),
    CompileUnit.getNode(),
    ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
    SizeInBits,
    AlignInBits,
    OffsetInBits,
    ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
    DerivedFrom.getNode(),
    Elements.getNode(),
    ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang)
  };
  return DICompositeType(MDNode::get(VMContext, &Elts[0], 12));
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例14: processScope

void DebugInfoFinder::processSubprogram(DISubprogram SP) {
  if (!addSubprogram(SP))
    return;
  processScope(SP.getContext().resolve(TypeIdentifierMap));
  processType(SP.getType());
  DIArray TParams = SP.getTemplateParams();
  for (unsigned I = 0, E = TParams.getNumElements(); I != E; ++I) {
    DIDescriptor Element = TParams.getElement(I);
    if (Element.isTemplateTypeParameter()) {
      DITemplateTypeParameter TType(Element);
      processType(TType.getType().resolve(TypeIdentifierMap));
    } else if (Element.isTemplateValueParameter()) {
      DITemplateValueParameter TVal(Element);
      processType(TVal.getType().resolve(TypeIdentifierMap));
    }
  }
}
开发者ID:RichardsonAlex,项目名称:llvm,代码行数:17,代码来源:DebugInfo.cpp

示例15: CUNode

llvm::DenseMap<const llvm::Function *, llvm::DISubprogram>
llvm::makeSubprogramMap(const Module &M) {
  DenseMap<const Function *, DISubprogram> R;

  NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu");
  if (!CU_Nodes)
    return R;

  for (MDNode *N : CU_Nodes->operands()) {
    DICompileUnit CUNode(N);
    DIArray SPs = CUNode.getSubprograms();
    for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
      DISubprogram SP(SPs.getElement(i));
      if (Function *F = SP.getFunction())
        R.insert(std::make_pair(F, SP));
    }
  }
  return R;
}
开发者ID:cschreiner,项目名称:llvm,代码行数:19,代码来源:DebugInfo.cpp


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