mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 17:43:35 +03:00
Slightly refactor DIBuilder::EmitSubProgram()
This commit is contained in:
parent
1a08d89445
commit
070d6dab0f
1 changed files with 30 additions and 36 deletions
|
@ -907,47 +907,41 @@ ldc::DISubprogram ldc::DIBuilder::EmitSubProgram(FuncDeclaration *fd) {
|
||||||
assert(GetCU() &&
|
assert(GetCU() &&
|
||||||
"Compilation unit missing or corrupted in DIBuilder::EmitSubProgram");
|
"Compilation unit missing or corrupted in DIBuilder::EmitSubProgram");
|
||||||
|
|
||||||
ldc::DIFile file = CreateFile(fd);
|
const auto scope = GetSymbolScope(fd);
|
||||||
|
const auto name = fd->toChars();
|
||||||
|
const auto linkageName = irFunc->getLLVMFuncName();
|
||||||
|
const auto file = CreateFile(fd);
|
||||||
|
const auto lineNo = fd->loc.linnum;
|
||||||
|
const auto isLocalToUnit = fd->protection.kind == Prot::private_;
|
||||||
|
const auto isDefinition = true;
|
||||||
|
const auto scopeLine = lineNo; // FIXME
|
||||||
|
const auto flags = DIFlags::FlagPrototyped;
|
||||||
|
const auto isOptimized = isOptimizationEnabled();
|
||||||
|
|
||||||
|
ldc::DISubroutineType diFnType = nullptr;
|
||||||
|
if (!mustEmitFullDebugInfo()) {
|
||||||
|
diFnType = CreateEmptyFunctionType();
|
||||||
|
} else {
|
||||||
// A special case is `auto foo() { struct S{}; S s; return s; }`
|
// 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
|
// The return type is a nested struct, so for this particular
|
||||||
// we need to create a temporary subprogram.
|
// chicken-and-egg case we need to create a temporary subprogram.
|
||||||
irFunc->diSubprogram = DBuilder.createTempFunctionFwdDecl(
|
irFunc->diSubprogram = DBuilder.createTempFunctionFwdDecl(
|
||||||
GetSymbolScope(fd), // context
|
scope, name, linkageName, file, lineNo, /*ty=*/nullptr, isLocalToUnit,
|
||||||
fd->toChars(), // name
|
isDefinition, scopeLine, flags, isOptimized);
|
||||||
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
|
// Now create subroutine type.
|
||||||
ldc::DISubroutineType DIFnType = mustEmitFullDebugInfo() ?
|
diFnType = CreateFunctionType(static_cast<TypeFunction *>(fd->type));
|
||||||
CreateFunctionType(static_cast<TypeFunction *>(fd->type)) :
|
}
|
||||||
CreateEmptyFunctionType();
|
|
||||||
|
|
||||||
// FIXME: duplicates?
|
// FIXME: duplicates?
|
||||||
auto SP = DBuilder.createFunction(
|
auto SP = DBuilder.createFunction(scope, name, linkageName, file, lineNo,
|
||||||
GetSymbolScope(fd), // context
|
diFnType, isLocalToUnit, isDefinition,
|
||||||
fd->toChars(), // name
|
scopeLine, flags, isOptimized);
|
||||||
irFunc->getLLVMFuncName(), // linkage name
|
|
||||||
file, // file
|
|
||||||
fd->loc.linnum, // line no
|
|
||||||
DIFnType, // type
|
|
||||||
fd->protection.kind == Prot::private_, // is local to unit
|
|
||||||
true, // isdefinition
|
|
||||||
fd->loc.linnum, // FIXME: scope line
|
|
||||||
DIFlags::FlagPrototyped, // Flags
|
|
||||||
isOptimizationEnabled() // isOptimized
|
|
||||||
);
|
|
||||||
|
|
||||||
irFunc->diSubprogram = DBuilder.replaceTemporary(
|
if (mustEmitFullDebugInfo())
|
||||||
llvm::TempDINode(irFunc->diSubprogram), SP);
|
DBuilder.replaceTemporary(llvm::TempDINode(irFunc->diSubprogram), SP);
|
||||||
|
|
||||||
|
irFunc->diSubprogram = SP;
|
||||||
return SP;
|
return SP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue