aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2009-10-24 09:57:09 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2009-10-24 09:57:09 +0000
commitf5942a44880be26878592eb052b737579349411e (patch)
tree4fa10aec9103fb7211f8cc84afeba1875c600957 /lib/AST/ASTContext.cpp
parentba6a9bd384df475780be636ca45bcef5c5bbd19f (diff)
Switch alloca/sprintf to SmallString/raw_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84996 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index eb09d9ecce..6c63c524b4 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -22,9 +22,10 @@
#include "clang/Basic/Builtins.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/raw_ostream.h"
#include "RecordLayoutBuilder.h"
using namespace clang;
@@ -2855,12 +2856,12 @@ QualType ASTContext::BuildByRefType(const char *DeclName, QualType Ty) {
// FIXME: Move up
static unsigned int UniqueBlockByRefTypeID = 0;
- char * Name =
- (char*)alloca(strlen("__Block_byref_") + 10 + 1 + strlen(DeclName) + 1);
- sprintf(Name, "__Block_byref_%d_%s", ++UniqueBlockByRefTypeID, DeclName);
+ llvm::SmallString<36> Name;
+ llvm::raw_svector_ostream(Name) << "__Block_byref_" <<
+ ++UniqueBlockByRefTypeID << '_' << DeclName;
RecordDecl *T;
T = RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
- &Idents.get(Name));
+ &Idents.get(Name.str()));
T->startDefinition();
QualType Int32Ty = IntTy;
assert(getIntWidth(IntTy) == 32 && "non-32bit int not supported");
@@ -2905,12 +2906,12 @@ QualType ASTContext::getBlockParmType(
llvm::SmallVector<const Expr *, 8> &BlockDeclRefDecls) {
// FIXME: Move up
static unsigned int UniqueBlockParmTypeID = 0;
- char * Name =
- (char*)alloca(strlen("__block_literal_") + 10 + 1);
- sprintf(Name, "__block_literal_%u", ++UniqueBlockParmTypeID);
+ llvm::SmallString<36> Name;
+ llvm::raw_svector_ostream(Name) << "__block_literal_"
+ << ++UniqueBlockParmTypeID;
RecordDecl *T;
T = RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
- &Idents.get(Name));
+ &Idents.get(Name.str()));
QualType FieldTypes[] = {
getPointerType(VoidPtrTy),
IntTy,