[cfe-commits] r41583 - in /cfe/trunk: Parse/ParseObjc.cpp Parse/Parser.cpp include/clang/Parse/Parser.h
Chris Lattner
sabre at nondot.org
Wed Aug 29 15:54:08 PDT 2007
Author: lattner
Date: Wed Aug 29 17:54:08 2007
New Revision: 41583
URL: http://llvm.org/viewvc/llvm-project?rev=41583&view=rev
Log:
cleanup context-sensitive objc keyword recognition. Patch by Fariborz Jahanian.
Modified:
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/Parse/Parser.cpp
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=41583&r1=41582&r2=41583&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Wed Aug 29 17:54:08 2007
@@ -303,13 +303,11 @@
/// 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;
}
Modified: cfe/trunk/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/Parser.cpp?rev=41583&r1=41582&r2=41583&view=diff
==============================================================================
--- cfe/trunk/Parse/Parser.cpp (original)
+++ cfe/trunk/Parse/Parser.cpp Wed Aug 29 17:54:08 2007
@@ -247,6 +247,17 @@
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
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=41583&r1=41582&r2=41583&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Aug 29 17:54:08 2007
@@ -267,6 +267,12 @@
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();
More information about the cfe-commits
mailing list