Emit debug declaration of variables before the instructions for their initializers.

This commit is contained in:
Matt Pharr
2011-07-28 11:05:02 +01:00
parent 80ca02af58
commit 7f662de6e3

View File

@@ -306,17 +306,19 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const {
llvm::Twine("static.") + llvm::Twine("static.") +
llvm::Twine(sym->pos.first_line) + llvm::Twine(sym->pos.first_line) +
llvm::Twine(".") + sym->name.c_str()); llvm::Twine(".") + sym->name.c_str());
// Tell the FunctionEmitContext about the variable
ctx->EmitVariableDebugInfo(sym);
} }
else { else {
// For non-static variables, allocate storage on the stack // For non-static variables, allocate storage on the stack
sym->storagePtr = ctx->AllocaInst(llvmType, sym->name.c_str()); 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... // And then get it initialized...
lInitSymbol(sym->storagePtr, sym->name.c_str(), type, decl->initExpr, lInitSymbol(sym->storagePtr, sym->name.c_str(), type, decl->initExpr,
ctx, sym->pos); ctx, sym->pos);
} }
// Finally, tell the FunctionEmitContext about the variable
ctx->EmitVariableDebugInfo(sym);
} }
} }