/// 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);
+ const IdentifierInfo *II = Tok.getIdentifierInfo();
+ for (unsigned i = 0; i < objc_NumQuals; ++i)
+ if (II == ObjcTypeQuals[i]) return true;
}
return false;
}
if (Tok.getKind() == tok::eof &&
!getLang().CPlusPlus) // Empty source file is an extension in C
Diag(Tok, diag::ext_empty_source_file);
+
+ // Initialization for Objective-C context sensitive keywords recognition.
+ // Referenced in Parser::isObjCTypeQualifier.
+ if (getLang().ObjC1) {
+ ObjcTypeQuals[objc_in] = &PP.getIdentifierTable().get("in");
+ ObjcTypeQuals[objc_out] = &PP.getIdentifierTable().get("out");
+ ObjcTypeQuals[objc_inout] = &PP.getIdentifierTable().get("inout");
+ ObjcTypeQuals[objc_oneway] = &PP.getIdentifierTable().get("oneway");
+ ObjcTypeQuals[objc_bycopy] = &PP.getIdentifierTable().get("bycopy");
+ ObjcTypeQuals[objc_byref] = &PP.getIdentifierTable().get("byref");
+ }
}
/// ParseTopLevelDecl - Parse one top-level declaration, return whatever the
DeclTy *ParseObjCAtAliasDeclaration();
IdentifierInfo *ParseObjCSelector();
+ // Definitions for Objective-c context sensitive keywords recognition.
+ enum ObjCTypeQual {
+ objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
+ objc_NumQuals
+ };
+ IdentifierInfo *ObjcTypeQuals[objc_NumQuals];
bool isObjCTypeQualifier();
void ParseObjCTypeName();
void ParseObjCMethodRequirement();