mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #83557 from augusto2112/6.2-fix-opaque-infinite-rec
[DebugInfo] Fix infinite recursion when opaque return type is defined inside function returning it
This commit is contained in:
@@ -979,7 +979,10 @@ private:
|
||||
if (Scope)
|
||||
return MainFile;
|
||||
}
|
||||
return cast<llvm::DIFile>(Scope);
|
||||
if (Scope)
|
||||
return cast<llvm::DIFile>(Scope);
|
||||
|
||||
return MainFile;
|
||||
}
|
||||
|
||||
static unsigned getStorageSizeInBits(const llvm::DataLayout &DL,
|
||||
@@ -3222,6 +3225,11 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
|
||||
Name = LinkageName;
|
||||
}
|
||||
|
||||
llvm::DISubprogram *ReplaceableType = DBuilder.createTempFunctionFwdDecl(
|
||||
Scope, Name, LinkageName, File, Line, /*Type=*/nullptr, ScopeLine);
|
||||
auto FwdDecl = llvm::TempDISubprogram(ReplaceableType);
|
||||
ScopeCache[DS] = llvm::TrackingMDNodeRef(FwdDecl.get());
|
||||
|
||||
CanSILFunctionType FnTy = getFunctionType(SILTy);
|
||||
auto Params = Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables
|
||||
? createParameterTypes(SILTy)
|
||||
@@ -3321,6 +3329,7 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
|
||||
if (!DS)
|
||||
return nullptr;
|
||||
|
||||
DBuilder.replaceTemporary(std::move(FwdDecl), SP);
|
||||
ScopeCache[DS] = llvm::TrackingMDNodeRef(SP);
|
||||
return SP;
|
||||
}
|
||||
|
||||
14
test/DebugInfo/nested_opaque.swift
Normal file
14
test/DebugInfo/nested_opaque.swift
Normal file
@@ -0,0 +1,14 @@
|
||||
// RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | %FileCheck %s
|
||||
|
||||
protocol TheProtocol {
|
||||
}
|
||||
|
||||
// CHECK: ![[FUNC_ID:[0-9]+]] = distinct !DISubprogram(name: "theFunction",
|
||||
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "TheType", scope: ![[FUNC_ID]]
|
||||
func theFunction() -> some TheProtocol {
|
||||
struct TheType: TheProtocol {
|
||||
}
|
||||
return TheType()
|
||||
}
|
||||
|
||||
theFunction()
|
||||
Reference in New Issue
Block a user