With this commit, we now successfully parse "Cocoa.h"!

llvm-svn: 41303
This commit is contained in:
Steve Naroff 2007-08-22 23:18:22 +00:00
parent 0a6ec03884
commit 7e901fdf86
3 changed files with 28 additions and 6 deletions

View File

@ -356,8 +356,7 @@ void Parser::ParseSpecifierQualifierList(DeclSpec &DS) {
/// [GNU] '_Decimal128'
/// [GNU] typeof-specifier
/// [OBJC] class-name objc-protocol-refs[opt] [TODO]
/// [OBJC] typedef-name objc-protocol-refs [TODO]
/// [OBJC] objc-protocol-refs [TODO]
/// [OBJC] typedef-name objc-protocol-refs[opt] [TODO]
/// type-qualifier:
/// 'const'
/// 'volatile'
@ -384,7 +383,15 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) {
CurScope)) {
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typedef, Loc, PrevSpec,
TypeRep);
break;
if (isInvalid)
break;
else { // FIXME: restrict this to "id" and ObjC classnames.
DS.Range.setEnd(Tok.getLocation());
ConsumeToken(); // The identifier
if (Tok.getKind() == tok::less)
ParseObjCProtocolReferences();
continue;
}
}
}
// FALL THROUGH.

View File

@ -301,6 +301,20 @@ IdentifierInfo *Parser::ParseObjCSelector() {
return II;
}
/// objc-type-qualifier: one of
/// in out inout bycopy byref oneway
///
/// FIXME: remove the string compares...
bool Parser::isObjCTypeQualifier() {
if (Tok.getKind() == tok::identifier) {
const char *qual = Tok.getIdentifierInfo()->getName();
return (strcmp(qual, "in") == 0) || (strcmp(qual, "out") == 0) ||
(strcmp(qual, "inout") == 0) || (strcmp(qual, "oneway") == 0) ||
(strcmp(qual, "bycopy") == 0) || (strcmp(qual, "byref") == 0);
}
return false;
}
/// objc-type-name:
/// '(' objc-type-qualifiers[opt] type-name ')'
/// '(' objc-type-qualifiers[opt] ')'
@ -309,14 +323,14 @@ IdentifierInfo *Parser::ParseObjCSelector() {
/// objc-type-qualifier
/// objc-type-qualifiers objc-type-qualifier
///
/// objc-type-qualifier: one of
/// in out inout bycopy byref oneway
///
void Parser::ParseObjCTypeName() {
assert(Tok.getKind() == tok::l_paren && "expected (");
SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
while (isObjCTypeQualifier())
ConsumeToken();
if (isTypeSpecifierQualifier()) {
//TypeTy *Ty = ParseTypeName();
//assert(Ty && "Parser::ParseObjCTypeName(): missing type");

View File

@ -267,6 +267,7 @@ private:
DeclTy *ParseObjCAtAliasDeclaration();
IdentifierInfo *ParseObjCSelector();
bool isObjCTypeQualifier();
void ParseObjCTypeName();
void ParseObjCMethodRequirement();
void ParseObjCMethodPrototype();