[clang] [clang][bytecode][NFC] Mark results as non-empty when taking a value (PR #204568)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 05:19:41 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/204568.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/EvaluationResult.h (+3-7)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/204568
More information about the cfe-commits
mailing list