[clang] [clang][bytecode] Fix a std::optional<bool> mishap (PR #167091)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 7 20:22:26 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

This is about the value saved in the std::optional, not about whether the optional has a value at all.

---
Full diff: https://github.com/llvm/llvm-project/pull/167091.diff


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2-1) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 84f7e6287609c..d0368feda0052 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Compiler.h"
+#include "ByteCode/Interp.h"
 #include "ByteCodeEmitter.h"
 #include "Context.h"
 #include "FixedPoint.h"
@@ -2508,7 +2509,7 @@ bool Compiler<Emitter>::VisitAbstractConditionalOperator(
   };
 
   if (std::optional<bool> BoolValue = getBoolValue(Condition)) {
-    if (BoolValue)
+    if (*BoolValue)
       return visitChildExpr(TrueExpr);
     return visitChildExpr(FalseExpr);
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/167091


More information about the cfe-commits mailing list