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


C++ IRGenFunction::getDebugScope方法代码示例

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


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

示例1: maybeEmitDebugInfoForLocalTypeData

static void maybeEmitDebugInfoForLocalTypeData(IRGenFunction &IGF,
                                               LocalTypeDataKey key,
                                               MetadataResponse value) {
  // FIXME: This check doesn't entirely behave correctly for non-transparent
  // functions that were inlined into transparent functions. Correct would be to
  // check which instruction requests the type metadata and see whether its
  // inlined function is transparent.
  auto * DS = IGF.getDebugScope();
  if (DS && DS->getInlinedFunction() &&
      DS->getInlinedFunction()->isTransparent())
    return;
  
  // Only for formal type metadata.
  if (key.Kind != LocalTypeDataKind::forFormalTypeMetadata())
    return;

  // Only for archetypes, and not for opened archetypes.
  auto type = dyn_cast<ArchetypeType>(key.Type);
  if (!type)
    return;
  if (type->getOpenedExistentialType())
    return;

  llvm::Value *data = value.getMetadata();

  // At -O0, create an alloca to keep the type alive.
  auto name = type->getFullName();
  if (!IGF.IGM.IRGen.Opts.shouldOptimize()) {
    auto alloca =
        IGF.createAlloca(data->getType(), IGF.IGM.getPointerAlignment(), name);
    IGF.Builder.CreateStore(data, alloca);
    data = alloca.getAddress();
  }

  // Only if debug info is enabled.
  if (!IGF.IGM.DebugInfo)
    return;

  // Emit debug info for the metadata.
  llvm::SmallString<8> AssocType;
  auto *oocTy = type->mapTypeOutOfContext().getPointer();
  {
    llvm::raw_svector_ostream OS(AssocType);
    while (auto *dependentMemberType = dyn_cast<DependentMemberType>(oocTy)) {
      OS << '.' << dependentMemberType->getName();
      oocTy = dependentMemberType->getBase().getPointer();
    }
  }
  auto *typeParam = cast<GenericTypeParamType>(oocTy);
  IGF.IGM.DebugInfo->emitTypeMetadata(IGF, data, typeParam->getDepth(),
                                      typeParam->getIndex(), AssocType);
}
开发者ID:phausler,项目名称:swift,代码行数:52,代码来源:LocalTypeData.cpp


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