[cfe-commits] r41303 - in /cfe/trunk: Parse/ParseDecl.cpp Parse/ParseObjc.cpp include/clang/Parse/Parser.h
Steve Naroff
snaroff at apple.com
Wed Aug 22 16:18:27 PDT 2007
Author: snaroff
Date: Wed Aug 22 18:18:22 2007
New Revision: 41303
URL: http://llvm.org/viewvc/llvm-project?rev=41303&view=rev
Log:
With this commit, we now successfully parse "Cocoa.h"!
Modified:
cfe/trunk/Parse/ParseDecl.cpp
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseDecl.cpp?rev=41303&r1=41302&r2=41303&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/Parse/ParseDecl.cpp Wed Aug 22 18:18:22 2007
@@ -356,8 +356,7 @@
/// [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 @@
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.
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=41303&r1=41302&r2=41303&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Wed Aug 22 18:18:22 2007
@@ -301,6 +301,20 @@
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 @@
/// 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");
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=41303&r1=41302&r2=41303&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Aug 22 18:18:22 2007
@@ -267,6 +267,7 @@
DeclTy *ParseObjCAtAliasDeclaration();
IdentifierInfo *ParseObjCSelector();
+ bool isObjCTypeQualifier();
void ParseObjCTypeName();
void ParseObjCMethodRequirement();
void ParseObjCMethodPrototype();
More information about the cfe-commits
mailing list