From 7281c357b13b8dd67b848a4d0b803078c1b2d000 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 29 Dec 2015 22:31:18 +0000 Subject: [TrailingObjects] Convert OffsetOfExpr. That necessitated moving the OffsetOfNode class out of OffsetOfExpr. llvm-svn: 256590 --- clang/lib/AST/Expr.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'clang/lib/AST/Expr.cpp') diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 7e58653efe1..a000a7de83b 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1314,9 +1314,8 @@ OffsetOfExpr *OffsetOfExpr::Create(const ASTContext &C, QualType type, ArrayRef comps, ArrayRef exprs, SourceLocation RParenLoc) { - void *Mem = C.Allocate(sizeof(OffsetOfExpr) + - sizeof(OffsetOfNode) * comps.size() + - sizeof(Expr*) * exprs.size()); + void *Mem = C.Allocate( + totalSizeToAlloc(comps.size(), exprs.size())); return new (Mem) OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs, RParenLoc); @@ -1324,9 +1323,8 @@ OffsetOfExpr *OffsetOfExpr::Create(const ASTContext &C, QualType type, OffsetOfExpr *OffsetOfExpr::CreateEmpty(const ASTContext &C, unsigned numComps, unsigned numExprs) { - void *Mem = C.Allocate(sizeof(OffsetOfExpr) + - sizeof(OffsetOfNode) * numComps + - sizeof(Expr*) * numExprs); + void *Mem = + C.Allocate(totalSizeToAlloc(numComps, numExprs)); return new (Mem) OffsetOfExpr(numComps, numExprs); } @@ -1356,7 +1354,7 @@ OffsetOfExpr::OffsetOfExpr(const ASTContext &C, QualType type, } } -IdentifierInfo *OffsetOfExpr::OffsetOfNode::getFieldName() const { +IdentifierInfo *OffsetOfNode::getFieldName() const { assert(getKind() == Field || getKind() == Identifier); if (getKind() == Field) return getField()->getIdentifier(); -- cgit v1.2.3