mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 09:00:33 +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);
|
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
|
// Create subroutine type
|
||||||
ldc::DISubroutineType DIFnType = mustEmitFullDebugInfo() ?
|
ldc::DISubroutineType DIFnType = mustEmitFullDebugInfo() ?
|
||||||
CreateFunctionType(static_cast<TypeFunction *>(fd->type)) :
|
CreateFunctionType(static_cast<TypeFunction *>(fd->type)) :
|
||||||
|
|
|
@ -1000,7 +1000,7 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// debug info
|
// debug info
|
||||||
irFunc->diSubprogram = gIR->DBuilder.EmitSubProgram(fd);
|
gIR->DBuilder.EmitSubProgram(fd);
|
||||||
|
|
||||||
IF_LOG Logger::println("Doing function body for: %s", fd->toChars());
|
IF_LOG Logger::println("Doing function body for: %s", fd->toChars());
|
||||||
gIR->funcGenStates.emplace_back(new FuncGenState(*irFunc, *gIR));
|
gIR->funcGenStates.emplace_back(new FuncGenState(*irFunc, *gIR));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue