mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +03:00
Debug info: create temporary forward subprograms before creating the subprogram type
This is for the special case of auto functions returning a nested type, e.g: auto foo() { struct S {}; S s; return s; }
This commit is contained in:
parent
8d26d5f452
commit
02eb4058fa
2 changed files with 18 additions and 1 deletions
|
@ -914,6 +914,23 @@ ldc::DISubprogram ldc::DIBuilder::EmitSubProgram(FuncDeclaration *fd) {
|
|||
|
||||
ldc::DIFile file = CreateFile(fd);
|
||||
|
||||
// A special case is `auto foo() { struct S{}; S s; return s; }`
|
||||
// The return type is a nested struct, so for this particular chicken-and-egg case
|
||||
// we need to create a temporary subprogram.
|
||||
irFunc->diSubprogram = DBuilder.createTempFunctionFwdDecl(
|
||||
GetSymbolScope(fd), // context
|
||||
fd->toChars(), // name
|
||||
irFunc->getLLVMFuncName(), // linkage name
|
||||
file, // file
|
||||
fd->loc.linnum, // line no
|
||||
nullptr, // type
|
||||
fd->protection.kind == Prot::private_, // is local to unit
|
||||
true, // isdefinition
|
||||
fd->loc.linnum, // FIXME: scope line
|
||||
DIFlags::FlagPrototyped, // Flags
|
||||
isOptimizationEnabled() // isOptimized
|
||||
);
|
||||
|
||||
// Create subroutine type
|
||||
ldc::DISubroutineType DIFnType = mustEmitFullDebugInfo() ?
|
||||
CreateFunctionType(static_cast<TypeFunction *>(fd->type)) :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue