mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-03-03 02:53:13 +01:00
Fix a LLVM 3.3 problem with debug info generation.
In some cases an assertion is triggered because the debug context of a local variale is verified. It turns out that LLVM returns always false for DISubprogram.Verify() if the return type is not a composite type. Reading the Clang source it looks like the return type must be a subroutine type. This commit introduces a dummy subroutine type to define the return type.
This commit is contained in:
@@ -475,17 +475,26 @@ llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd)
|
||||
Logger::println("D to dwarf subprogram");
|
||||
LOG_SCOPE;
|
||||
|
||||
llvm::DICompileUnit CU(gIR->dibuilder.getCU());
|
||||
assert(CU && CU.Verify() && "Compilation unit missing or corrupted");
|
||||
|
||||
llvm::DIFile file = DtoDwarfFile(fd->loc);
|
||||
Type *retType = static_cast<TypeFunction*>(fd->type)->next;
|
||||
|
||||
// Create "dummy" subroutine type for the return type
|
||||
llvm::SmallVector<llvm::Value*, 16> Elts;
|
||||
Elts.push_back(dwarfTypeDescription(retType, NULL));
|
||||
llvm::DIArray EltTypeArray = gIR->dibuilder.getOrCreateArray(Elts);
|
||||
llvm::DIType DIFnType = gIR->dibuilder.createSubroutineType(file, EltTypeArray);
|
||||
|
||||
// FIXME: duplicates ?
|
||||
return gIR->dibuilder.createFunction(
|
||||
llvm::DICompileUnit(file), // context
|
||||
CU, // context
|
||||
fd->toPrettyChars(), // name
|
||||
fd->mangle(), // linkage name
|
||||
file, // file
|
||||
fd->loc.linnum, // line no
|
||||
dwarfTypeDescription(retType, NULL), // type
|
||||
DIFnType, // type
|
||||
fd->protection == PROTprivate, // is local to unit
|
||||
gIR->dmodule == getDefinedModule(fd), // isdefinition
|
||||
#if LDC_LLVM_VER >= 301
|
||||
|
||||
Reference in New Issue
Block a user