aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseObjc.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-22 03:52:06 +0000
committerChris Lattner <sabre@nondot.org>2008-10-22 03:52:06 +0000
commit4a76b292c9c3f60a257636e21d76b6ce1c12f8c4 (patch)
treeb1511e248926c0d845620fb2235d0b3b82a9c224 /lib/Parse/ParseObjc.cpp
parent11292b0ce02fc679cf52e021b3b820cf8198f930 (diff)
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 '}'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57949 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseObjc.cpp')
-rw-r--r--lib/Parse/ParseObjc.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 8487ea2338..f6d77cfb50 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -611,32 +611,27 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS) {
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;
}