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

Chris Lattner sabre at nondot.org
Tue Oct 21 20:52:06 PDT 2008


Author: lattner
Date: Tue Oct 21 22:52:06 2008
New Revision: 57949

URL: http://llvm.org/viewvc/llvm-project?rev=57949&view=rev
Log:
some minor cleanups to ParseObjCTypeName:

1. Remove a bogus assertion, clients other than sema can return a
   null pointer from actions that result in ParseTypeName returning null.
2. Remove dead RParenLoc variable.
3. Simplify control flow handling error conditions.
4. On a major failure, we should skip until ')' not until '}'.


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=57949&r1=57948&r2=57949&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Oct 21 22:52:06 2008
@@ -611,32 +611,27 @@
 Parser::TypeTy *Parser::ParseObjCTypeName(ObjCDeclSpec &DS) {
   assert(Tok.is(tok::l_paren) && "expected (");
   
-  SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
+  SourceLocation LParenLoc = ConsumeParen();
   SourceLocation TypeStartLoc = Tok.getLocation();
-  TypeTy *Ty = 0;
   
   // Parse type qualifiers, in, inout, etc.
   ParseObjCTypeQualifierList(DS);
 
-  if (isTypeSpecifierQualifier()) {
+  TypeTy *Ty = 0;
+  if (isTypeSpecifierQualifier())
     Ty = ParseTypeName();
-    // FIXME: back when Sema support is in place...
-    // assert(Ty && "Parser::ParseObjCTypeName(): missing type");
-  }
   
-  if (Tok.isNot(tok::r_paren)) {
+  if (Tok.is(tok::r_paren))
+    ConsumeParen();
+  else if (Tok.getLocation() == TypeStartLoc) {
     // If we didn't eat any tokens, then this isn't a type.
-    if (Tok.getLocation() == TypeStartLoc) {
-      Diag(Tok.getLocation(), diag::err_expected_type);
-      SkipUntil(tok::r_brace);
-    } else {
-      // Otherwise, we found *something*, but didn't get a ')' in the right
-      // place.  Emit an error then return what we have as the type.
-      MatchRHSPunctuation(tok::r_paren, LParenLoc);
-    }
+    Diag(Tok.getLocation(), diag::err_expected_type);
+    SkipUntil(tok::r_paren);
+  } else {
+    // Otherwise, we found *something*, but didn't get a ')' in the right
+    // place.  Emit an error then return what we have as the type.
+    MatchRHSPunctuation(tok::r_paren, LParenLoc);
   }
-  if (Tok.is(tok::r_paren))
-    RParenLoc = ConsumeParen();
   return Ty;
 }
 





More information about the cfe-commits mailing list