From c68af565ff0c2fdc5537e9ac0c2d7c75df44b035 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Sat, 31 Dec 2022 12:53:02 +0100 Subject: [PATCH] [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. --- clang/lib/AST/Interp/InterpFrame.cpp | 5 ++--- clang/lib/AST/Interp/InterpFrame.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/Interp/InterpFrame.cpp b/clang/lib/AST/Interp/InterpFrame.cpp index ee29997..584cf1a 100644 --- a/clang/lib/AST/Interp/InterpFrame.cpp +++ b/clang/lib/AST/Interp/InterpFrame.cpp @@ -76,7 +76,7 @@ InterpFrame::~InterpFrame() { void InterpFrame::destroy(unsigned Idx) { for (auto &Local : Func->getScope(Idx).locals()) { - S.deallocate(reinterpret_cast(localBlock(Local.Offset))); + S.deallocate(localBlock(Local.Offset)); } } @@ -185,8 +185,7 @@ const FunctionDecl *InterpFrame::getCallee() const { Pointer InterpFrame::getLocalPointer(unsigned Offset) const { assert(Offset < Func->getFrameSize() && "Invalid local offset."); - return Pointer(reinterpret_cast(localBlock(Offset)), - sizeof(InlineDescriptor)); + return Pointer(localBlock(Offset), sizeof(InlineDescriptor)); } Pointer InterpFrame::getParamPointer(unsigned Off) { diff --git a/clang/lib/AST/Interp/InterpFrame.h b/clang/lib/AST/Interp/InterpFrame.h index bfa02c9..c0f4825 100644 --- a/clang/lib/AST/Interp/InterpFrame.h +++ b/clang/lib/AST/Interp/InterpFrame.h @@ -133,8 +133,8 @@ private: } /// Returns a pointer to a local's block. - void *localBlock(unsigned Offset) const { - return Locals.get() + Offset - sizeof(Block); + Block *localBlock(unsigned Offset) const { + return reinterpret_cast(Locals.get() + Offset - sizeof(Block)); } // Returns the inline descriptor of the local. -- 2.7.4