diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-06 19:55:15 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-06 19:55:15 +0000 |
commit | 6e94ef5696cfb005d3fc7bbac8dcf7690b64f0a5 (patch) | |
tree | 97de005ec3d70e33d4173910446a126dd9a2211a /Driver/RewriteObjC.cpp | |
parent | 2770105f9ecdc1bf8ba0bc9ed1963eeabc10377d (diff) |
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
Diffstat (limited to 'Driver/RewriteObjC.cpp')
-rw-r--r-- | Driver/RewriteObjC.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp index f860433c29..4e262963a9 100644 --- a/Driver/RewriteObjC.cpp +++ b/Driver/RewriteObjC.cpp @@ -1717,7 +1717,7 @@ Stmt *RewriteObjC::RewriteAtEncode(ObjCEncodeExpr *Exp) { QualType StrType = Context->getPointerType(Context->CharTy); std::string StrEncoding; Context->getObjCEncodingForType(Exp->getEncodedType(), StrEncoding); - Expr *Replacement = new StringLiteral(StrEncoding.c_str(), + Expr *Replacement = new (*Context) StringLiteral(*Context,StrEncoding.c_str(), StrEncoding.length(), false, StrType, SourceLocation(), SourceLocation()); ReplaceStmt(Exp, Replacement); @@ -1734,7 +1734,8 @@ Stmt *RewriteObjC::RewriteAtSelector(ObjCSelectorExpr *Exp) { // Create a call to sel_registerName("selName"). llvm::SmallVector<Expr*, 8> SelExprs; QualType argType = Context->getPointerType(Context->CharTy); - SelExprs.push_back(new StringLiteral(Exp->getSelector().getAsString().c_str(), + SelExprs.push_back(new (*Context) StringLiteral((*Context), + Exp->getSelector().getAsString().c_str(), Exp->getSelector().getAsString().size(), false, argType, SourceLocation(), SourceLocation())); @@ -2271,10 +2272,11 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) { SourceLocation())); llvm::SmallVector<Expr*, 8> ClsExprs; QualType argType = Context->getPointerType(Context->CharTy); - ClsExprs.push_back(new StringLiteral(SuperDecl->getIdentifier()->getName(), - SuperDecl->getIdentifier()->getLength(), - false, argType, SourceLocation(), - SourceLocation())); + ClsExprs.push_back(new (*Context) StringLiteral(*Context, + SuperDecl->getIdentifier()->getName(), + SuperDecl->getIdentifier()->getLength(), + false, argType, SourceLocation(), + SourceLocation())); CallExpr *Cls = SynthesizeCallToFunctionDecl(GetMetaClassFunctionDecl, &ClsExprs[0], ClsExprs.size()); @@ -2322,7 +2324,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) { } else { llvm::SmallVector<Expr*, 8> ClsExprs; QualType argType = Context->getPointerType(Context->CharTy); - ClsExprs.push_back(new StringLiteral(clsName->getName(), + ClsExprs.push_back(new (*Context) StringLiteral(*Context, + clsName->getName(), clsName->getLength(), false, argType, SourceLocation(), SourceLocation())); @@ -2352,10 +2355,11 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) { llvm::SmallVector<Expr*, 8> ClsExprs; QualType argType = Context->getPointerType(Context->CharTy); - ClsExprs.push_back(new StringLiteral(SuperDecl->getIdentifier()->getName(), - SuperDecl->getIdentifier()->getLength(), - false, argType, SourceLocation(), - SourceLocation())); + ClsExprs.push_back(new (*Context) StringLiteral(*Context, + SuperDecl->getIdentifier()->getName(), + SuperDecl->getIdentifier()->getLength(), + false, argType, SourceLocation(), + SourceLocation())); CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl, &ClsExprs[0], ClsExprs.size()); @@ -2409,7 +2413,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) { // Create a call to sel_registerName("selName"), it will be the 2nd argument. llvm::SmallVector<Expr*, 8> SelExprs; QualType argType = Context->getPointerType(Context->CharTy); - SelExprs.push_back(new StringLiteral(Exp->getSelector().getAsString().c_str(), + SelExprs.push_back(new (*Context) StringLiteral(*Context, + Exp->getSelector().getAsString().c_str(), Exp->getSelector().getAsString().size(), false, argType, SourceLocation(), SourceLocation())); @@ -2574,9 +2579,11 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) { // Create a call to objc_getProtocol("ProtocolName"). llvm::SmallVector<Expr*, 8> ProtoExprs; QualType argType = Context->getPointerType(Context->CharTy); - ProtoExprs.push_back(new StringLiteral(Exp->getProtocol()->getNameAsCString(), - strlen(Exp->getProtocol()->getNameAsCString()), - false, argType, SourceLocation(), + ProtoExprs.push_back(new (*Context) + StringLiteral(*Context, + Exp->getProtocol()->getNameAsCString(), + strlen(Exp->getProtocol()->getNameAsCString()), + false, argType, SourceLocation(), SourceLocation())); CallExpr *ProtoExp = SynthesizeCallToFunctionDecl(GetProtocolFunctionDecl, &ProtoExprs[0], |