From: David Blaikie Date: Mon, 9 Feb 2015 19:13:51 +0000 (+0000) Subject: DebugInfo: Refactor default arg handling into a common place (instead of handling... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6666e621f3588f0494b11a7d11c67ba682fd6204;p=clang DebugInfo: Refactor default arg handling into a common place (instead of handling in repeatedly for aggregate, complex, and scalar types) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228591 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 3c296ae468..95fad1a114 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -2734,8 +2734,22 @@ struct DestroyUnpassedArg : EHScopeStack::Cleanup { } +struct DisableDebugLocationUpdates { + CodeGenFunction &CGF; + bool disabledDebugInfo; + DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) { + if ((disabledDebugInfo = isa(E) && CGF.getDebugInfo())) + CGF.disableDebugInfo(); + } + ~DisableDebugLocationUpdates() { + if (disabledDebugInfo) + CGF.enableDebugInfo(); + } +}; + void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, QualType type) { + DisableDebugLocationUpdates Dis(*this, E); if (const ObjCIndirectCopyRestoreExpr *CRE = dyn_cast(E)) { assert(getLangOpts().ObjCAutoRefCount); diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 7d05d48e85..80b16dd5ba 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -1387,12 +1387,7 @@ void CodeGenFunction::EmitAggExpr(const Expr *E, AggValueSlot Slot) { // Optimize the slot if possible. CheckAggExprForMemSetUse(Slot, E, *this); - bool hasDebugInfo = getDebugInfo(); - if (isa(E)) - disableDebugInfo(); AggExprEmitter(*this, Slot).Visit(const_cast(E)); - if (isa(E) && hasDebugInfo) - enableDebugInfo(); } LValue CodeGenFunction::EmitAggExprToLValue(const Expr *E) { diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index b4c652c3d8..3a39b337b3 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -1033,14 +1033,8 @@ ComplexPairTy CodeGenFunction::EmitComplexExpr(const Expr *E, bool IgnoreReal, assert(E && getComplexType(E->getType()) && "Invalid complex expression to emit"); - bool hasDebugInfo = getDebugInfo(); - if (isa(E)) - disableDebugInfo(); - auto R = ComplexExprEmitter(*this, IgnoreReal, IgnoreImag) - .Visit(const_cast(E)); - if (isa(E) && hasDebugInfo) - enableDebugInfo(); - return R; + return ComplexExprEmitter(*this, IgnoreReal, IgnoreImag) + .Visit(const_cast(E)); } void CodeGenFunction::EmitComplexExprIntoLValue(const Expr *E, LValue dest, diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 951895f5f0..3e7cd4011d 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -3393,14 +3393,8 @@ Value *CodeGenFunction::EmitScalarExpr(const Expr *E, bool IgnoreResultAssign) { assert(E && hasScalarEvaluationKind(E->getType()) && "Invalid scalar expression to emit"); - bool hasDebugInfo = getDebugInfo(); - if (isa(E)) - disableDebugInfo(); - Value *V = ScalarExprEmitter(*this, IgnoreResultAssign) - .Visit(const_cast(E)); - if (isa(E) && hasDebugInfo) - enableDebugInfo(); - return V; + return ScalarExprEmitter(*this, IgnoreResultAssign) + .Visit(const_cast(E)); } /// EmitScalarConversion - Emit a conversion from the specified type to the