[clang] d2dd4ce - [clang][bytecode][NFC] Mark results as non-empty when taking a value (#204568)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 06:34:11 PDT 2026
Author: Timm Baeder
Date: 2026-06-18T15:34:05+02:00
New Revision: d2dd4ce545bd5753f37181f2821bc8ac07601de8
URL: https://github.com/llvm/llvm-project/commit/d2dd4ce545bd5753f37181f2821bc8ac07601de8
DIFF: https://github.com/llvm/llvm-project/commit/d2dd4ce545bd5753f37181f2821bc8ac07601de8.diff
LOG: [clang][bytecode][NFC] Mark results as non-empty when taking a value (#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.
Added:
Modified:
clang/lib/AST/ByteCode/EvaluationResult.h
Removed:
################################################################################
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.
More information about the cfe-commits
mailing list