https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/204568

This was missing and all the EvaluationResults always ended up being empty even 
though their APValue was set. Since the assert(!empty()) was missing from 
`takeAPValue()`, nobody noticed though.

>From 2dbb6c7d757366b455a419914694b0638c79ff2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Thu, 18 Jun 2026 14:11:03 +0200
Subject: [PATCH] [clang][bytecode][NFC] Mark results as non-empty when taking
 a value

This was missing and all the EvaluationResults always ended up being
empty even though their APValue was set. Since the assert(!empty()) was
missing from `takeAPValue()`, nobody noticed though.
---
 clang/lib/AST/ByteCode/EvaluationResult.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/clang/lib/AST/ByteCode/EvaluationResult.h 
b/clang/lib/AST/ByteCode/EvaluationResult.h
index bd08ac1466691..381600955440d 100644
--- a/clang/lib/AST/ByteCode/EvaluationResult.h
+++ b/clang/lib/AST/ByteCode/EvaluationResult.h
@@ -51,6 +51,8 @@ class EvaluationResult final {
   void takeValue(APValue &&V) {
     assert(empty());
     Value = std::move(V);
+    Kind = Valid;
+    assert(!empty());
   }
   void setInvalid() {
     // We are NOT asserting empty() here, since setting it to invalid
@@ -72,13 +74,7 @@ class EvaluationResult final {
   bool empty() const { return Kind == Empty; }
   bool isInvalid() const { return Kind == Invalid; }
 
-  /// Returns an APValue for the evaluation result.
-  APValue toAPValue() const {
-    assert(!empty());
-    assert(!isInvalid());
-    return Value;
-  }
-
+  /// Moves the APValue containing the evaluation result to the caller.
   APValue stealAPValue() { return std::move(Value); }
 
   /// Check that all subobjects of the given pointer have been initialized.

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to