Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 6666e62

Browse files
committed
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
1 parent 74bfe10 commit 6666e62

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

Diff for: lib/CodeGen/CGCall.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -2734,8 +2734,22 @@ struct DestroyUnpassedArg : EHScopeStack::Cleanup {
27342734

27352735
}
27362736

2737+
struct DisableDebugLocationUpdates {
2738+
CodeGenFunction &CGF;
2739+
bool disabledDebugInfo;
2740+
DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) {
2741+
if ((disabledDebugInfo = isa<CXXDefaultArgExpr>(E) && CGF.getDebugInfo()))
2742+
CGF.disableDebugInfo();
2743+
}
2744+
~DisableDebugLocationUpdates() {
2745+
if (disabledDebugInfo)
2746+
CGF.enableDebugInfo();
2747+
}
2748+
};
2749+
27372750
void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
27382751
QualType type) {
2752+
DisableDebugLocationUpdates Dis(*this, E);
27392753
if (const ObjCIndirectCopyRestoreExpr *CRE
27402754
= dyn_cast<ObjCIndirectCopyRestoreExpr>(E)) {
27412755
assert(getLangOpts().ObjCAutoRefCount);

Diff for: lib/CodeGen/CGExprAgg.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -1387,12 +1387,7 @@ void CodeGenFunction::EmitAggExpr(const Expr *E, AggValueSlot Slot) {
13871387
// Optimize the slot if possible.
13881388
CheckAggExprForMemSetUse(Slot, E, *this);
13891389

1390-
bool hasDebugInfo = getDebugInfo();
1391-
if (isa<CXXDefaultArgExpr>(E))
1392-
disableDebugInfo();
13931390
AggExprEmitter(*this, Slot).Visit(const_cast<Expr*>(E));
1394-
if (isa<CXXDefaultArgExpr>(E) && hasDebugInfo)
1395-
enableDebugInfo();
13961391
}
13971392

13981393
LValue CodeGenFunction::EmitAggExprToLValue(const Expr *E) {

Diff for: lib/CodeGen/CGExprComplex.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -1033,14 +1033,8 @@ ComplexPairTy CodeGenFunction::EmitComplexExpr(const Expr *E, bool IgnoreReal,
10331033
assert(E && getComplexType(E->getType()) &&
10341034
"Invalid complex expression to emit");
10351035

1036-
bool hasDebugInfo = getDebugInfo();
1037-
if (isa<CXXDefaultArgExpr>(E))
1038-
disableDebugInfo();
1039-
auto R = ComplexExprEmitter(*this, IgnoreReal, IgnoreImag)
1040-
.Visit(const_cast<Expr *>(E));
1041-
if (isa<CXXDefaultArgExpr>(E) && hasDebugInfo)
1042-
enableDebugInfo();
1043-
return R;
1036+
return ComplexExprEmitter(*this, IgnoreReal, IgnoreImag)
1037+
.Visit(const_cast<Expr *>(E));
10441038
}
10451039

10461040
void CodeGenFunction::EmitComplexExprIntoLValue(const Expr *E, LValue dest,

Diff for: lib/CodeGen/CGExprScalar.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -3393,14 +3393,8 @@ Value *CodeGenFunction::EmitScalarExpr(const Expr *E, bool IgnoreResultAssign) {
33933393
assert(E && hasScalarEvaluationKind(E->getType()) &&
33943394
"Invalid scalar expression to emit");
33953395

3396-
bool hasDebugInfo = getDebugInfo();
3397-
if (isa<CXXDefaultArgExpr>(E))
3398-
disableDebugInfo();
3399-
Value *V = ScalarExprEmitter(*this, IgnoreResultAssign)
3400-
.Visit(const_cast<Expr*>(E));
3401-
if (isa<CXXDefaultArgExpr>(E) && hasDebugInfo)
3402-
enableDebugInfo();
3403-
return V;
3396+
return ScalarExprEmitter(*this, IgnoreResultAssign)
3397+
.Visit(const_cast<Expr *>(E));
34043398
}
34053399

34063400
/// EmitScalarConversion - Emit a conversion from the specified type to the

0 commit comments

Comments
 (0)