diff options
| author | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2013-08-30 05:37:02 +0000 |
|---|---|---|
| committer | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2013-08-30 05:37:02 +0000 |
| commit | 51a31e1da76cc0906e4708ae15e2f7ecf1ba5f13 (patch) | |
| tree | 4c8cecbf1de67e4f1418a193759c209b8ae5293a /lib/CodeGen/CodeGenFunction.cpp | |
| parent | bb6b5e40b6ea0e512eebd4bdc9d635076ed279f7 (diff) | |
| download | clang-51a31e1da76cc0906e4708ae15e2f7ecf1ba5f13.tar.gz clang-51a31e1da76cc0906e4708ae15e2f7ecf1ba5f13.tar.bz2 clang-51a31e1da76cc0906e4708ae15e2f7ecf1ba5f13.tar.xz | |
Fixing a bug where debug info for a local variable gets emitted at file scope.
The patch was discussed in Phabricator. See:
http://llvm-reviews.chandlerc.com/D1281
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189649 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 20352f9f68..c0357238d2 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -1376,12 +1376,27 @@ llvm::Value* CodeGenFunction::EmitVAListRef(const Expr* E) { return EmitLValue(E).getAddress(); } -void CodeGenFunction::EmitDeclRefExprDbgValue(const DeclRefExpr *E, - llvm::Constant *Init) { +void CodeGenFunction::EmitValueDeclDbgValue(const ValueDecl *Val, + llvm::Constant *Init) { assert (Init && "Invalid DeclRefExpr initializer!"); - if (CGDebugInfo *Dbg = getDebugInfo()) - if (CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo) - Dbg->EmitGlobalVariable(E->getDecl(), Init); + CGDebugInfo *Dbg = getDebugInfo(); + if (!Dbg || + CGM.getCodeGenOpts().getDebugInfo() < CodeGenOptions::LimitedDebugInfo) + return; + + // Make sure we emit a debug reference to the global variable. + if (const VarDecl *VD = dyn_cast<VarDecl>(Val)) { + // Do not duplicate DIE entry for local variables; they are not deferred + // like global variables are. + if (VD->isFileVarDecl() && !getLangOpts().EmitAllDecls && + !getContext().DeclMustBeEmitted(Val)) + Dbg->EmitGlobalVariable(Init, VD); + + // Make sure we emit a debug reference to an enumerator constant. + } else { + assert(isa<EnumConstantDecl>(Val)); + Dbg->EmitEnumConstant(dyn_cast<EnumConstantDecl>(Val)); + } } CodeGenFunction::PeepholeProtection |
