[cfe-commits] r84996 - /cfe/trunk/lib/AST/ASTContext.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sat Oct 24 02:57:11 PDT 2009
Author: d0k
Date: Sat Oct 24 04:57:09 2009
New Revision: 84996
URL: http://llvm.org/viewvc/llvm-project?rev=84996&view=rev
Log:
Switch alloca/sprintf to SmallString/raw_ostream.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=84996&r1=84995&r2=84996&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Oct 24 04:57:09 2009
@@ -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 @@
// 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 @@
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,
More information about the cfe-commits
mailing list