From 7f662de6e357d998ec0cff8778bff23ef9baf330 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 28 Jul 2011 11:05:02 +0100 Subject: [PATCH] Emit debug declaration of variables before the instructions for their initializers. --- stmt.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stmt.cpp b/stmt.cpp index 815d0061..d83a056e 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -306,17 +306,19 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const { llvm::Twine("static.") + llvm::Twine(sym->pos.first_line) + llvm::Twine(".") + sym->name.c_str()); + // Tell the FunctionEmitContext about the variable + ctx->EmitVariableDebugInfo(sym); } else { // For non-static variables, allocate storage on the stack sym->storagePtr = ctx->AllocaInst(llvmType, sym->name.c_str()); + // Tell the FunctionEmitContext about the variable; must do + // this before the initializer stuff. + ctx->EmitVariableDebugInfo(sym); // And then get it initialized... lInitSymbol(sym->storagePtr, sym->name.c_str(), type, decl->initExpr, ctx, sym->pos); } - - // Finally, tell the FunctionEmitContext about the variable - ctx->EmitVariableDebugInfo(sym); } }