Eliminate a pointer of storage in each ObjCInterfaceType and
ObjCObjectPointerType AST node by allocating the list of protocols
after the type node itself. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95597 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 386a5f3..c9d85c8 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -2163,10 +2163,14 @@
ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
}
- // No Match;
- ObjCObjectPointerType *QType = new (*this, TypeAlignment)
- ObjCObjectPointerType(*this, Canonical, InterfaceT, Protocols,
- NumProtocols);
+ // No match.
+ unsigned Size = sizeof(ObjCObjectPointerType)
+ + NumProtocols * sizeof(ObjCProtocolDecl *);
+ void *Mem = Allocate(Size, TypeAlignment);
+ ObjCObjectPointerType *QType = new (Mem) ObjCObjectPointerType(Canonical,
+ InterfaceT,
+ Protocols,
+ NumProtocols);
Types.push_back(QType);
ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
@@ -2199,9 +2203,13 @@
ObjCInterfaceTypes.FindNodeOrInsertPos(ID, InsertPos);
}
- ObjCInterfaceType *QType = new (*this, TypeAlignment)
- ObjCInterfaceType(*this, Canonical, const_cast<ObjCInterfaceDecl*>(Decl),
- Protocols, NumProtocols);
+ unsigned Size = sizeof(ObjCInterfaceType)
+ + NumProtocols * sizeof(ObjCProtocolDecl *);
+ void *Mem = Allocate(Size, TypeAlignment);
+ ObjCInterfaceType *QType = new (Mem) ObjCInterfaceType(Canonical,
+ const_cast<ObjCInterfaceDecl*>(Decl),
+ Protocols,
+ NumProtocols);
Types.push_back(QType);
ObjCInterfaceTypes.InsertNode(QType, InsertPos);