[clang] [clang][bytecode] Remove Program include from InterpFrame.h (PR #160843)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 26 03:09:00 PDT 2025
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/160843
Program itself is unused in that filre, so just include the needed headers.
>From d7dcb117d3966cb0ef29183b3d25675cd3f49eef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Fri, 26 Sep 2025 12:07:39 +0200
Subject: [PATCH] [clang][bytecode] Remove Program include from InterpFrame.h
Program itself is unused in that filre, so just include the needed
headers.
---
clang/lib/AST/ByteCode/EvalEmitter.h | 1 +
clang/lib/AST/ByteCode/InterpBlock.h | 3 ++-
clang/lib/AST/ByteCode/InterpFrame.h | 7 ++++---
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h b/clang/lib/AST/ByteCode/EvalEmitter.h
index e81ea67adf97a..a9f87db5d7f8d 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.h
+++ b/clang/lib/AST/ByteCode/EvalEmitter.h
@@ -16,6 +16,7 @@
#include "EvaluationResult.h"
#include "InterpState.h"
#include "PrimType.h"
+#include "Record.h"
#include "Source.h"
namespace clang {
diff --git a/clang/lib/AST/ByteCode/InterpBlock.h b/clang/lib/AST/ByteCode/InterpBlock.h
index ea9f44c38842e..9b3dadca6cc14 100644
--- a/clang/lib/AST/ByteCode/InterpBlock.h
+++ b/clang/lib/AST/ByteCode/InterpBlock.h
@@ -115,9 +115,10 @@ class Block final {
return reinterpret_cast<const std::byte *>(this) + sizeof(Block);
}
- template <typename T> T deref() const {
+ template <typename T> const T &deref() const {
return *reinterpret_cast<const T *>(data());
}
+ template <typename T> T &deref() { return *reinterpret_cast<T *>(data()); }
/// Invokes the constructor.
void invokeCtor() {
diff --git a/clang/lib/AST/ByteCode/InterpFrame.h b/clang/lib/AST/ByteCode/InterpFrame.h
index 3cdc164e4bdda..fa9de2e1e7c6d 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.h
+++ b/clang/lib/AST/ByteCode/InterpFrame.h
@@ -14,7 +14,8 @@
#define LLVM_CLANG_AST_INTERP_INTERPFRAME_H
#include "Frame.h"
-#include "Program.h"
+#include "InterpBlock.h"
+#include "Pointer.h"
namespace clang {
namespace interp {
@@ -93,7 +94,7 @@ class InterpFrame final : public Frame {
auto Pt = Params.find(Offset);
if (Pt == Params.end())
return stackRef<T>(Offset);
- return Pointer(reinterpret_cast<Block *>(Pt->second.get())).deref<T>();
+ return reinterpret_cast<const Block *>(Pt->second.get())->deref<T>();
}
/// Mutates a local copy of a parameter.
@@ -151,7 +152,7 @@ class InterpFrame final : public Frame {
/// Returns an offset to a local.
template <typename T> T &localRef(unsigned Offset) const {
- return getLocalPointer(Offset).deref<T>();
+ return localBlock(Offset)->deref<T>();
}
/// Returns a pointer to a local's block.
More information about the cfe-commits
mailing list