diff --git a/gen/dibuilder.cpp b/gen/dibuilder.cpp index dcc6642a3e..0559304478 100644 --- a/gen/dibuilder.cpp +++ b/gen/dibuilder.cpp @@ -73,7 +73,7 @@ ldc::DIScope ldc::DIBuilder::GetCurrentScope() return fn->diLexicalBlocks.top(); } -void ldc::DIBuilder::Declare(llvm::Value *var, ldc::DILocalVariable divar +void ldc::DIBuilder::Declare(const Loc &loc, llvm::Value *var, ldc::DILocalVariable divar #if LDC_LLVM_VER >= 306 , ldc::DIExpression diexpr #endif @@ -84,10 +84,12 @@ void ldc::DIBuilder::Declare(llvm::Value *var, ldc::DILocalVariable divar diexpr, #endif #if LDC_LLVM_VER >= 307 - IR->ir->getCurrentDebugLocation(), + llvm::DebugLoc::get(loc.linnum, loc.charnum, GetCurrentScope()), #endif IR->scopebb()); - instr->setDebugLoc(IR->ir->getCurrentDebugLocation()); +#if LDC_LLVM_VER < 307 + instr->setDebugLoc(llvm::DebugLoc::get(loc.linnum, loc.charnum, GetCurrentScope())); +#endif } ldc::DIFile ldc::DIBuilder::CreateFile(Loc& loc) @@ -932,9 +934,9 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd, // declare #if LDC_LLVM_VER >= 306 - Declare(ll, debugVariable, addr.empty() ? DBuilder.createExpression() : DBuilder.createExpression(addr)); + Declare(vd->loc, ll, debugVariable, addr.empty() ? DBuilder.createExpression() : DBuilder.createExpression(addr)); #else - Declare(ll, debugVariable); + Declare(vd->loc, ll, debugVariable); #endif } diff --git a/gen/dibuilder.h b/gen/dibuilder.h index 3d65fe8fc9..1b58ae3a45 100644 --- a/gen/dibuilder.h +++ b/gen/dibuilder.h @@ -189,7 +189,7 @@ private: llvm::LLVMContext &getContext(); Module *getDefinedModule(Dsymbol *s); DIScope GetCurrentScope(); - void Declare(llvm::Value *var, ldc::DILocalVariable divar + void Declare(const Loc &loc, llvm::Value *var, ldc::DILocalVariable divar #if LDC_LLVM_VER >= 306 , ldc::DIExpression diexpr #endif