summaryrefslogtreecommitdiff
path: root/lib/AST/RecordLayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/RecordLayout.cpp')
-rw-r--r--lib/AST/RecordLayout.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/lib/AST/RecordLayout.cpp b/lib/AST/RecordLayout.cpp
index b2c244e3790e..299fd111bf6a 100644
--- a/lib/AST/RecordLayout.cpp
+++ b/lib/AST/RecordLayout.cpp
@@ -18,8 +18,6 @@
using namespace clang;
void ASTRecordLayout::Destroy(ASTContext &Ctx) {
- if (FieldOffsets)
- Ctx.Deallocate(FieldOffsets);
if (CXXInfo) {
CXXInfo->~CXXRecordLayoutInfo();
Ctx.Deallocate(CXXInfo);
@@ -29,18 +27,13 @@ void ASTRecordLayout::Destroy(ASTContext &Ctx) {
}
ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
- CharUnits alignment,
+ CharUnits alignment,
CharUnits requiredAlignment,
CharUnits datasize,
- const uint64_t *fieldoffsets,
- unsigned fieldcount)
- : Size(size), DataSize(datasize), Alignment(alignment),
- RequiredAlignment(requiredAlignment), FieldOffsets(nullptr),
- FieldCount(fieldcount), CXXInfo(nullptr) {
- if (FieldCount > 0) {
- FieldOffsets = new (Ctx) uint64_t[FieldCount];
- memcpy(FieldOffsets, fieldoffsets, FieldCount * sizeof(*FieldOffsets));
- }
+ ArrayRef<uint64_t> fieldoffsets)
+ : Size(size), DataSize(datasize), Alignment(alignment),
+ RequiredAlignment(requiredAlignment), CXXInfo(nullptr) {
+ FieldOffsets.append(Ctx, fieldoffsets.begin(), fieldoffsets.end());
}
// Constructor for C++ records.
@@ -50,26 +43,21 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
bool hasOwnVFPtr, bool hasExtendableVFPtr,
CharUnits vbptroffset,
CharUnits datasize,
- const uint64_t *fieldoffsets,
- unsigned fieldcount,
+ ArrayRef<uint64_t> fieldoffsets,
CharUnits nonvirtualsize,
CharUnits nonvirtualalignment,
CharUnits SizeOfLargestEmptySubobject,
const CXXRecordDecl *PrimaryBase,
bool IsPrimaryBaseVirtual,
const CXXRecordDecl *BaseSharingVBPtr,
- bool HasZeroSizedSubObject,
+ bool EndsWithZeroSizedObject,
bool LeadsWithZeroSizedBase,
const BaseOffsetsMapTy& BaseOffsets,
const VBaseOffsetsMapTy& VBaseOffsets)
: Size(size), DataSize(datasize), Alignment(alignment),
- RequiredAlignment(requiredAlignment), FieldOffsets(nullptr),
- FieldCount(fieldcount), CXXInfo(new (Ctx) CXXRecordLayoutInfo)
+ RequiredAlignment(requiredAlignment), CXXInfo(new (Ctx) CXXRecordLayoutInfo)
{
- if (FieldCount > 0) {
- FieldOffsets = new (Ctx) uint64_t[FieldCount];
- memcpy(FieldOffsets, fieldoffsets, FieldCount * sizeof(*FieldOffsets));
- }
+ FieldOffsets.append(Ctx, fieldoffsets.begin(), fieldoffsets.end());
CXXInfo->PrimaryBase.setPointer(PrimaryBase);
CXXInfo->PrimaryBase.setInt(IsPrimaryBaseVirtual);
@@ -82,7 +70,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
CXXInfo->VBPtrOffset = vbptroffset;
CXXInfo->HasExtendableVFPtr = hasExtendableVFPtr;
CXXInfo->BaseSharingVBPtr = BaseSharingVBPtr;
- CXXInfo->HasZeroSizedSubObject = HasZeroSizedSubObject;
+ CXXInfo->EndsWithZeroSizedObject = EndsWithZeroSizedObject;
CXXInfo->LeadsWithZeroSizedBase = LeadsWithZeroSizedBase;