[cfe-commits] r146815 - in /cfe/trunk: lib/Parse/ParseObjc.cpp lib/Parse/Parser.cpp test/Parser/method-def-in-class.m

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Dec 16 20:13:22 PST 2011


Author: akirtzidis
Date: Fri Dec 16 22:13:22 2011
New Revision: 146815

URL: http://llvm.org/viewvc/llvm-project?rev=146815&view=rev
Log:
In Parser::SkipUntil do not stop at '@' unconditionally.

Stopping at '@' was originally intended to avoid skipping an '@' at the @interface context
when doing parser recovery, but we should not stop at all '@' tokens because they may be part
of expressions (e.g. in @"string", @selector(), etc.), so in most cases we will want to skip them.

This commit caused 'test/Parser/method-def-in-class.m' to fail for the cases where we tried to
recover from unmatched angle bracket but IMO it is not a big deal to not have good recovery
from such broken code and the way we did recovery would not always work anyway (e.g. if there was '@'
in an expression).

The case that rdar://7029784 is about still passes.

Modified:
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Parse/Parser.cpp
    cfe/trunk/test/Parser/method-def-in-class.m

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=146815&r1=146814&r2=146815&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Dec 16 22:13:22 2011
@@ -366,8 +366,12 @@
       allMethods.push_back(methodPrototype);
       // Consume the ';' here, since ParseObjCMethodPrototype() is re-used for
       // method definitions.
-      ExpectAndConsume(tok::semi, diag::err_expected_semi_after_method_proto,
-                       "", tok::semi);
+      if (ExpectAndConsumeSemi(diag::err_expected_semi_after_method_proto)) {
+        // We didn't find a semi and we error'ed out. Skip until a ';' or '@'.
+        SkipUntil(tok::at, /*StopAtSemi=*/true, /*DontConsume=*/true);
+        if (Tok.is(tok::semi))
+          ConsumeToken();
+      }
       continue;
     }
     if (Tok.is(tok::l_paren)) {

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=146815&r1=146814&r2=146815&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Fri Dec 16 22:13:22 2011
@@ -284,9 +284,6 @@
       ConsumeStringToken();
       break;
         
-    case tok::at:
-      return false;
-      
     case tok::semi:
       if (StopAtSemi)
         return false;

Modified: cfe/trunk/test/Parser/method-def-in-class.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/method-def-in-class.m?rev=146815&r1=146814&r2=146815&view=diff
==============================================================================
--- cfe/trunk/test/Parser/method-def-in-class.m (original)
+++ cfe/trunk/test/Parser/method-def-in-class.m Fri Dec 16 22:13:22 2011
@@ -7,19 +7,8 @@
 }
 @end
 
- at interface B
--(id) f0 { // expected-error {{expected ';' after method prototype}}
-  assert(0);
- at end
-
 @interface C
 - (id) f0 { // expected-error {{expected ';' after method prototype}}
     assert(0);
 };
 @end
-
- at interface D
-- (id) f0 { // expected-error {{expected ';' after method prototype}}
-  assert(0);
- at property int P;
- at end





More information about the cfe-commits mailing list