From: Timm Bäder Date: Sat, 31 Dec 2022 11:53:02 +0000 (+0100) Subject: [clang][Interp][NFC] Cast in InterpFrame::localBlock X-Git-Tag: upstream/17.0.6~19627 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c68af565ff0c2fdc5537e9ac0c2d7c75df44b035;p=platform%2Fupstream%2Fllvm.git [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. --- 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.