Skip to content

Commit d61ba03

Browse files
committed
[clang][Interp][NFC] Call delegate() for the RHS of a comma op
1 parent bf8fd08 commit d61ba03

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,22 +243,14 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
243243
std::optional<PrimType> RT = classify(RHS->getType());
244244
std::optional<PrimType> T = classify(BO->getType());
245245

246-
auto Discard = [this, T, BO](bool Result) {
247-
if (!Result)
248-
return false;
249-
return DiscardResult ? this->emitPop(*T, BO) : true;
250-
};
251-
252246
// Deal with operations which have composite or void types.
253247
if (BO->isCommaOp()) {
254248
if (!this->discard(LHS))
255249
return false;
256250
if (RHS->getType()->isVoidType())
257251
return this->discard(RHS);
258252

259-
// Otherwise, visit RHS and optionally discard its value.
260-
return Discard(Initializing ? this->visitInitializer(RHS)
261-
: this->visit(RHS));
253+
return this->delegate(RHS);
262254
}
263255

264256
if (!LT || !RT || !T)
@@ -285,6 +277,12 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
285277
return true;
286278
};
287279

280+
auto Discard = [this, T, BO](bool Result) {
281+
if (!Result)
282+
return false;
283+
return DiscardResult ? this->emitPop(*T, BO) : true;
284+
};
285+
288286
switch (BO->getOpcode()) {
289287
case BO_EQ:
290288
return MaybeCastToBool(this->emitEQ(*LT, BO));

clang/test/AST/Interp/literals.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ namespace DiscardExprs {
929929
(bool)1;
930930
__null;
931931
__builtin_offsetof(A, a);
932+
1,2;
932933

933934
return 0;
934935
}

0 commit comments

Comments
 (0)