summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-09-17 17:51:48 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-09-17 17:51:48 +0000
commitff0c460863cf967f444f44e67fbd5cfc934d7761 (patch)
tree72e9d3ea0ee9d170e3b1a9131b4a1a4c64c3b5c8 /clang
parent74a23ea4942e832a0b9671ab2e4a3d3835c3fee2 (diff)
downloadbcm5719-llvm-ff0c460863cf967f444f44e67fbd5cfc934d7761.tar.gz
bcm5719-llvm-ff0c460863cf967f444f44e67fbd5cfc934d7761.zip
ObjectiveC modern translator: Provide proper cast of
the ObjectiveC object of an @synchronized statement. // rdar://14993814 llvm-svn: 190874
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp2
-rw-r--r--clang/test/Rewriter/rewrite-modern-synchronized.m15
2 files changed, 14 insertions, 3 deletions
diff --git a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
index 697d1009fa8..ecd509610a7 100644
--- a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
+++ b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
@@ -1904,7 +1904,7 @@ Stmt *RewriteModernObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S)
std::string buf;
SourceLocation SynchLoc = S->getAtSynchronizedLoc();
ConvertSourceLocationToLineDirective(SynchLoc, buf);
- buf += "{ id _rethrow = 0; id _sync_obj = ";
+ buf += "{ id _rethrow = 0; id _sync_obj = (id)";
const char *lparenBuf = startBuf;
while (*lparenBuf != '(') lparenBuf++;
diff --git a/clang/test/Rewriter/rewrite-modern-synchronized.m b/clang/test/Rewriter/rewrite-modern-synchronized.m
index e8953393038..17c8e9a4ad4 100644
--- a/clang/test/Rewriter/rewrite-modern-synchronized.m
+++ b/clang/test/Rewriter/rewrite-modern-synchronized.m
@@ -1,7 +1,6 @@
// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"Class=struct objc_class *" -D"__declspec(X)=" %t-rw.cpp
-typedef struct objc_class *Class;
typedef struct objc_object {
Class isa;
} *id;
@@ -33,3 +32,15 @@ void test_sync_with_implicit_finally() {
return; // The rewriter knows how to generate code for implicit finally
}
}
+
+// rdar://14993814
+@interface NSObject @end
+
+@interface I : NSObject @end
+
+@implementation I
++ (void) Meth {
+@synchronized(self) {
+}
+}
+@end
OpenPOWER on IntegriCloud