From 3f76f2aa6e479bc6ec73aa449975804751da8109 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 9 Jan 2008 17:50:00 +0000 Subject: [PATCH] Fixed a bug whereby a parethesized collection expression was not being rewritten correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45776 91177308-0d34-0410-b5e6-96231b3b80d8 --- Driver/RewriteTest.cpp | 2 +- test/Sema/rewrite-foreach-1.m | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index ee2f8ef2f6..1ba0af5ae3 100644 --- a/Driver/RewriteTest.cpp +++ b/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/test/Sema/rewrite-foreach-1.m b/test/Sema/rewrite-foreach-1.m index 71e3fbd582..5962f3332e 100644 --- a/test/Sema/rewrite-foreach-1.m +++ b/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 -- 2.50.1