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);
// 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()));
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());
} 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()));
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());
// 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()));
// 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],
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
+#include "clang/AST/ASTContext.h"
#include "llvm/Bitcode/Serialize.h"
#include "llvm/Bitcode/Deserialize.h"
QualType t = QualType::ReadVal(D);
SourceLocation AALoc = SourceLocation::ReadVal(D);
SourceLocation LLoc = SourceLocation::ReadVal(D);
- AddrLabelExpr* expr = new AddrLabelExpr(AALoc,LLoc,NULL,t);
+ AddrLabelExpr* expr = new (C, llvm::alignof<AddrLabelExpr>())
+ AddrLabelExpr(AALoc,LLoc,NULL,t);
D.ReadPtr(expr->Label); // Pointer may be backpatched.
return expr;
}
SourceLocation L = SourceLocation::ReadVal(D);
Expr *LHS, *RHS;
D.BatchReadOwnedPtrs(LHS, RHS, C);
- return new ArraySubscriptExpr(LHS,RHS,t,L);
+ return new (C, llvm::alignof<ArraySubscriptExpr>())
+ ArraySubscriptExpr(LHS,RHS,t,L);
}
void AsmStmt::EmitImpl(Serializer& S) const {
bool IsVolatile = D.ReadBool();
bool IsSimple = D.ReadBool();
- AsmStmt *Stmt = new AsmStmt(ALoc, IsSimple, IsVolatile, 0, 0, 0, 0, 0,
- AsmStr,
- 0, 0, PLoc);
+ AsmStmt *Stmt = new (C, llvm::alignof<AsmStmt>())
+ AsmStmt(ALoc, IsSimple, IsVolatile, 0, 0, 0, 0, 0, AsmStr, 0, 0, PLoc);
Stmt->NumOutputs = D.ReadInt();
Stmt->NumInputs = D.ReadInt();
Expr *LHS, *RHS;
D.BatchReadOwnedPtrs(LHS, RHS, C);
- return new BinaryOperator(LHS,RHS,Opc,Result,OpLoc);
+ return new (C, llvm::alignof<BinaryOperator>())
+ BinaryOperator(LHS,RHS,Opc,Result,OpLoc);
}
void BreakStmt::EmitImpl(Serializer& S) const {
BreakStmt* BreakStmt::CreateImpl(Deserializer& D, ASTContext& C) {
SourceLocation Loc = SourceLocation::ReadVal(D);
- return new BreakStmt(Loc);
+ return new (C, llvm::alignof<BreakStmt>()) BreakStmt(Loc);
}
void CallExpr::EmitImpl(Serializer& S) const {
QualType t = QualType::ReadVal(D);
SourceLocation L = SourceLocation::ReadVal(D);
unsigned NumArgs = D.ReadInt();
- Stmt** SubExprs = new Stmt*[NumArgs+1];
+ Stmt** SubExprs = new (C, llvm::alignof<Stmt*>()) Stmt*[NumArgs+1];
D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C);
- return new CallExpr(SC, SubExprs,NumArgs,t,L);
+ return new (C, llvm::alignof<CallExpr>()) CallExpr(SC, SubExprs,NumArgs,t,L);
}
void CaseStmt::EmitImpl(Serializer& S) const {
CaseStmt* CaseStmt::CreateImpl(Deserializer& D, ASTContext& C) {
SourceLocation CaseLoc = SourceLocation::ReadVal(D);
- CaseStmt* stmt = new CaseStmt(NULL,NULL,NULL,CaseLoc);
+ CaseStmt* stmt = new (C, llvm::alignof<CaseStmt>())
+ CaseStmt(NULL,NULL,NULL,CaseLoc);
D.ReadPtr(stmt->NextSwitchCase);
D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0], C);
return stmt;
SourceLocation LPLoc = SourceLocation::ReadVal(D);
SourceLocation RPLoc = SourceLocation::ReadVal(D);
Expr* Op = D.ReadOwnedPtr<Expr>(C);
- return new CStyleCastExpr(t,Op,writtenTy,LPLoc,RPLoc);
+ return new (C, llvm::alignof<CStyleCastExpr>())
+ CStyleCastExpr(t,Op,writtenTy,LPLoc,RPLoc);
}
void CharacterLiteral::EmitImpl(Serializer& S) const {
SourceLocation Loc = SourceLocation::ReadVal(D);
bool iswide = D.ReadBool();
QualType T = QualType::ReadVal(D);
- return new CharacterLiteral(value,iswide,T,Loc);
+ return new (C, llvm::alignof<CharacterLiteral>())
+ CharacterLiteral(value,iswide,T,Loc);
}
void CompoundAssignOperator::EmitImpl(Serializer& S) const {
Expr* LHS, *RHS;
D.BatchReadOwnedPtrs(LHS, RHS, C);
- return new CompoundAssignOperator(LHS,RHS,Opc,t,c,L);
+ return new (C, llvm::alignof<CompoundAssignOperator>())
+ CompoundAssignOperator(LHS,RHS,Opc,t,c,L);
}
void CompoundLiteralExpr::EmitImpl(Serializer& S) const {
SourceLocation L = SourceLocation::ReadVal(D);
bool fileScope = D.ReadBool();
Expr* Init = D.ReadOwnedPtr<Expr>(C);
- return new CompoundLiteralExpr(L, Q, Init, fileScope);
+ return new (C, llvm::alignof<CompoundLiteralExpr>())
+ CompoundLiteralExpr(L, Q, Init, fileScope);
}
void CompoundStmt::EmitImpl(Serializer& S) const {
SourceLocation RB = SourceLocation::ReadVal(D);
unsigned size = D.ReadInt();
- CompoundStmt* stmt = new CompoundStmt(NULL,0,LB,RB);
+ CompoundStmt* stmt = new (C, llvm::alignof<CompoundStmt>())
+ CompoundStmt(NULL, 0, LB, RB);
stmt->Body.reserve(size);
ASTContext& C) {
QualType t = QualType::ReadVal(D);
- ConditionalOperator* c = new ConditionalOperator(NULL,NULL,NULL,t);
+ ConditionalOperator* c = new (C, llvm::alignof<ConditionalOperator>())
+ ConditionalOperator(NULL,NULL,NULL,t);
D.BatchReadOwnedPtrs((unsigned) END_EXPR, c->SubExprs, C);
return c;
}
bool isWide = D.ReadBool();
unsigned ByteLength = D.ReadInt();
- StringLiteral* sl = new StringLiteral(NULL,0,isWide,t,firstTokLoc,lastTokLoc);
+ StringLiteral* sl = new (C, llvm::alignof<StringLiteral>())
+ StringLiteral(C, NULL, 0, isWide, t, firstTokLoc, lastTokLoc);
- char* StrData = new char[ByteLength];
+ char* StrData = new (C, llvm::alignof<char>()) char[ByteLength];
for (unsigned i = 0; i < ByteLength; ++i)
StrData[i] = (char) D.ReadInt();