mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Debug info] Map the thrown error type into context when generating debug info
This commit is contained in:
@@ -2570,11 +2570,18 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
|
||||
if (FnTy && (Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables))
|
||||
if (auto ErrorInfo = FnTy->getOptionalErrorResult()) {
|
||||
GenericContextScope scope(IGM, FnTy->getInvocationGenericSignature());
|
||||
CanType errorResultTy = ErrorInfo->getReturnValueType(
|
||||
IGM.getSILModule(), FnTy,
|
||||
IGM.getMaximalTypeExpansionContext());
|
||||
SILType SILTy = IGM.silConv.getSILType(
|
||||
*ErrorInfo, FnTy, IGM.getMaximalTypeExpansionContext());
|
||||
|
||||
errorResultTy = SILFn->mapTypeIntoContext(errorResultTy)
|
||||
->getCanonicalType();
|
||||
SILTy = SILFn->mapTypeIntoContext(SILTy);
|
||||
|
||||
auto DTI = DebugTypeInfo::getFromTypeInfo(
|
||||
ErrorInfo->getReturnValueType(IGM.getSILModule(), FnTy,
|
||||
IGM.getMaximalTypeExpansionContext()),
|
||||
errorResultTy,
|
||||
IGM.getTypeInfo(SILTy), IGM, false);
|
||||
Error = DBuilder.getOrCreateArray({getOrCreateType(DTI)}).get();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,17 @@ public class C {
|
||||
}
|
||||
}
|
||||
|
||||
// Function with typed throws.
|
||||
// CHECK: !DISubprogram(name: "genericRethrow", {{.*}}thrownTypes: ![[GENERIC_THROWN:.*]])
|
||||
// CHECK: ![[GENERIC_THROWN]] = !{![[GENERIC_THROWN_INNER:.*]]}
|
||||
// CHECK: ![[GENERIC_THROWN_INNER]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$sxD", {{.*}}, elements: ![[GENERIC_THROWN_ELEMENTS:.*]], runtimeLang: DW_LANG_Swift)
|
||||
// CHECK: ![[GENERIC_THROWN_ELEMENTS]] = !{![[GENERIC_THROWN_ELEMENTS_INNER:.*]]}
|
||||
// CHECK: ![[GENERIC_THROWN_ELEMENTS_INNER]] = !DIDerivedType(tag: DW_TAG_inheritance, {{.*}}baseType: ![[GENERIC_THROWN_BASE:.*]], extraData: {{.*}})
|
||||
// CHECK: ![[GENERIC_THROWN_BASE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$ss5Error_pmD", size: {{.*}}, flags: DIFlagArtificial, runtimeLang: DW_LANG_Swift, identifier: "$ss5Error_pmD")
|
||||
public func genericRethrow<E: Error>(fn: () throws(E) -> Void) throws(E) {
|
||||
try fn()
|
||||
}
|
||||
|
||||
// Negative tests.
|
||||
// CHECK: !DISubprogram(name: "returnThrowing",
|
||||
// CHECK-NOT: thrownTypes:
|
||||
|
||||
Reference in New Issue
Block a user