aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2008-05-30 10:30:31 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2008-05-30 10:30:31 +0000
commitcc9b16394fe6c9245dc4f8661a63d0c3937b62f0 (patch)
tree14ffd780b29f8e2ed574e0684642b2f6d8e90f50 /lib/CodeGen/CGDecl.cpp
parente36a3c8b5c7db4916342e4381caa2fdc93eb5745 (diff)
Emit parameter and local variable debug information with -g.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51765 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 6e40ea0582..4541fc4caa 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "CGDebugInfo.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
@@ -18,6 +19,7 @@
#include "clang/Basic/TargetInfo.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Type.h"
+#include "llvm/Support/Dwarf.h"
using namespace clang;
using namespace CodeGen;
@@ -143,7 +145,16 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
llvm::Value *&DMEntry = LocalDeclMap[&D];
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");
DMEntry = DeclPtr;
-
+
+ // Emit debug info for local var declaration.
+ CGDebugInfo *DI = CGM.getDebugInfo();
+ if(DI) {
+ if(D.getLocation().isValid())
+ DI->setLocation(D.getLocation());
+ DI->EmitDeclare(&D, llvm::dwarf::DW_TAG_auto_variable,
+ DeclPtr, Builder);
+ }
+
// If this local has an initializer, emit it now.
if (const Expr *Init = D.getInit()) {
if (!hasAggregateLLVMType(Init->getType())) {
@@ -188,5 +199,15 @@ void CodeGenFunction::EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg) {
llvm::Value *&DMEntry = LocalDeclMap[&D];
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");
DMEntry = DeclPtr;
+
+ // Emit debug info for param declaration.
+ CGDebugInfo *DI = CGM.getDebugInfo();
+ if(DI) {
+ if(D.getLocation().isValid())
+ DI->setLocation(D.getLocation());
+ DI->EmitDeclare(&D, llvm::dwarf::DW_TAG_arg_variable,
+ DeclPtr, Builder);
+ }
+
}