[cfe-commits] r71225 - in /cfe/branches/Apple/objective-rewrite/tools/clang: Driver/RewriteObjC.cpp test/Rewriter/finally.m
Steve Naroff
snaroff at apple.com
Fri May 8 09:24:41 PDT 2009
Author: snaroff
Date: Fri May 8 11:24:35 2009
New Revision: 71225
URL: http://llvm.org/viewvc/llvm-project?rev=71225&view=rev
Log:
Fix <rdar://problem/6849319> clang ObjC rewriter: No warning or error jumping out of @synchronized block.
Modified:
cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/finally.m
Modified: cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp?rev=71225&r1=71224&r2=71225&view=diff
==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp (original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp Fri May 8 11:24:35 2009
@@ -1518,10 +1518,14 @@
buf += "}";
ReplaceText(lastCurlyLoc, 1, buf.c_str(), buf.size());
+
+ WarnAboutReturnGotoContinueOrBreakStmts(S->getSynchBody());
+
return 0;
}
-void RewriteObjC::WarnAboutReturnGotoContinueOrBreakStmts(Stmt *S) {
+void RewriteObjC::WarnAboutReturnGotoContinueOrBreakStmts(Stmt *S)
+{
// Perform a bottom up traversal of all children.
for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
CI != E; ++CI)
@@ -1695,6 +1699,11 @@
buf += " if (_rethrow) objc_exception_throw(_rethrow);\n";
buf += "}";
ReplaceText(lastCurlyLoc, 1, buf.c_str(), buf.size());
+
+ // Now check for any return/continue/go statements within the @try.
+ // The implicit finally clause won't called if the @try contains any
+ // jump statements.
+ WarnAboutReturnGotoContinueOrBreakStmts(S->getTryBody());
}
// Now emit the final closing curly brace...
lastCurlyLoc = lastCurlyLoc.getFileLocWithOffset(1);
Modified: cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/finally.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/finally.m?rev=71225&r1=71224&r2=71225&view=diff
==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/finally.m (original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/finally.m Fri May 8 11:24:35 2009
@@ -24,3 +24,17 @@
return 0;
}
+void test_sync_with_implicit_finally() {
+ id foo;
+ @synchronized (foo) {
+ return; // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
+ }
+}
+
+void test2_try_with_implicit_finally() {
+ @try {
+ return; // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
+ } @catch (id e) {
+
+ }
+}
More information about the cfe-commits
mailing list