summaryrefslogtreecommitdiffstats
path: root/lib/Frontend/RewriteObjC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend/RewriteObjC.cpp')
-rw-r--r--lib/Frontend/RewriteObjC.cpp262
1 files changed, 133 insertions, 129 deletions
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index fc9401d..35d8dde 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -420,6 +420,14 @@ namespace {
}
}
};
+
+ // Helper function: create a CStyleCastExpr with trivial type source info.
+ CStyleCastExpr* NoTypeInfoCStyleCastExpr(ASTContext *Ctx, QualType Ty,
+ CastExpr::CastKind Kind, Expr *E) {
+ TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation());
+ return new (Ctx) CStyleCastExpr(Ty, Kind, E, TInfo,
+ SourceLocation(), SourceLocation());
+ }
}
void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
@@ -610,6 +618,7 @@ void RewriteObjC::Initialize(ASTContext &context) {
Preamble += "#undef __OBJC_RW_DLLIMPORT\n";
Preamble += "#undef __OBJC_RW_STATICIMPORT\n";
Preamble += "#define __attribute__(X)\n";
+ Preamble += "#define __weak\n";
}
else {
Preamble += "#define __block\n";
@@ -824,6 +833,10 @@ void RewriteObjC::RewriteForwardClassDecl(ObjCClassDecl *ClassDecl) {
}
void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
+ // When method is a synthesized one, such as a getter/setter there is
+ // nothing to rewrite.
+ if (Method->isSynthesized())
+ return;
SourceLocation LocStart = Method->getLocStart();
SourceLocation LocEnd = Method->getLocEnd();
@@ -837,10 +850,9 @@ void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
}
void RewriteObjC::RewriteProperty(ObjCPropertyDecl *prop) {
- SourceLocation Loc = prop->getLocation();
+ SourceLocation Loc = prop->getAtLoc();
ReplaceText(Loc, 0, "// ", 3);
-
// FIXME: handle properties that are declared across multiple lines.
}
@@ -1219,11 +1231,9 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
- CastExpr *castExpr = new (Context) CStyleCastExpr(castT,
- CastExpr::CK_Unknown,
- IV->getBase(),
- castT,SourceLocation(),
- SourceLocation());
+ CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
+ CastExpr::CK_Unknown,
+ IV->getBase());
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(),
IV->getBase()->getLocEnd(),
@@ -1267,11 +1277,9 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
- CastExpr *castExpr = new (Context) CStyleCastExpr(castT,
- CastExpr::CK_Unknown,
- IV->getBase(),
- castT, SourceLocation(),
- SourceLocation());
+ CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
+ CastExpr::CK_Unknown,
+ IV->getBase());
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(),
IV->getBase()->getLocEnd(), castExpr);
@@ -1584,12 +1592,9 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
std::string syncBuf;
syncBuf += " objc_sync_exit(";
- Expr *syncExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
- CastExpr::CK_Unknown,
- S->getSynchExpr(),
- Context->getObjCIdType(),
- SourceLocation(),
- SourceLocation());
+ Expr *syncExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
+ CastExpr::CK_Unknown,
+ S->getSynchExpr());
std::string syncExprBufS;
llvm::raw_string_ostream syncExprBuf(syncExprBufS);
syncExpr->printPretty(syncExprBuf, *Context, 0,
@@ -2332,11 +2337,8 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
Context->getPointerType(DRE->getType()),
SourceLocation());
// cast to NSConstantString *
- CastExpr *cast = new (Context) CStyleCastExpr(Exp->getType(),
- CastExpr::CK_Unknown,
- Unop, Exp->getType(),
- SourceLocation(),
- SourceLocation());
+ CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Exp->getType(),
+ CastExpr::CK_Unknown, Unop);
ReplaceStmt(Exp, cast);
// delete Exp; leak for now, see RewritePropertySetter() usage for more info.
return cast;
@@ -2465,13 +2467,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// set the receiver to self, the first argument to all methods.
InitExprs.push_back(
- new (Context) CStyleCastExpr(Context->getObjCIdType(),
- CastExpr::CK_Unknown,
+ NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
+ CastExpr::CK_Unknown,
new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
Context->getObjCIdType(),
- SourceLocation()),
- Context->getObjCIdType(),
- SourceLocation(), SourceLocation())); // set the 'receiver'.
+ SourceLocation()))
+ ); // set the 'receiver'.
llvm::SmallVector<Expr*, 8> ClsExprs;
QualType argType = Context->getPointerType(Context->CharTy);
@@ -2484,10 +2485,9 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
ClsExprs.size());
// To turn off a warning, type-cast to 'id'
InitExprs.push_back( // set 'super class', using objc_getClass().
- new (Context) CStyleCastExpr(Context->getObjCIdType(),
- CastExpr::CK_Unknown,
- Cls, Context->getObjCIdType(),
- SourceLocation(), SourceLocation()));
+ NoTypeInfoCStyleCastExpr(Context,
+ Context->getObjCIdType(),
+ CastExpr::CK_Unknown, Cls));
// struct objc_super
QualType superType = getSuperStructType();
Expr *SuperRep;
@@ -2509,17 +2509,18 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf,
Context->getPointerType(SuperRep->getType()),
SourceLocation());
- SuperRep = new (Context) CStyleCastExpr(Context->getPointerType(superType),
- CastExpr::CK_Unknown, SuperRep,
- Context->getPointerType(superType),
- SourceLocation(), SourceLocation());
+ SuperRep = NoTypeInfoCStyleCastExpr(Context,
+ Context->getPointerType(superType),
+ CastExpr::CK_Unknown, SuperRep);
} else {
// (struct objc_super) { <exprs from above> }
InitListExpr *ILE = new (Context) InitListExpr(SourceLocation(),
&InitExprs[0], InitExprs.size(),
SourceLocation());
- SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superType, ILE,
- false);
+ TypeSourceInfo *superTInfo
+ = Context->getTrivialTypeSourceInfo(superType);
+ SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo,
+ superType, ILE, false);
// struct objc_super *
SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf,
Context->getPointerType(SuperRep->getType()),
@@ -2551,13 +2552,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
llvm::SmallVector<Expr*, 4> InitExprs;
InitExprs.push_back(
- new (Context) CStyleCastExpr(Context->getObjCIdType(),
- CastExpr::CK_Unknown,
+ NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
+ CastExpr::CK_Unknown,
new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
Context->getObjCIdType(),
- SourceLocation()),
- Context->getObjCIdType(),
- SourceLocation(), SourceLocation())); // set the 'receiver'.
+ SourceLocation()))
+ ); // set the 'receiver'.
llvm::SmallVector<Expr*, 8> ClsExprs;
QualType argType = Context->getPointerType(Context->CharTy);
@@ -2571,9 +2571,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// To turn off a warning, type-cast to 'id'
InitExprs.push_back(
// set 'super class', using objc_getClass().
- new (Context) CStyleCastExpr(Context->getObjCIdType(),
- CastExpr::CK_Unknown,
- Cls, Context->getObjCIdType(), SourceLocation(), SourceLocation()));
+ NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
+ CastExpr::CK_Unknown, Cls));
// struct objc_super
QualType superType = getSuperStructType();
Expr *SuperRep;
@@ -2595,16 +2594,18 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf,
Context->getPointerType(SuperRep->getType()),
SourceLocation());
- SuperRep = new (Context) CStyleCastExpr(Context->getPointerType(superType),
- CastExpr::CK_Unknown,
- SuperRep, Context->getPointerType(superType),
- SourceLocation(), SourceLocation());
+ SuperRep = NoTypeInfoCStyleCastExpr(Context,
+ Context->getPointerType(superType),
+ CastExpr::CK_Unknown, SuperRep);
} else {
// (struct objc_super) { <exprs from above> }
InitListExpr *ILE = new (Context) InitListExpr(SourceLocation(),
&InitExprs[0], InitExprs.size(),
SourceLocation());
- SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superType, ILE, false);
+ TypeSourceInfo *superTInfo
+ = Context->getTrivialTypeSourceInfo(superType);
+ SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo,
+ superType, ILE, false);
}
MsgExprs.push_back(SuperRep);
} else {
@@ -2612,10 +2613,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// Foo<Proto> *.
while (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(recExpr))
recExpr = CE->getSubExpr();
- recExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
- CastExpr::CK_Unknown, recExpr,
- Context->getObjCIdType(),
- SourceLocation(), SourceLocation());
+ recExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
+ CastExpr::CK_Unknown, recExpr);
MsgExprs.push_back(recExpr);
}
}
@@ -2639,19 +2638,16 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
QualType type = ICE->getType()->isObjCQualifiedIdType()
? Context->getObjCIdType()
: ICE->getType();
- userExpr = new (Context) CStyleCastExpr(type, CastExpr::CK_Unknown,
- userExpr, type, SourceLocation(),
- SourceLocation());
+ userExpr = NoTypeInfoCStyleCastExpr(Context, type, CastExpr::CK_Unknown,
+ userExpr);
}
// Make id<P...> cast into an 'id' cast.
else if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(userExpr)) {
if (CE->getType()->isObjCQualifiedIdType()) {
while ((CE = dyn_cast<CStyleCastExpr>(userExpr)))
userExpr = CE->getSubExpr();
- userExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
- CastExpr::CK_Unknown,
- userExpr, Context->getObjCIdType(),
- SourceLocation(), SourceLocation());
+ userExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
+ CastExpr::CK_Unknown, userExpr);
}
}
MsgExprs.push_back(userExpr);
@@ -2701,10 +2697,9 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// If we don't do this cast, we get the following bizarre warning/note:
// xx.m:13: warning: function called through a non-compatible type
// xx.m:13: note: if this code is reached, the program will abort
- cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy),
- CastExpr::CK_Unknown, DRE,
- Context->getPointerType(Context->VoidTy),
- SourceLocation(), SourceLocation());
+ cast = NoTypeInfoCStyleCastExpr(Context,
+ Context->getPointerType(Context->VoidTy),
+ CastExpr::CK_Unknown, DRE);
// Now do the "normal" pointer to function cast.
QualType castType = Context->getFunctionType(returnType,
@@ -2712,9 +2707,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// If we don't have a method decl, force a variadic cast.
Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true, 0);
castType = Context->getPointerType(castType);
- cast = new (Context) CStyleCastExpr(castType, CastExpr::CK_Unknown, cast,
- castType, SourceLocation(),
- SourceLocation());
+ cast = NoTypeInfoCStyleCastExpr(Context, castType, CastExpr::CK_Unknown,
+ cast);
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
@@ -2734,17 +2728,16 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor, msgSendType,
SourceLocation());
// Need to cast objc_msgSend_stret to "void *" (see above comment).
- cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy),
- CastExpr::CK_Unknown, STDRE,
- Context->getPointerType(Context->VoidTy),
- SourceLocation(), SourceLocation());
+ cast = NoTypeInfoCStyleCastExpr(Context,
+ Context->getPointerType(Context->VoidTy),
+ CastExpr::CK_Unknown, STDRE);
// Now do the "normal" pointer to function cast.
castType = Context->getFunctionType(returnType,
&ArgTypes[0], ArgTypes.size(),
Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false, 0);
castType = Context->getPointerType(castType);
- cast = new (Context) CStyleCastExpr(castType, CastExpr::CK_Unknown,
- cast, castType, SourceLocation(), SourceLocation());
+ cast = NoTypeInfoCStyleCastExpr(Context, castType, CastExpr::CK_Unknown,
+ cast);
// Don't forget the parens to enforce the proper binding.
PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
@@ -2819,10 +2812,9 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
Expr *DerefExpr = new (Context) UnaryOperator(DRE, UnaryOperator::AddrOf,
Context->getPointerType(DRE->getType()),
SourceLocation());
- CastExpr *castExpr = new (Context) CStyleCastExpr(DerefExpr->getType(),
- CastExpr::CK_Unknown,
- DerefExpr, DerefExpr->getType(),
- SourceLocation(), SourceLocation());
+ CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, DerefExpr->getType(),
+ CastExpr::CK_Unknown,
+ DerefExpr);
ReplaceStmt(Exp, castExpr);
ProtocolExprDecls.insert(Exp->getProtocol());
// delete Exp; leak for now, see RewritePropertySetter() usage for more info.
@@ -4043,7 +4035,7 @@ std::string RewriteObjC::SynthesizeBlockDescriptor(std::string DescTag,
void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
const char *FunName) {
// Insert declaration for the function in which block literal is used.
- if (CurFunctionDeclToDeclareForBlock)
+ if (CurFunctionDeclToDeclareForBlock && !Blocks.empty())
RewriteBlockLiteralFunctionDecl(CurFunctionDeclToDeclareForBlock);
// Insert closures that were part of the function.
for (unsigned i = 0; i < Blocks.size(); i++) {
@@ -4204,11 +4196,9 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
PtrToFuncCastType = Context->getPointerType(PtrToFuncCastType);
- CastExpr *BlkCast = new (Context) CStyleCastExpr(PtrBlock,
- CastExpr::CK_Unknown,
- const_cast<Expr*>(BlockExp),
- PtrBlock, SourceLocation(),
- SourceLocation());
+ CastExpr *BlkCast = NoTypeInfoCStyleCastExpr(Context, PtrBlock,
+ CastExpr::CK_Unknown,
+ const_cast<Expr*>(BlockExp));
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
BlkCast);
@@ -4220,11 +4210,8 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType());
- CastExpr *FunkCast = new (Context) CStyleCastExpr(PtrToFuncCastType,
- CastExpr::CK_Unknown, ME,
- PtrToFuncCastType,
- SourceLocation(),
- SourceLocation());
+ CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType,
+ CastExpr::CK_Unknown, ME);
PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), FunkCast);
llvm::SmallVector<Expr*, 8> BlkExprs;
@@ -4309,17 +4296,29 @@ void RewriteObjC::RewriteCastExpr(CStyleCastExpr *CE) {
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
-
+ QualType QT = CE->getType();
+ const Type* TypePtr = QT->getAs<Type>();
+ if (isa<TypeOfExprType>(TypePtr)) {
+ const TypeOfExprType *TypeOfExprTypePtr = cast<TypeOfExprType>(TypePtr);
+ QT = TypeOfExprTypePtr->getUnderlyingExpr()->getType();
+ std::string TypeAsString = "(";
+ TypeAsString += QT.getAsString();
+ TypeAsString += ")";
+ ReplaceText(LocStart, endBuf-startBuf+1,
+ TypeAsString.c_str(), TypeAsString.size());
+ return;
+ }
+
// advance the location to startArgList.
const char *argPtr = startBuf;
while (*argPtr++ && (argPtr < endBuf)) {
switch (*argPtr) {
- case '^':
- // Replace the '^' with '*'.
- LocStart = LocStart.getFileLocWithOffset(argPtr-startBuf);
- ReplaceText(LocStart, 1, "*", 1);
- break;
+ case '^':
+ // Replace the '^' with '*'.
+ LocStart = LocStart.getFileLocWithOffset(argPtr-startBuf);
+ ReplaceText(LocStart, 1, "*", 1);
+ break;
}
}
return;
@@ -4344,17 +4343,17 @@ void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
while (*argPtr++ && parenCount) {
switch (*argPtr) {
- case '^':
- // Replace the '^' with '*'.
- DeclLoc = DeclLoc.getFileLocWithOffset(argPtr-startArgList);
- ReplaceText(DeclLoc, 1, "*", 1);
- break;
- case '(':
- parenCount++;
- break;
- case ')':
- parenCount--;
- break;
+ case '^':
+ // Replace the '^' with '*'.
+ DeclLoc = DeclLoc.getFileLocWithOffset(argPtr-startArgList);
+ ReplaceText(DeclLoc, 1, "*", 1);
+ break;
+ case '(':
+ parenCount++;
+ break;
+ case ')':
+ parenCount--;
+ break;
}
}
return;
@@ -4390,9 +4389,9 @@ void RewriteObjC::GetExtentOfArgList(const char *Name, const char *&LParen,
while (*argPtr && parenCount) {
switch (*argPtr) {
- case '(': parenCount++; break;
- case ')': parenCount--; break;
- default: break;
+ case '(': parenCount++; break;
+ case ')': parenCount--; break;
+ default: break;
}
if (parenCount) argPtr++;
}
@@ -4557,8 +4556,13 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
ByrefType += " " + Name + ";\n";
ByrefType += "};\n";
// Insert this type in global scope. It is needed by helper function.
- assert(CurFunctionDef && "RewriteByRefVar - CurFunctionDef is null");
- SourceLocation FunLocStart = CurFunctionDef->getTypeSpecStartLoc();
+ SourceLocation FunLocStart;
+ if (CurFunctionDef)
+ FunLocStart = CurFunctionDef->getTypeSpecStartLoc();
+ else {
+ assert(CurMethodDef && "RewriteByRefVar - CurMethodDef is null");
+ FunLocStart = CurMethodDef->getLocStart();
+ }
InsertText(FunLocStart, ByrefType.c_str(), ByrefType.size());
if (Ty.isObjCGCWeak()) {
flag |= BLOCK_FIELD_IS_WEAK;
@@ -4608,12 +4612,17 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
ByrefType.c_str(), ByrefType.size());
}
else {
- SourceLocation startLoc = ND->getInit()->getLocStart();
+ SourceLocation startLoc;
+ Expr *E = ND->getInit();
+ if (const CStyleCastExpr *ECE = dyn_cast<CStyleCastExpr>(E))
+ startLoc = ECE->getLParenLoc();
+ else
+ startLoc = E->getLocStart();
startLoc = SM->getInstantiationLoc(startLoc);
+ endBuf = SM->getCharacterData(startLoc);
+
ByrefType += " " + Name;
- ReplaceText(DeclLoc, endBuf-startBuf,
- ByrefType.c_str(), ByrefType.size());
- ByrefType = " = {(void*)";
+ ByrefType += " = {(void*)";
ByrefType += utostr(isa);
ByrefType += ", &" + Name + ", ";
ByrefType += utostr(flags);
@@ -4628,7 +4637,8 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
ByrefType += utostr(flag);
ByrefType += ", ";
}
- InsertText(startLoc, ByrefType.c_str(), ByrefType.size());
+ ReplaceText(DeclLoc, endBuf-startBuf,
+ ByrefType.c_str(), ByrefType.size());
// Complete the newly synthesized compound expression by inserting a right
// curly brace before the end of the declaration.
@@ -4719,10 +4729,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
FD = SynthBlockInitFunctionDecl(Func.c_str());
DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, FD->getType(),
SourceLocation());
- CastExpr *castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
- CastExpr::CK_Unknown, Arg,
- Context->VoidPtrTy, SourceLocation(),
- SourceLocation());
+ CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
+ CastExpr::CK_Unknown, Arg);
InitExprs.push_back(castExpr);
// Initialize the block descriptor.
@@ -4753,11 +4761,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
} else if (isTopLevelBlockPointerType((*I)->getType())) {
FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
- Exp = new (Context) CStyleCastExpr(Context->VoidPtrTy,
- CastExpr::CK_Unknown, Arg,
- Context->VoidPtrTy,
- SourceLocation(),
- SourceLocation());
+ Exp = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
+ CastExpr::CK_Unknown, Arg);
} else {
FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
Exp = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
@@ -4789,9 +4794,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
NewRep = new (Context) UnaryOperator(NewRep, UnaryOperator::AddrOf,
Context->getPointerType(NewRep->getType()),
SourceLocation());
- NewRep = new (Context) CStyleCastExpr(FType, CastExpr::CK_Unknown, NewRep,
- FType, SourceLocation(),
- SourceLocation());
+ NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CastExpr::CK_Unknown,
+ NewRep);
BlockDeclRefs.clear();
BlockByRefDecls.clear();
BlockByCopyDecls.clear();
OpenPOWER on IntegriCloud