Skip to content

Commit 347df23

Browse files
authored
[clang][bytecode] Remove Program include from InterpFrame.h (#160843)
Program itself is unused in that file, so just include the needed headers.
1 parent a27baf9 commit 347df23

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

clang/lib/AST/ByteCode/EvalEmitter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "EvaluationResult.h"
1717
#include "InterpState.h"
1818
#include "PrimType.h"
19+
#include "Record.h"
1920
#include "Source.h"
2021

2122
namespace clang {

clang/lib/AST/ByteCode/InterpBlock.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ class Block final {
115115
return reinterpret_cast<const std::byte *>(this) + sizeof(Block);
116116
}
117117

118-
template <typename T> T deref() const {
118+
template <typename T> const T &deref() const {
119119
return *reinterpret_cast<const T *>(data());
120120
}
121+
template <typename T> T &deref() { return *reinterpret_cast<T *>(data()); }
121122

122123
/// Invokes the constructor.
123124
void invokeCtor() {

clang/lib/AST/ByteCode/InterpFrame.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#define LLVM_CLANG_AST_INTERP_INTERPFRAME_H
1515

1616
#include "Frame.h"
17-
#include "Program.h"
17+
#include "InterpBlock.h"
18+
#include "Pointer.h"
1819

1920
namespace clang {
2021
namespace interp {
@@ -93,7 +94,7 @@ class InterpFrame final : public Frame {
9394
auto Pt = Params.find(Offset);
9495
if (Pt == Params.end())
9596
return stackRef<T>(Offset);
96-
return Pointer(reinterpret_cast<Block *>(Pt->second.get())).deref<T>();
97+
return reinterpret_cast<const Block *>(Pt->second.get())->deref<T>();
9798
}
9899

99100
/// Mutates a local copy of a parameter.
@@ -151,7 +152,7 @@ class InterpFrame final : public Frame {
151152

152153
/// Returns an offset to a local.
153154
template <typename T> T &localRef(unsigned Offset) const {
154-
return getLocalPointer(Offset).deref<T>();
155+
return localBlock(Offset)->deref<T>();
155156
}
156157

157158
/// Returns a pointer to a local's block.

0 commit comments

Comments
 (0)