[cfe-commits] r57815 - /cfe/trunk/lib/Parse/ParseObjc.cpp

Chris Lattner sabre at nondot.org
Mon Oct 20 00:37:23 PDT 2008


Author: lattner
Date: Mon Oct 20 02:37:22 2008
New Revision: 57815

URL: http://llvm.org/viewvc/llvm-project?rev=57815&view=rev
Log:
more simplifications to error recovery in ParseObjCPropertyAttribute


Modified:
    cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=57815&r1=57814&r2=57815&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Oct 20 02:37:22 2008
@@ -390,20 +390,18 @@
       return;
     }
     
+    SourceLocation AttrName = ConsumeToken(); // consume last attribute name
+    
     // getter/setter require extra treatment.
     if (II == ObjCPropertyAttrs[objc_getter] || 
         II == ObjCPropertyAttrs[objc_setter]) {
-      // skip getter/setter part.
-      SourceLocation loc = ConsumeToken();
-      if (Tok.isNot(tok::equal)) {
-        Diag(loc, diag::err_objc_expected_equal);    
-        SkipUntil(tok::r_paren);
+      
+      if (ExpectAndConsume(tok::equal, diag::err_objc_expected_equal, "",
+                           tok::r_paren))
         return;
-      }
-
-      loc = ConsumeToken();
+      
       if (Tok.isNot(tok::identifier)) {
-        Diag(loc, diag::err_expected_ident);
+        Diag(Tok.getLocation(), diag::err_expected_ident);
         SkipUntil(tok::r_paren);
         return;
       }
@@ -411,15 +409,15 @@
       if (II == ObjCPropertyAttrs[objc_setter]) {
         DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_setter);
         DS.setSetterName(Tok.getIdentifierInfo());
-        loc = ConsumeToken();  // consume method name
-        if (Tok.isNot(tok::colon)) {
-          Diag(loc, diag::err_expected_colon);
-          SkipUntil(tok::r_paren);
+        ConsumeToken();  // consume method name
+        
+        if (ExpectAndConsume(tok::colon, diag::err_expected_colon, "",
+                             tok::r_paren))
           return;
-        }
       } else {
         DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_getter);
         DS.setGetterName(Tok.getIdentifierInfo());
+        ConsumeToken();  // consume method name
       }
     } else if (II == ObjCPropertyAttrs[objc_readonly])
       DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_readonly);
@@ -434,26 +432,18 @@
     else if (II == ObjCPropertyAttrs[objc_nonatomic])
       DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nonatomic);
     else {
-      Diag(Tok.getLocation(), diag::err_objc_expected_property_attr,
-           II->getName());
+      Diag(AttrName, diag::err_objc_expected_property_attr, II->getName());
       SkipUntil(tok::r_paren);
       return;
     }
     
-    ConsumeToken(); // consume last attribute token
-    if (Tok.is(tok::comma)) {
-      ConsumeToken();
-      continue;
-    }
-    
-    if (Tok.is(tok::r_paren)) {
-      ConsumeParen();
-      return;
-    }
+    if (Tok.isNot(tok::comma))
+      break;
     
-    MatchRHSPunctuation(tok::r_paren, LHSLoc);
-    return;
+    ConsumeToken();
   }
+  
+  MatchRHSPunctuation(tok::r_paren, LHSLoc);
 }
 
 ///   objc-method-proto:





More information about the cfe-commits mailing list