[clang] 21aa8a2 - [clang][Interp] Fix ignoring Integral- and IntegralToBoolean casts
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 1 06:21:43 PDT 2023
Author: Timm Bäder
Date: 2023-08-01T15:21:20+02:00
New Revision: 21aa8a220c017e35338b3be44a011c6450786f54
URL: https://github.com/llvm/llvm-project/commit/21aa8a220c017e35338b3be44a011c6450786f54
DIFF: https://github.com/llvm/llvm-project/commit/21aa8a220c017e35338b3be44a011c6450786f54.diff
LOG: [clang][Interp] Fix ignoring Integral- and IntegralToBoolean casts
Differential Revision: https://reviews.llvm.org/D154474
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 82f1e7a74b22e6..b727865427054b 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -150,6 +150,8 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
case CK_IntegralToBoolean:
case CK_IntegralCast: {
+ if (DiscardResult)
+ return this->discard(SubExpr);
std::optional<PrimType> FromT = classify(SubExpr->getType());
std::optional<PrimType> ToT = classify(CE->getType());
if (!FromT || !ToT)
diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp
index d514ba9b654bef..2a31d11e72cce2 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -921,6 +921,9 @@ namespace DiscardExprs {
sizeof(int);
alignof(int);
+ (short)5;
+ (bool)1;
+
return 0;
}
static_assert(ignoredExprs() == 0, "");
More information about the cfe-commits
mailing list