[cfe-commits] r136946 - in /cfe/trunk: lib/Rewrite/RewriteObjC.cpp test/Rewriter/rewrite-cast-to-bool.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Aug 4 16:58:03 PDT 2011
Author: fjahanian
Date: Thu Aug 4 18:58:03 2011
New Revision: 136946
URL: http://llvm.org/viewvc/llvm-project?rev=136946&view=rev
Log:
objc rewriter: Fixes a rewriting of implicit casting of an integral
argument to bool. // rdar://9899834
Added:
cfe/trunk/test/Rewriter/rewrite-cast-to-bool.mm
Modified:
cfe/trunk/lib/Rewrite/RewriteObjC.cpp
Modified: cfe/trunk/lib/Rewrite/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteObjC.cpp?rev=136946&r1=136945&r2=136946&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteObjC.cpp Thu Aug 4 18:58:03 2011
@@ -3008,7 +3008,11 @@
type = Context->getObjCIdType();
// Make sure we convert "type (^)(...)" to "type (*)(...)".
(void)convertBlockPointerToFunctionPointer(type);
- userExpr = NoTypeInfoCStyleCastExpr(Context, type, CK_BitCast,
+ const Expr *SubExpr = ICE->IgnoreParenImpCasts();
+ bool integral = SubExpr->getType()->isIntegralType(*Context);
+ userExpr = NoTypeInfoCStyleCastExpr(Context, type,
+ (integral && type->isBooleanType())
+ ? CK_IntegralToBoolean : CK_BitCast,
userExpr);
}
// Make id<P...> cast into an 'id' cast.
Added: cfe/trunk/test/Rewriter/rewrite-cast-to-bool.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-cast-to-bool.mm?rev=136946&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-cast-to-bool.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-cast-to-bool.mm Thu Aug 4 18:58:03 2011
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 9899834
+
+void *sel_registerName(const char *);
+
+ at interface NSURLDownload
+-(void)setBool:(bool)Arg;
+ at end
+
+ at implementation NSURLDownload
+- (void) Meth
+{
+ [self setBool:(signed char)1];
+}
+ at end
+
More information about the cfe-commits
mailing list