Skip to content

Commit f608deb

Browse files
committed
Kill CK_Unknown references in the ObjC rewriter. The actual
choice of cast doesn't matter here, but I've tried to choose the right one anyway. llvm-svn: 119140
1 parent 3b70267 commit f608deb

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

clang/lib/Rewrite/RewriteObjC.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
14161416
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
14171417
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
14181418
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
1419-
CK_Unknown,
1419+
CK_BitCast,
14201420
IV->getBase());
14211421
// Don't forget the parens to enforce the proper binding.
14221422
ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(),
@@ -1461,7 +1461,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
14611461
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
14621462
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
14631463
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
1464-
CK_Unknown,
1464+
CK_BitCast,
14651465
IV->getBase());
14661466
// Don't forget the parens to enforce the proper binding.
14671467
ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(),
@@ -1797,7 +1797,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
17971797
std::string syncBuf;
17981798
syncBuf += " objc_sync_exit(";
17991799
Expr *syncExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
1800-
CK_Unknown,
1800+
CK_BitCast,
18011801
S->getSynchExpr());
18021802
std::string syncExprBufS;
18031803
llvm::raw_string_ostream syncExprBuf(syncExprBufS);
@@ -2140,7 +2140,7 @@ CallExpr *RewriteObjC::SynthesizeCallToFunctionDecl(
21402140
// Now, we cast the reference to a pointer to the objc_msgSend type.
21412141
QualType pToFunc = Context->getPointerType(msgSendType);
21422142
ImplicitCastExpr *ICE =
2143-
ImplicitCastExpr::Create(*Context, pToFunc, CK_Unknown,
2143+
ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay,
21442144
DRE, 0, VK_RValue);
21452145

21462146
const FunctionType *FT = msgSendType->getAs<FunctionType>();
@@ -2668,7 +2668,7 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
26682668
SourceLocation());
26692669
// cast to NSConstantString *
26702670
CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Exp->getType(),
2671-
CK_Unknown, Unop);
2671+
CK_BitCast, Unop);
26722672
ReplaceStmt(Exp, cast);
26732673
// delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info.
26742674
return cast;
@@ -2782,7 +2782,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
27822782
// set the receiver to self, the first argument to all methods.
27832783
InitExprs.push_back(
27842784
NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
2785-
CK_Unknown,
2785+
CK_BitCast,
27862786
new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
27872787
Context->getObjCIdType(),
27882788
SourceLocation()))
@@ -2803,7 +2803,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
28032803
// (Class)objc_getClass("CurrentClass")
28042804
CastExpr *ArgExpr = NoTypeInfoCStyleCastExpr(Context,
28052805
Context->getObjCClassType(),
2806-
CK_Unknown, Cls);
2806+
CK_BitCast, Cls);
28072807
ClsExprs.clear();
28082808
ClsExprs.push_back(ArgExpr);
28092809
Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl,
@@ -2815,7 +2815,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
28152815
InitExprs.push_back( // set 'super class', using class_getSuperclass().
28162816
NoTypeInfoCStyleCastExpr(Context,
28172817
Context->getObjCIdType(),
2818-
CK_Unknown, Cls));
2818+
CK_BitCast, Cls));
28192819
// struct objc_super
28202820
QualType superType = getSuperStructType();
28212821
Expr *SuperRep;
@@ -2839,7 +2839,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
28392839
SourceLocation());
28402840
SuperRep = NoTypeInfoCStyleCastExpr(Context,
28412841
Context->getPointerType(superType),
2842-
CK_Unknown, SuperRep);
2842+
CK_BitCast, SuperRep);
28432843
} else {
28442844
// (struct objc_super) { <exprs from above> }
28452845
InitListExpr *ILE =
@@ -2888,7 +2888,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
28882888

28892889
InitExprs.push_back(
28902890
NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
2891-
CK_Unknown,
2891+
CK_BitCast,
28922892
new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
28932893
Context->getObjCIdType(),
28942894
SourceLocation()))
@@ -2908,7 +2908,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
29082908
// (Class)objc_getClass("CurrentClass")
29092909
CastExpr *ArgExpr = NoTypeInfoCStyleCastExpr(Context,
29102910
Context->getObjCClassType(),
2911-
CK_Unknown, Cls);
2911+
CK_BitCast, Cls);
29122912
ClsExprs.clear();
29132913
ClsExprs.push_back(ArgExpr);
29142914
Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl,
@@ -2920,7 +2920,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
29202920
InitExprs.push_back(
29212921
// set 'super class', using class_getSuperclass().
29222922
NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
2923-
CK_Unknown, Cls));
2923+
CK_BitCast, Cls));
29242924
// struct objc_super
29252925
QualType superType = getSuperStructType();
29262926
Expr *SuperRep;
@@ -2944,7 +2944,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
29442944
SourceLocation());
29452945
SuperRep = NoTypeInfoCStyleCastExpr(Context,
29462946
Context->getPointerType(superType),
2947-
CK_Unknown, SuperRep);
2947+
CK_BitCast, SuperRep);
29482948
} else {
29492949
// (struct objc_super) { <exprs from above> }
29502950
InitListExpr *ILE =
@@ -2967,7 +2967,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
29672967
while (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(recExpr))
29682968
recExpr = CE->getSubExpr();
29692969
recExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
2970-
CK_Unknown, recExpr);
2970+
CK_BitCast, recExpr);
29712971
MsgExprs.push_back(recExpr);
29722972
break;
29732973
}
@@ -2997,7 +2997,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
29972997
: ICE->getType();
29982998
// Make sure we convert "type (^)(...)" to "type (*)(...)".
29992999
(void)convertBlockPointerToFunctionPointer(type);
3000-
userExpr = NoTypeInfoCStyleCastExpr(Context, type, CK_Unknown,
3000+
userExpr = NoTypeInfoCStyleCastExpr(Context, type, CK_BitCast,
30013001
userExpr);
30023002
}
30033003
// Make id<P...> cast into an 'id' cast.
@@ -3006,7 +3006,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
30063006
while ((CE = dyn_cast<CStyleCastExpr>(userExpr)))
30073007
userExpr = CE->getSubExpr();
30083008
userExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
3009-
CK_Unknown, userExpr);
3009+
CK_BitCast, userExpr);
30103010
}
30113011
}
30123012
MsgExprs.push_back(userExpr);
@@ -3056,7 +3056,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
30563056
// xx.m:13: note: if this code is reached, the program will abort
30573057
cast = NoTypeInfoCStyleCastExpr(Context,
30583058
Context->getPointerType(Context->VoidTy),
3059-
CK_Unknown, DRE);
3059+
CK_BitCast, DRE);
30603060

30613061
// Now do the "normal" pointer to function cast.
30623062
QualType castType = Context->getFunctionType(returnType,
@@ -3066,7 +3066,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
30663066
false, false, 0, 0,
30673067
FunctionType::ExtInfo());
30683068
castType = Context->getPointerType(castType);
3069-
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_Unknown,
3069+
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
30703070
cast);
30713071

30723072
// Don't forget the parens to enforce the proper binding.
@@ -3089,15 +3089,15 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
30893089
// Need to cast objc_msgSend_stret to "void *" (see above comment).
30903090
cast = NoTypeInfoCStyleCastExpr(Context,
30913091
Context->getPointerType(Context->VoidTy),
3092-
CK_Unknown, STDRE);
3092+
CK_BitCast, STDRE);
30933093
// Now do the "normal" pointer to function cast.
30943094
castType = Context->getFunctionType(returnType,
30953095
&ArgTypes[0], ArgTypes.size(),
30963096
Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false, 0,
30973097
false, false, 0, 0,
30983098
FunctionType::ExtInfo());
30993099
castType = Context->getPointerType(castType);
3100-
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_Unknown,
3100+
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
31013101
cast);
31023102

31033103
// Don't forget the parens to enforce the proper binding.
@@ -3179,7 +3179,7 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
31793179
Context->getPointerType(DRE->getType()),
31803180
SourceLocation());
31813181
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, DerefExpr->getType(),
3182-
CK_Unknown,
3182+
CK_BitCast,
31833183
DerefExpr);
31843184
ReplaceStmt(Exp, castExpr);
31853185
ProtocolExprDecls.insert(Exp->getProtocol());
@@ -4709,7 +4709,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
47094709
PtrToFuncCastType = Context->getPointerType(PtrToFuncCastType);
47104710

47114711
CastExpr *BlkCast = NoTypeInfoCStyleCastExpr(Context, PtrBlock,
4712-
CK_Unknown,
4712+
CK_BitCast,
47134713
const_cast<Expr*>(BlockExp));
47144714
// Don't forget the parens to enforce the proper binding.
47154715
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
@@ -4724,7 +4724,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
47244724

47254725

47264726
CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType,
4727-
CK_Unknown, ME);
4727+
CK_BitCast, ME);
47284728
PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), FunkCast);
47294729

47304730
llvm::SmallVector<Expr*, 8> BlkExprs;
@@ -5344,7 +5344,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
53445344
DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, FD->getType(),
53455345
SourceLocation());
53465346
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
5347-
CK_Unknown, Arg);
5347+
CK_BitCast, Arg);
53485348
InitExprs.push_back(castExpr);
53495349

53505350
// Initialize the block descriptor.
@@ -5382,7 +5382,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
53825382
FD = SynthBlockInitFunctionDecl((*I)->getName());
53835383
Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
53845384
Exp = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
5385-
CK_Unknown, Arg);
5385+
CK_BitCast, Arg);
53865386
} else {
53875387
FD = SynthBlockInitFunctionDecl((*I)->getName());
53885388
Exp = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
@@ -5415,7 +5415,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
54155415
Exp = new (Context) UnaryOperator(Exp, UO_AddrOf,
54165416
Context->getPointerType(Exp->getType()),
54175417
SourceLocation());
5418-
Exp = NoTypeInfoCStyleCastExpr(Context, castT, CK_Unknown, Exp);
5418+
Exp = NoTypeInfoCStyleCastExpr(Context, castT, CK_BitCast, Exp);
54195419
InitExprs.push_back(Exp);
54205420
}
54215421
}
@@ -5433,7 +5433,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
54335433
NewRep = new (Context) UnaryOperator(NewRep, UO_AddrOf,
54345434
Context->getPointerType(NewRep->getType()),
54355435
SourceLocation());
5436-
NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CK_Unknown,
5436+
NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CK_BitCast,
54375437
NewRep);
54385438
BlockDeclRefs.clear();
54395439
BlockByRefDecls.clear();

0 commit comments

Comments
 (0)