[cfe-commits] r41303 - in /cfe/trunk: Parse/ParseDecl.cpp Parse/ParseObjc.cpp include/clang/Parse/Parser.h
Chris Lattner
clattner at apple.com
Mon Aug 27 21:06:48 PDT 2007
+/// 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);
> + }
Ouch :)
Since identifier infos are uniqued, how about this approach:
Add (to Parser):
enum ObjCTypeQual {
objc_in, objc_out, objc_inout ... objc_NumQuals
};
IdentifierInfo *ObjcTypeQuals[objc_NumQuals];
When the parser starts up, if in ObjC mode, populate this:
ObjcTypeQuals[objc_in] = IdentTable.get("in");
Then isObjCTypeQualifier becomes a series of pointer compares:
> +bool Parser::isObjCTypeQualifier() {
> + if (Tok.getKind() == tok::identifier) {
> + const IdentifierInfo *II = Tok.getIdentifierInfo();
for (unsigned i = 0; i != objc_NumQuals; ++i)
if (II == ObjcTypeQuals[i]) return true;
}
return false;
}
I assume that these are "context sensitive keywords" that are not
otherwise treated as keywords. If they are real keywords, they
should be added to the keyword table.
-Chris
More information about the cfe-commits
mailing list