[cfe-commits] r41303 - in /cfe/trunk: Parse/ParseDecl.cpp Parse/ParseObjc.cpp include/clang/Parse/Parser.h

Steve Naroff snaroff at apple.com
Mon Aug 27 21:16:28 PDT 2007


On Aug 27, 2007, at 9:06 PM, Chris Lattner wrote:

> +///   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 :)
>

Understood. This is temporary (hence the FIXME above).

The solution you outline below sounds fine with me...

> 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.
>

Yep...there is a FIXME for this....

   // FIXME: deal with "context sensitive" protocol qualifiers in  
prototypes

> -Chris
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20070827/6c2539b4/attachment.html>


More information about the cfe-commits mailing list