[cfe-commits] r76979 - in /cfe/trunk: include/clang/AST/ExprObjC.h include/clang/AST/StmtNodes.def include/clang/AST/Type.h include/clang/Frontend/PCHBitCodes.h lib/AST/Expr.cpp lib/AST/StmtPrinter.cpp lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaObjC/id-isa-ref.m

Chris Lattner clattner at apple.com
Tue Jul 28 16:26:28 PDT 2009


On Jul 24, 2009, at 10:54 AM, Steve Naroff wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=76979&view=rev
> Log:
> Allow front-end 'isa' access on object's of type 'id'.
> Enhance test case to cover 'isa' access on interface types (clang  
> produces an error, GCC produces a warning).
>
> Still need back-end CodeGen for ObjCIsaExpr.

Nice.

> +++ cfe/trunk/include/clang/AST/ExprObjC.h Fri Jul 24 12:54:45 2009
> @@ -496,6 +496,51 @@
>   virtual child_iterator child_end();
> };
>
> +/// ObjCIsaExpr - Represent X->isa and X.isa (similiar in spirit to  
> MemberExpr).
> +class ObjCIsaExpr : public Expr {

Please say "when X is an objective-c id type" explicitly.

> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul 24 12:54:45 2009
> @@ -2340,7 +2339,11 @@
>                          << IDecl->getDeclName() << &Member
>                          << BaseExpr->getSourceRange());
>     }
> -    // We don't have an interface. FIXME: deal with ObjC builtin  
> 'id' type.
> +    // We have an 'id' type. Rather than fall through, we check if  
> this
> +    // is a reference to 'isa'.
> +    if (&Member == &Context.Idents.get("isa"))

I think that "if (Member.isStr("isa"))" will work and be faster.

> +  // Handle the following exceptional case (*Obj).isa.
> +  if (OpKind == tok::period &&
> +      BaseType->isSpecificBuiltinType(BuiltinType::ObjCId) &&
> +      &Member == &Context.Idents.get("isa"))

likewise.

-Chris



More information about the cfe-commits mailing list