DebugInfo: Use location of variable declaration instead of current stop point.

There might be no valid stop point but the variable should always have a
location. This fixes an ICE compiling core.demangle.
This commit is contained in:
Kai Nacke 2015-06-05 13:04:30 +02:00
parent 227f16bcce
commit 95c897ab3e
2 changed files with 8 additions and 6 deletions

View file

@ -73,7 +73,7 @@ ldc::DIScope ldc::DIBuilder::GetCurrentScope()
return fn->diLexicalBlocks.top(); 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 #if LDC_LLVM_VER >= 306
, ldc::DIExpression diexpr , ldc::DIExpression diexpr
#endif #endif
@ -84,10 +84,12 @@ void ldc::DIBuilder::Declare(llvm::Value *var, ldc::DILocalVariable divar
diexpr, diexpr,
#endif #endif
#if LDC_LLVM_VER >= 307 #if LDC_LLVM_VER >= 307
IR->ir->getCurrentDebugLocation(), llvm::DebugLoc::get(loc.linnum, loc.charnum, GetCurrentScope()),
#endif #endif
IR->scopebb()); 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) ldc::DIFile ldc::DIBuilder::CreateFile(Loc& loc)
@ -932,9 +934,9 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
// declare // declare
#if LDC_LLVM_VER >= 306 #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 #else
Declare(ll, debugVariable); Declare(vd->loc, ll, debugVariable);
#endif #endif
} }

View file

@ -189,7 +189,7 @@ private:
llvm::LLVMContext &getContext(); llvm::LLVMContext &getContext();
Module *getDefinedModule(Dsymbol *s); Module *getDefinedModule(Dsymbol *s);
DIScope GetCurrentScope(); 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 #if LDC_LLVM_VER >= 306
, ldc::DIExpression diexpr , ldc::DIExpression diexpr
#endif #endif