[clang] 301e2ff - [clang][bytecode] Disable DiscardResult in visitBool() (#188916)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 27 01:35:52 PDT 2026


Author: Timm Baeder
Date: 2026-03-27T09:35:48+01:00
New Revision: 301e2ffa5cd87e6c293a85fef0e3597809b3d803

URL: https://github.com/llvm/llvm-project/commit/301e2ffa5cd87e6c293a85fef0e3597809b3d803
DIFF: https://github.com/llvm/llvm-project/commit/301e2ffa5cd87e6c293a85fef0e3597809b3d803.diff

LOG: [clang][bytecode] Disable DiscardResult in visitBool() (#188916)

It's a visit* function, so we shouldn't discard the result.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Compiler.cpp
    clang/test/AST/ByteCode/c.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 217ba3663edb0..4d129a7ccd497 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4632,6 +4632,9 @@ template <class Emitter> bool Compiler<Emitter>::visitAsLValue(const Expr *E) {
 }
 
 template <class Emitter> bool Compiler<Emitter>::visitBool(const Expr *E) {
+  OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/false,
+                             /*NewInitializing=*/false, /*ToLValue=*/ToLValue);
+
   OptPrimType T = classify(E->getType());
   if (!T) {
     // Convert complex values to bool.

diff  --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c
index 550a51002b60f..78820d04ba3f5 100644
--- a/clang/test/AST/ByteCode/c.c
+++ b/clang/test/AST/ByteCode/c.c
@@ -446,3 +446,6 @@ void strcpyDouble(void) {
   const double test_buf[] = {'4', '2'};
   __builtin_strcpy(buf, test_buf + 1); // all-error {{incompatible pointer types}}
 }
+
+int *iptr;
+void ignoredConditional(void) { *iptr = (((_Complex double)1.0 ? 2 : 3), a); } // all-warning {{left operand of comma operator has no effect}}


        


More information about the cfe-commits mailing list