diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2009-10-24 09:57:09 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2009-10-24 09:57:09 +0000 |
| commit | 1402ce3e42b9fb9a1b45bd68fead25236def315c (patch) | |
| tree | d5677f97631f6396a0cfebfc8151f3279a8556e2 /clang/lib/AST | |
| parent | 703a3f8a7ba3df3c04ca78c1ab29889d4ea98477 (diff) | |
| download | bcm5719-llvm-1402ce3e42b9fb9a1b45bd68fead25236def315c.tar.gz bcm5719-llvm-1402ce3e42b9fb9a1b45bd68fead25236def315c.zip | |
Switch alloca/sprintf to SmallString/raw_ostream.
llvm-svn: 84996
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index eb09d9ecce0..6c63c524b40 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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, |

