Move StringLiteral to allocate its internal string data using the allocator in
ASTContext. This required changing all clients to pass in the ASTContext& to the
constructor of StringLiteral. I also changed all allocations of StringLiteral to
use new(ASTContext&).
Along the way, I updated a bunch of new()'s in StmtSerialization.cpp to use the
allocator from ASTContext& (not complete).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63958 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index ce13c34..d627ab0 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -38,12 +38,13 @@
}
-StringLiteral::StringLiteral(const char *strData, unsigned byteLength,
- bool Wide, QualType t, SourceLocation firstLoc,
+StringLiteral::StringLiteral(ASTContext& C, const char *strData,
+ unsigned byteLength, bool Wide, QualType t,
+ SourceLocation firstLoc,
SourceLocation lastLoc) :
Expr(StringLiteralClass, t) {
// OPTIMIZE: could allocate this appended to the StringLiteral.
- char *AStrData = new char[byteLength];
+ char *AStrData = new (C, 1) char[byteLength];
memcpy(AStrData, strData, byteLength);
StrData = AStrData;
ByteLength = byteLength;
@@ -52,8 +53,9 @@
lastTokLoc = lastLoc;
}
-StringLiteral::~StringLiteral() {
- delete[] StrData;
+void StringLiteral::Destroy(ASTContext &C) {
+ C.Deallocate(const_cast<char*>(StrData));
+ this->~StringLiteral();
}
bool UnaryOperator::isPostfix(Opcode Op) {