From: Dmitri Gribenko Date: Fri, 6 Jul 2012 16:41:59 +0000 (+0000) Subject: Stop using new[] on llvm::BumpPtrAllocator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=814e219fc6d5faeb48e4fd5375843346f2d4a7a7;p=clang Stop using new[] on llvm::BumpPtrAllocator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159833 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/CommentLexer.h b/include/clang/AST/CommentLexer.h index f8dfd278ee..6683788227 100644 --- a/include/clang/AST/CommentLexer.h +++ b/include/clang/AST/CommentLexer.h @@ -479,7 +479,7 @@ public: return false; } - char *TextPtr = new (Allocator) char[Length + 1]; + char *TextPtr = Allocator.Allocate(Length + 1); memcpy(TextPtr, WordText.c_str(), Length + 1); StringRef Text = StringRef(TextPtr, Length); @@ -525,7 +525,7 @@ public: } const unsigned Length = WordText.size(); - char *TextPtr = new (Allocator) char[Length + 1]; + char *TextPtr = Allocator.Allocate(Length + 1); memcpy(TextPtr, WordText.c_str(), Length + 1); StringRef Text = StringRef(TextPtr, Length); diff --git a/include/clang/AST/CommentParser.h b/include/clang/AST/CommentParser.h index 53c58662bf..e75d7978b7 100644 --- a/include/clang/AST/CommentParser.h +++ b/include/clang/AST/CommentParser.h @@ -34,8 +34,8 @@ class Parser { ArrayRef copyArray(ArrayRef Source) { size_t Size = Source.size(); if (Size != 0) { - T *Mem = new (Allocator) T[Size]; - std::copy(Source.begin(), Source.end(), Mem); + T *Mem = Allocator.Allocate(Size); + std::uninitialized_copy(Source.begin(), Source.end(), Mem); return llvm::makeArrayRef(Mem, Size); } else return llvm::makeArrayRef(static_cast(NULL), 0); diff --git a/lib/AST/CommentParser.cpp b/lib/AST/CommentParser.cpp index 75eae46b8b..14a2d85ae4 100644 --- a/lib/AST/CommentParser.cpp +++ b/lib/AST/CommentParser.cpp @@ -47,7 +47,8 @@ BlockCommandComment *Parser::parseBlockCommandArgs( TextTokenRetokenizer &Retokenizer, unsigned NumArgs) { typedef BlockCommandComment::Argument Argument; - Argument *Args = new (Allocator) Argument[NumArgs]; + Argument *Args = + new (Allocator.Allocate(NumArgs)) Argument[NumArgs]; unsigned ParsedArgs = 0; Token Arg; while (ParsedArgs < NumArgs && Retokenizer.lexWord(Arg)) {