[clang] 2e676fa - Revert "[clang][Interp] Optionally cast comparison result to non-bool"
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Wed May 31 04:08:01 PDT 2023
Author: Timm Bäder
Date: 2023-05-31T13:07:40+02:00
New Revision: 2e676fad2620a2ee41b7a00b27770fcfcb16f912
URL: https://github.com/llvm/llvm-project/commit/2e676fad2620a2ee41b7a00b27770fcfcb16f912
DIFF: https://github.com/llvm/llvm-project/commit/2e676fad2620a2ee41b7a00b27770fcfcb16f912.diff
LOG: Revert "[clang][Interp] Optionally cast comparison result to non-bool"
This reverts commit 81522a012accfcc6bbf4dfa21a793aea6e4e532a.
Looks like we're not ready for this yet:
https://lab.llvm.org/buildbot/#/builders/139/builds/41797
Added:
Modified:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
Removed:
clang/test/AST/Interp/c.c
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 24663a15bcd0..df7c4a72f21a 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -237,31 +237,19 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
if (!visit(LHS) || !visit(RHS))
return false;
- // For languages such as C, cast the result of one
- // of our comparision opcodes to T (which is usually int).
- auto MaybeCastToBool = [this, T, BO](bool Result) {
- if (!Result)
- return false;
- if (DiscardResult)
- return this->emitPop(*T, BO);
- if (T != PT_Bool)
- return this->emitCast(PT_Bool, *T, BO);
- return true;
- };
-
switch (BO->getOpcode()) {
case BO_EQ:
- return MaybeCastToBool(this->emitEQ(*LT, BO));
+ return Discard(this->emitEQ(*LT, BO));
case BO_NE:
- return MaybeCastToBool(this->emitNE(*LT, BO));
+ return Discard(this->emitNE(*LT, BO));
case BO_LT:
- return MaybeCastToBool(this->emitLT(*LT, BO));
+ return Discard(this->emitLT(*LT, BO));
case BO_LE:
- return MaybeCastToBool(this->emitLE(*LT, BO));
+ return Discard(this->emitLE(*LT, BO));
case BO_GT:
- return MaybeCastToBool(this->emitGT(*LT, BO));
+ return Discard(this->emitGT(*LT, BO));
case BO_GE:
- return MaybeCastToBool(this->emitGE(*LT, BO));
+ return Discard(this->emitGE(*LT, BO));
case BO_Sub:
if (BO->getType()->isFloatingType())
return Discard(this->emitSubf(getRoundingMode(BO), BO));
diff --git a/clang/test/AST/Interp/c.c b/clang/test/AST/Interp/c.c
deleted file mode 100644
index 248494c95f5e..000000000000
--- a/clang/test/AST/Interp/c.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
-// RUN: %clang_cc1 -verify=ref %s
-
-/// expected-no-diagnostics
-/// ref-no-diagnostics
-
-_Static_assert(1, "");
-_Static_assert(0 != 1, "");
-_Static_assert(1.0 == 1.0, "");
-_Static_assert( (5 > 4) + (3 > 2) == 2, "");
More information about the cfe-commits
mailing list