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


C++ DICompileUnit::getRetainedTypes方法代码示例

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


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

示例1: processModule

void DebugInfoFinder::processModule(const Module &M) {
  InitializeTypeMap(M);
  if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
    for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
      DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
      addCompileUnit(CU);
      for (DIGlobalVariable DIG : CU->getGlobalVariables()) {
        if (addGlobalVariable(DIG)) {
          processScope(DIG.getContext());
          processType(DIG.getType().resolve(TypeIdentifierMap));
        }
      }
      for (auto *SP : CU->getSubprograms())
        processSubprogram(SP);
      for (auto *ET : CU->getEnumTypes())
        processType(ET);
      for (auto *RT : CU->getRetainedTypes())
        processType(RT);
      for (DIImportedEntity Import : CU->getImportedEntities()) {
        DIDescriptor Entity = Import.getEntity().resolve(TypeIdentifierMap);
        if (auto *T = dyn_cast<MDType>(Entity))
          processType(T);
        else if (auto *SP = dyn_cast<MDSubprogram>(Entity))
          processSubprogram(SP);
        else if (auto *NS = dyn_cast<MDNamespace>(Entity))
          processScope(NS->getScope());
      }
    }
  }
}
开发者ID:kunhuahuang,项目名称:llvm,代码行数:30,代码来源:DebugInfo.cpp

示例2:

DITypeIdentifierMap
llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) {
  DITypeIdentifierMap Map;
  for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
    DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(CUi));
    DIArray Retain = CU.getRetainedTypes();
    for (unsigned Ti = 0, Te = Retain.size(); Ti != Te; ++Ti) {
      if (!isa<MDCompositeType>(Retain[Ti]))
        continue;
      DICompositeType Ty = cast<MDCompositeType>(Retain[Ti]);
      if (MDString *TypeId = Ty.getIdentifier()) {
        // Definition has priority over declaration.
        // Try to insert (TypeId, Ty) to Map.
        std::pair<DITypeIdentifierMap::iterator, bool> P =
            Map.insert(std::make_pair(TypeId, Ty));
        // If TypeId already exists in Map and this is a definition, replace
        // whatever we had (declaration or definition) with the definition.
        if (!P.second && !Ty.isForwardDecl())
          P.first->second = Ty;
      }
    }
  }
  return Map;
}
开发者ID:kunhuahuang,项目名称:llvm,代码行数:24,代码来源:DebugInfo.cpp


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