本文整理汇总了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);
}