summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-05-24 18:10:50 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-05-24 18:10:50 +0000
commit97276c8be5f3c7a8e4aa9e2dd417be2a992f3abf (patch)
tree3f76fbbbee171e9fc69b32bda8d0cb8db6f780ba /clang/lib/AST
parent3154e77795d22988862c92d611788bb75e53b027 (diff)
downloadbcm5719-llvm-97276c8be5f3c7a8e4aa9e2dd417be2a992f3abf.tar.gz
bcm5719-llvm-97276c8be5f3c7a8e4aa9e2dd417be2a992f3abf.zip
[RecordLayout] Use an ASTVector instead of using a separate pointer and counter
No functional change is intended. llvm-svn: 270591
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/RecordLayout.cpp28
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp19
2 files changed, 15 insertions, 32 deletions
diff --git a/clang/lib/AST/RecordLayout.cpp b/clang/lib/AST/RecordLayout.cpp
index 4cee2e06311..299fd111bf6 100644
--- a/clang/lib/AST/RecordLayout.cpp
+++ b/clang/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,8 +43,7 @@ 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,
@@ -63,13 +55,9 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
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);
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index d03273f9175..cf981be0a4d 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2949,8 +2949,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
NewEntry = new (*this) ASTRecordLayout(
*this, Builder.Size, Builder.Alignment, Builder.RequiredAlignment,
Builder.HasOwnVFPtr, Builder.HasOwnVFPtr || Builder.PrimaryBase,
- Builder.VBPtrOffset, Builder.DataSize,
- Builder.FieldOffsets.data(), Builder.FieldOffsets.size(),
+ Builder.VBPtrOffset, Builder.DataSize, Builder.FieldOffsets,
Builder.NonVirtualSize, Builder.Alignment, CharUnits::Zero(),
Builder.PrimaryBase, false, Builder.SharedVBPtrBase,
Builder.EndsWithZeroSizedObject, Builder.LeadsWithZeroSizedBase,
@@ -2959,8 +2958,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
Builder.layout(D);
NewEntry = new (*this) ASTRecordLayout(
*this, Builder.Size, Builder.Alignment, Builder.RequiredAlignment,
- Builder.Size, Builder.FieldOffsets.data(),
- Builder.FieldOffsets.size());
+ Builder.Size, Builder.FieldOffsets);
}
} else {
if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
@@ -2983,9 +2981,8 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
*this, Builder.getSize(), Builder.Alignment,
/*RequiredAlignment : used by MS-ABI)*/
Builder.Alignment, Builder.HasOwnVFPtr, RD->isDynamicClass(),
- CharUnits::fromQuantity(-1), DataSize, Builder.FieldOffsets.data(),
- Builder.FieldOffsets.size(), NonVirtualSize,
- Builder.NonVirtualAlignment,
+ CharUnits::fromQuantity(-1), DataSize, Builder.FieldOffsets,
+ NonVirtualSize, Builder.NonVirtualAlignment,
EmptySubobjects.SizeOfLargestEmptySubobject, Builder.PrimaryBase,
Builder.PrimaryBaseIsVirtual, nullptr, false, false, Builder.Bases,
Builder.VBases);
@@ -2996,8 +2993,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
NewEntry = new (*this) ASTRecordLayout(
*this, Builder.getSize(), Builder.Alignment,
/*RequiredAlignment : used by MS-ABI)*/
- Builder.Alignment, Builder.getSize(), Builder.FieldOffsets.data(),
- Builder.FieldOffsets.size());
+ Builder.Alignment, Builder.getSize(), Builder.FieldOffsets);
}
}
@@ -3112,13 +3108,12 @@ ASTContext::getObjCLayout(const ObjCInterfaceDecl *D,
Builder.Layout(D);
const ASTRecordLayout *NewEntry =
- new (*this) ASTRecordLayout(*this, Builder.getSize(),
+ new (*this) ASTRecordLayout(*this, Builder.getSize(),
Builder.Alignment,
/*RequiredAlignment : used by MS-ABI)*/
Builder.Alignment,
Builder.getDataSize(),
- Builder.FieldOffsets.data(),
- Builder.FieldOffsets.size());
+ Builder.FieldOffsets);
ObjCLayouts[Key] = NewEntry;
OpenPOWER on IntegriCloud