diff --git a/clang/Driver/RewriteTest.cpp b/clang/Driver/RewriteTest.cpp index ee2f8ef2f653..1ba0af5ae336 100644 --- a/clang/Driver/RewriteTest.cpp +++ b/clang/Driver/RewriteTest.cpp @@ -854,7 +854,7 @@ Stmt *RewriteTest::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S) { // Replace ')' in for '(' type elem in collection ')' with ';' SourceLocation endCollectionLoc = S->getCollection()->getLocEnd(); const char *endCollectionBuf = SM->getCharacterData(endCollectionLoc); - const char *lparenBuf = strchr(endCollectionBuf, ')'); + const char *lparenBuf = strchr(endCollectionBuf+1, ')'); SourceLocation lparenLoc = startLoc.getFileLocWithOffset(lparenBuf-startBuf); buf = ";\n\t"; diff --git a/clang/test/Sema/rewrite-foreach-1.m b/clang/test/Sema/rewrite-foreach-1.m index 71e3fbd582ec..5962f3332e79 100644 --- a/clang/test/Sema/rewrite-foreach-1.m +++ b/clang/test/Sema/rewrite-foreach-1.m @@ -24,6 +24,14 @@ int LOOP(); { LOOP(); } for (id el1 in self) LOOP(); + + for (el in (self)) + if (el) + LOOP(); + + for (el in ((self))) + if (el) + LOOP(); } @end