diff --git a/clang/lib/AST/Interp/Descriptor.h b/clang/lib/AST/Interp/Descriptor.h index 6ef4fc2f4c9be2..57cb5728c9ba8b 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; + using MetadataSize = std::optional; 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 f790c50a91237f..edcbec232e23d8 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 getDeclID() const { return DeclID; } diff --git a/clang/lib/AST/Interp/Program.cpp b/clang/lib/AST/Interp/Program.cpp index 5305ddd8de1899..106c59463e2bf8 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::max() / ElemSize <= NumElems) return {};