[clang] d61ba03 - [clang][Interp][NFC] Call delegate() for the RHS of a comma op
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 14 04:37:03 PDT 2023
Author: Timm Bäder
Date: 2023-09-14T13:36:51+02:00
New Revision: d61ba038a9d49761ae86cce662f48bce1e47cbe9
URL: https://github.com/llvm/llvm-project/commit/d61ba038a9d49761ae86cce662f48bce1e47cbe9
DIFF: https://github.com/llvm/llvm-project/commit/d61ba038a9d49761ae86cce662f48bce1e47cbe9.diff
LOG: [clang][Interp][NFC] Call delegate() for the RHS of a comma op
Added:
Modified:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/literals.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 0ce55f115a1a066..4fa12a66bbf767f 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -243,12 +243,6 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
std::optional<PrimType> RT = classify(RHS->getType());
std::optional<PrimType> T = classify(BO->getType());
- auto Discard = [this, T, BO](bool Result) {
- if (!Result)
- return false;
- return DiscardResult ? this->emitPop(*T, BO) : true;
- };
-
// Deal with operations which have composite or void types.
if (BO->isCommaOp()) {
if (!this->discard(LHS))
@@ -256,9 +250,7 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
if (RHS->getType()->isVoidType())
return this->discard(RHS);
- // Otherwise, visit RHS and optionally discard its value.
- return Discard(Initializing ? this->visitInitializer(RHS)
- : this->visit(RHS));
+ return this->delegate(RHS);
}
if (!LT || !RT || !T)
@@ -285,6 +277,12 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
return true;
};
+ auto Discard = [this, T, BO](bool Result) {
+ if (!Result)
+ return false;
+ return DiscardResult ? this->emitPop(*T, BO) : true;
+ };
+
switch (BO->getOpcode()) {
case BO_EQ:
return MaybeCastToBool(this->emitEQ(*LT, BO));
diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp
index 69a3edc87b6ec65..dae1d5af6f7ae38 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -929,6 +929,7 @@ namespace DiscardExprs {
(bool)1;
__null;
__builtin_offsetof(A, a);
+ 1,2;
return 0;
}
More information about the cfe-commits
mailing list