[clang] c61fe18 - [clang][Interp][NFC] Get rid of InterpSize

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 25 07:03:49 PST 2023


Author: Timm Bäder
Date: 2023-01-25T16:03:33+01:00
New Revision: c61fe188a7e8e8c4b3098998f3dfa194e4842ebc

URL: https://github.com/llvm/llvm-project/commit/c61fe188a7e8e8c4b3098998f3dfa194e4842ebc
DIFF: https://github.com/llvm/llvm-project/commit/c61fe188a7e8e8c4b3098998f3dfa194e4842ebc.diff

LOG: [clang][Interp][NFC] Get rid of InterpSize

Added: 
    

Modified: 
    clang/lib/AST/Interp/Descriptor.h
    clang/lib/AST/Interp/InterpBlock.h
    clang/lib/AST/Interp/Program.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Descriptor.h b/clang/lib/AST/Interp/Descriptor.h
index 6ef4fc2f4c9b..57cb5728c9ba 100644
--- a/clang/lib/AST/Interp/Descriptor.h
+++ b/clang/lib/AST/Interp/Descriptor.h
@@ -44,9 +44,6 @@ using BlockDtorFn = void (*)(Block *Storage, char *FieldPtr,
 using BlockMoveFn = void (*)(Block *Storage, char *SrcFieldPtr,
                              char *DstFieldPtr, Descriptor *FieldDesc);
 
-/// Object size as used by the interpreter.
-using InterpSize = unsigned;
-
 /// Inline descriptor embedded in structures and arrays.
 ///
 /// Such descriptors precede all composite array elements and structure fields.
@@ -81,13 +78,13 @@ struct Descriptor final {
   /// Original declaration, used to emit the error message.
   const DeclTy Source;
   /// Size of an element, in host bytes.
-  const InterpSize ElemSize;
+  const unsigned ElemSize;
   /// Size of the storage, in host bytes.
-  const InterpSize Size;
+  const unsigned Size;
   // Size of the metadata.
-  const InterpSize MDSize;
+  const unsigned MDSize;
   /// Size of the allocation (storage + metadata), in host bytes.
-  const InterpSize AllocSize;
+  const unsigned AllocSize;
 
   /// Value to denote arrays of unknown size.
   static constexpr unsigned UnknownSizeMark = (unsigned)-1;
@@ -96,7 +93,7 @@ struct Descriptor final {
   /// Token to denote structures of unknown size.
   struct UnknownSize {};
 
-  using MetadataSize = std::optional<InterpSize>;
+  using MetadataSize = std::optional<unsigned>;
   static constexpr MetadataSize InlineDescMD = sizeof(InlineDescriptor);
 
   /// Pointer to the record, if block contains records.

diff  --git a/clang/lib/AST/Interp/InterpBlock.h b/clang/lib/AST/Interp/InterpBlock.h
index f790c50a9123..edcbec232e23 100644
--- a/clang/lib/AST/Interp/InterpBlock.h
+++ b/clang/lib/AST/Interp/InterpBlock.h
@@ -68,7 +68,7 @@ class Block final {
   /// Checks if the block is temporary.
   bool isTemporary() const { return Desc->IsTemporary; }
   /// Returns the size of the block.
-  InterpSize getSize() const { return Desc->getAllocSize(); }
+  unsigned getSize() const { return Desc->getAllocSize(); }
   /// Returns the declaration ID.
   std::optional<unsigned> getDeclID() const { return DeclID; }
 

diff  --git a/clang/lib/AST/Interp/Program.cpp b/clang/lib/AST/Interp/Program.cpp
index 5305ddd8de18..106c59463e2b 100644
--- a/clang/lib/AST/Interp/Program.cpp
+++ b/clang/lib/AST/Interp/Program.cpp
@@ -340,7 +340,7 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
             D, ElemTy.getTypePtr(), std::nullopt, IsConst, IsTemporary);
         if (!ElemDesc)
           return nullptr;
-        InterpSize ElemSize =
+        unsigned ElemSize =
             ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
         if (std::numeric_limits<unsigned>::max() / ElemSize <= NumElems)
           return {};


        


More information about the cfe-commits mailing list