From c8d98ad31c2a97d3dced4e145a1bf29f5813b10a Mon Sep 17 00:00:00 2001 From: kai Date: Sat, 23 Mar 2013 15:40:29 +0100 Subject: [PATCH] More Dwarf debug code changes. Add a fix for LLVM 3.3 (`createTemporaryType()` was removed) and add linkage name to `createGlobalVariable()` (new in 3.3). --- gen/todebug.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gen/todebug.cpp b/gen/todebug.cpp index f0d6a33c..d5e5488d 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -254,8 +254,19 @@ static llvm::DIType dwarfCompositeType(Type* type) llvm::DIType derivedFrom; // set diCompositeType to handle recursive types properly - if (!ir->diCompositeType) + if (!ir->diCompositeType) { +#if LDC_LLVM_VER >= 301 + unsigned tag = (t->ty == Tstruct) ? llvm::dwarf::DW_TAG_structure_type + : llvm::dwarf::DW_TAG_class_type; + ir->diCompositeType = gIR->dibuilder.createForwardDecl(tag, name, +#if LDC_LLVM_VER >= 302 + llvm::DIDescriptor(file), +#endif + file, linnum); +#else ir->diCompositeType = gIR->dibuilder.createTemporaryType(); +#endif + } if (!ir->aggrdecl->isInterfaceDeclaration()) // plain interfaces don't have one { @@ -325,7 +336,10 @@ static llvm::DIGlobalVariable dwarfGlobalVariable(LLGlobalVariable* ll, VarDecla assert(vd->isDataseg() || (vd->storage_class & (STCconst | STCimmutable) && vd->init)); return gIR->dibuilder.createGlobalVariable( - vd->toChars(), // name TODO: mangle() or toPrettyChars() instead? + vd->toChars(), // name +#if LDC_LLVM_VER >= 303 + vd->mangle(), // linkage name +#endif DtoDwarfFile(vd->loc), // file vd->loc.linnum, // line num dwarfTypeDescription_impl(vd->type, NULL), // type