Skip to content

Commit c68af56

Browse files
committed
[clang][Interp][NFC] Cast in InterpFrame::localBlock
We know we save a Block* here, so do the cast there instead of everywhere we're calling this function.
1 parent eee8075 commit c68af56

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

clang/lib/AST/Interp/InterpFrame.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ InterpFrame::~InterpFrame() {
7676

7777
void InterpFrame::destroy(unsigned Idx) {
7878
for (auto &Local : Func->getScope(Idx).locals()) {
79-
S.deallocate(reinterpret_cast<Block *>(localBlock(Local.Offset)));
79+
S.deallocate(localBlock(Local.Offset));
8080
}
8181
}
8282

@@ -185,8 +185,7 @@ const FunctionDecl *InterpFrame::getCallee() const {
185185

186186
Pointer InterpFrame::getLocalPointer(unsigned Offset) const {
187187
assert(Offset < Func->getFrameSize() && "Invalid local offset.");
188-
return Pointer(reinterpret_cast<Block *>(localBlock(Offset)),
189-
sizeof(InlineDescriptor));
188+
return Pointer(localBlock(Offset), sizeof(InlineDescriptor));
190189
}
191190

192191
Pointer InterpFrame::getParamPointer(unsigned Off) {

clang/lib/AST/Interp/InterpFrame.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ class InterpFrame final : public Frame {
133133
}
134134

135135
/// Returns a pointer to a local's block.
136-
void *localBlock(unsigned Offset) const {
137-
return Locals.get() + Offset - sizeof(Block);
136+
Block *localBlock(unsigned Offset) const {
137+
return reinterpret_cast<Block *>(Locals.get() + Offset - sizeof(Block));
138138
}
139139

140140
// Returns the inline descriptor of the local.

0 commit comments

Comments
 (0)