Expand Up
@@ -39,16 +39,14 @@ ObjCArrayLiteral *ObjCArrayLiteral::Create(const ASTContext &C,
ArrayRef<Expr *> Elements,
QualType T, ObjCMethodDecl *Method,
SourceRange SR) {
void *Mem =
C.Allocate (sizeof (ObjCArrayLiteral) + Elements.size () * sizeof (Expr *));
void *Mem = C.Allocate (totalSizeToAlloc<Expr *>(Elements.size ()));
return new (Mem) ObjCArrayLiteral (Elements, T, Method, SR);
}
ObjCArrayLiteral *ObjCArrayLiteral::CreateEmpty (const ASTContext &C,
unsigned NumElements) {
void *Mem =
C.Allocate (sizeof (ObjCArrayLiteral) + NumElements * sizeof (Expr *));
void *Mem = C.Allocate (totalSizeToAlloc<Expr *>(NumElements));
return new (Mem) ObjCArrayLiteral (EmptyShell (), NumElements);
}
Expand All
@@ -60,8 +58,8 @@ ObjCDictionaryLiteral::ObjCDictionaryLiteral(ArrayRef<ObjCDictionaryElement> VK,
false , false ),
NumElements(VK.size()), HasPackExpansions(HasPackExpansions), Range(SR),
DictWithObjectsMethod(method) {
KeyValuePair *KeyValues = getKeyValues ();
ExpansionData *Expansions = getExpansionData ();
KeyValuePair *KeyValues = getTrailingObjects<KeyValuePair> ();
ExpansionData *Expansions = getTrailingObjects<ExpansionData> ();
for (unsigned I = 0 ; I < NumElements; I++) {
if (VK[I].Key ->isTypeDependent () || VK[I].Key ->isValueDependent () ||
VK[I].Value ->isTypeDependent () || VK[I].Value ->isValueDependent ())
Expand Down
Expand Up
@@ -91,23 +89,16 @@ ObjCDictionaryLiteral::Create(const ASTContext &C,
ArrayRef<ObjCDictionaryElement> VK,
bool HasPackExpansions, QualType T,
ObjCMethodDecl *method, SourceRange SR) {
unsigned ExpansionsSize = 0 ;
if (HasPackExpansions)
ExpansionsSize = sizeof (ExpansionData) * VK.size ();
void *Mem = C.Allocate (sizeof (ObjCDictionaryLiteral) +
sizeof (KeyValuePair) * VK.size () + ExpansionsSize);
void *Mem = C.Allocate (totalSizeToAlloc<KeyValuePair, ExpansionData>(
VK.size (), HasPackExpansions ? VK.size () : 0 ));
return new (Mem) ObjCDictionaryLiteral (VK, HasPackExpansions, T, method, SR);
}
ObjCDictionaryLiteral *
ObjCDictionaryLiteral::CreateEmpty (const ASTContext &C, unsigned NumElements,
bool HasPackExpansions) {
unsigned ExpansionsSize = 0 ;
if (HasPackExpansions)
ExpansionsSize = sizeof (ExpansionData) * NumElements;
void *Mem = C.Allocate (sizeof (ObjCDictionaryLiteral) +
sizeof (KeyValuePair) * NumElements + ExpansionsSize);
void *Mem = C.Allocate (totalSizeToAlloc<KeyValuePair, ExpansionData>(
NumElements, HasPackExpansions ? NumElements : 0 ));
return new (Mem)
ObjCDictionaryLiteral (EmptyShell (), NumElements, HasPackExpansions);
}
Expand All
@@ -122,15 +113,6 @@ QualType ObjCPropertyRefExpr::getReceiverType(const ASTContext &ctx) const {
return getBase ()->getType ();
}
ObjCSubscriptRefExpr *
ObjCSubscriptRefExpr::Create (const ASTContext &C, Expr *base, Expr *key,
QualType T, ObjCMethodDecl *getMethod,
ObjCMethodDecl *setMethod, SourceLocation RB) {
void *Mem = C.Allocate (sizeof (ObjCSubscriptRefExpr));
return new (Mem) ObjCSubscriptRefExpr (
base, key, T, VK_LValue, OK_ObjCSubscript, getMethod, setMethod, RB);
}
ObjCMessageExpr::ObjCMessageExpr (QualType T, ExprValueKind VK,
SourceLocation LBracLoc,
SourceLocation SuperLoc, bool IsInstanceSuper,
Expand Down
Expand Up
@@ -293,11 +275,9 @@ ObjCMessageExpr *ObjCMessageExpr::alloc(const ASTContext &C,
ObjCMessageExpr *ObjCMessageExpr::alloc (const ASTContext &C, unsigned NumArgs,
unsigned NumStoredSelLocs) {
unsigned Size = sizeof (ObjCMessageExpr) + sizeof (void *) +
NumArgs * sizeof (Expr *) +
NumStoredSelLocs * sizeof (SourceLocation);
return (ObjCMessageExpr *)C.Allocate (
Size , llvm::AlignOf<ObjCMessageExpr>::Alignment);
totalSizeToAlloc<void *, SourceLocation>(NumArgs + 1 , NumStoredSelLocs),
llvm::AlignOf<ObjCMessageExpr>::Alignment);
}
void ObjCMessageExpr::getSelectorLocs (
Expand Down
Expand Up
@@ -358,7 +338,7 @@ ObjCInterfaceDecl *ObjCMessageExpr::getReceiverInterface() const {
Stmt::child_range ObjCMessageExpr::children () {
Stmt **begin;
if (getReceiverKind () == Instance)
begin = reinterpret_cast <Stmt **>(this + 1 );
begin = reinterpret_cast <Stmt **>(getTrailingObjects< void *>() );
else
begin = reinterpret_cast <Stmt **>(getArgs ());
return child_range (begin,
Expand Down