Author: Timm Bäder Date: 2023-01-25T17:09:34+01:00 New Revision: c68af565ff0c2fdc5537e9ac0c2d7c75df44b035
URL: https://github.com/llvm/llvm-project/commit/c68af565ff0c2fdc5537e9ac0c2d7c75df44b035 DIFF: https://github.com/llvm/llvm-project/commit/c68af565ff0c2fdc5537e9ac0c2d7c75df44b035.diff LOG: [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. Added: Modified: clang/lib/AST/Interp/InterpFrame.cpp clang/lib/AST/Interp/InterpFrame.h Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/InterpFrame.cpp b/clang/lib/AST/Interp/InterpFrame.cpp index ee29997cfecc..584cf1a9a69e 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<Block *>(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<Block *>(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 bfa02c90ebec..c0f4825096be 100644 --- a/clang/lib/AST/Interp/InterpFrame.h +++ b/clang/lib/AST/Interp/InterpFrame.h @@ -133,8 +133,8 @@ class InterpFrame final : public Frame { } /// 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<Block *>(Locals.get() + Offset - sizeof(Block)); } // Returns the inline descriptor of the local. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits