[clang][Interp][NFC] Cast in InterpFrame::localBlock
authorTimm Bäder <tbaeder@redhat.com>
Sat, 31 Dec 2022 11:53:02 +0000 (12:53 +0100)
committerTimm Bäder <tbaeder@redhat.com>
Wed, 25 Jan 2023 16:09:34 +0000 (17:09 +0100)
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
clang/lib/AST/Interp/InterpFrame.h

index ee29997..584cf1a 100644 (file)
@@ -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) {
index bfa02c9..c0f4825 100644 (file)
@@ -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<Block *>(Locals.get() + Offset - sizeof(Block));
   }
 
   // Returns the inline descriptor of the local.