Skip to content

Commit 4a1d1bb

Browse files
committed
Generalize/reuse DisableDebugLocationUpdates
1 parent 0267bcc commit 4a1d1bb

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4818,19 +4818,6 @@ struct DestroyUnpassedArg final : EHScopeStack::Cleanup {
48184818
}
48194819
};
48204820

4821-
struct DisableDebugLocationUpdates {
4822-
CodeGenFunction &CGF;
4823-
bool disabledDebugInfo;
4824-
DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) {
4825-
if ((disabledDebugInfo = isa<CXXDefaultArgExpr>(E) && CGF.getDebugInfo()))
4826-
CGF.disableDebugInfo();
4827-
}
4828-
~DisableDebugLocationUpdates() {
4829-
if (disabledDebugInfo)
4830-
CGF.enableDebugInfo();
4831-
}
4832-
};
4833-
48344821
} // end anonymous namespace
48354822

48364823
RValue CallArg::getRValue(CodeGenFunction &CGF) const {
@@ -4867,7 +4854,9 @@ void CodeGenFunction::EmitWritebacks(const CallArgList &args) {
48674854

48684855
void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
48694856
QualType type) {
4870-
DisableDebugLocationUpdates Dis(*this, E);
4857+
std::optional<DisableDebugLocationUpdates> Dis;
4858+
if (isa<CXXDefaultArgExpr>(E))
4859+
Dis.emplace(*this);
48714860
if (const ObjCIndirectCopyRestoreExpr *CRE =
48724861
dyn_cast<ObjCIndirectCopyRestoreExpr>(E)) {
48734862
assert(getLangOpts().ObjCAutoRefCount);
@@ -6282,3 +6271,12 @@ RValue CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr,
62826271
return CGM.getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty, Slot);
62836272
return CGM.getABIInfo().EmitVAArg(*this, VAListAddr, Ty, Slot);
62846273
}
6274+
6275+
DisableDebugLocationUpdates::DisableDebugLocationUpdates(CodeGenFunction &CGF)
6276+
: CGF(CGF) {
6277+
CGF.disableDebugInfo();
6278+
}
6279+
6280+
DisableDebugLocationUpdates::~DisableDebugLocationUpdates() {
6281+
CGF.enableDebugInfo();
6282+
}

clang/lib/CodeGen/CGCall.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,12 @@ inline FnInfoOpts &operator&=(FnInfoOpts &A, FnInfoOpts B) {
453453
return A;
454454
}
455455

456+
struct DisableDebugLocationUpdates {
457+
CodeGenFunction &CGF;
458+
DisableDebugLocationUpdates(CodeGenFunction &CGF);
459+
~DisableDebugLocationUpdates();
460+
};
461+
456462
} // end namespace CodeGen
457463
} // end namespace clang
458464

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,13 +1629,12 @@ LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
16291629
/// length type, this is not possible.
16301630
///
16311631
LValue CodeGenFunction::EmitLValue(const Expr *E,
1632-
KnownNonNull_t IsKnownNonNull, bool SuppressLocation) {
1632+
KnownNonNull_t IsKnownNonNull) {
16331633
// Running with sufficient stack space to avoid deeply nested expressions
16341634
// cause a stack overflow.
16351635
LValue LV;
1636-
CGM.runWithSufficientStackSpace(E->getExprLoc(), [&] {
1637-
LV = EmitLValueHelper(E, IsKnownNonNull, SuppressLocation);
1638-
});
1636+
CGM.runWithSufficientStackSpace(
1637+
E->getExprLoc(), [&] { LV = EmitLValueHelper(E, IsKnownNonNull); });
16391638

16401639
if (IsKnownNonNull && !LV.isKnownNonNull())
16411640
LV.setKnownNonNull();
@@ -1651,11 +1650,8 @@ static QualType getConstantExprReferredType(const FullExpr *E,
16511650
}
16521651

16531652
LValue CodeGenFunction::EmitLValueHelper(const Expr *E,
1654-
KnownNonNull_t IsKnownNonNull,
1655-
bool SuppressLocation) {
1656-
std::optional<ApplyDebugLocation> DL;
1657-
if (!SuppressLocation)
1658-
DL.emplace(*this, E);
1653+
KnownNonNull_t IsKnownNonNull) {
1654+
ApplyDebugLocation DL(*this, E);
16591655
switch (E->getStmtClass()) {
16601656
default: return EmitUnsupportedLValue(E, "l-value expression");
16611657

@@ -3391,7 +3387,8 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
33913387
auto *FD = LambdaCaptureFields.lookup(BD);
33923388
return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
33933389
}
3394-
return EmitLValue(BD->getBinding(), NotKnownNonNull, true);
3390+
DisableDebugLocationUpdates D(*this);
3391+
return EmitLValue(BD->getBinding(), NotKnownNonNull);
33953392
}
33963393

33973394
// We can form DeclRefExprs naming GUID declarations when reconstituting

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4230,12 +4230,10 @@ class CodeGenFunction : public CodeGenTypeCache {
42304230
/// variable length type, this is not possible.
42314231
///
42324232
LValue EmitLValue(const Expr *E,
4233-
KnownNonNull_t IsKnownNonNull = NotKnownNonNull,
4234-
bool SuppressLocation = false);
4233+
KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
42354234

42364235
private:
4237-
LValue EmitLValueHelper(const Expr *E, KnownNonNull_t IsKnownNonNull,
4238-
bool SuppressLocation);
4236+
LValue EmitLValueHelper(const Expr *E, KnownNonNull_t IsKnownNonNull);
42394237

42404238
public:
42414239
/// Same as EmitLValue but additionally we generate checking code to

0 commit comments

Comments
 (0)