[cfe-commits] r43075 - in /cfe/trunk: AST/ASTContext.cpp AST/Expr.cpp AST/StmtDumper.cpp AST/StmtPrinter.cpp Parse/ParseObjc.cpp Sema/Sema.cpp Sema/Sema.h Sema/SemaExpr.cpp include/clang/AST/ASTContext.h include/clang/AST/Expr.h include/clang/AST/StmtNodes.def include/clang/Basic/DiagnosticKinds.def include/clang/Parse/Action.h test/Sema/protocol-expr-1.m test/Sema/protocol-expr-neg-1.m

Chris Lattner clattner at apple.com
Wed Oct 17 17:25:48 PDT 2007


On Oct 17, 2007, at 9:58 AM, Fariborz Jahanian wrote:

> Author: fjahanian
> Date: Wed Oct 17 11:58:11 2007
> New Revision: 43075
>
> URL: http://llvm.org/viewvc/llvm-project?rev=43075&view=rev
> Log:
> Implementation of AST for @protocol expression.

Nice Fariborz.

> ====================================================================== 
> ========
> --- cfe/trunk/Sema/Sema.cpp (original)
> +++ cfe/trunk/Sema/Sema.cpp Wed Oct 17 11:58:11 2007
> @@ -63,6 +63,24 @@
>    return Context.getObjcSelType();
>  }
>
> +/// GetObjcProtoType - See comments for Sema::GetObjcIdType above;  
> replace "id"
> +/// with "Protocol".
> +QualType Sema::GetObjcProtoType(SourceLocation Loc) {
> +  assert(TUScope && "GetObjcProtoType(): Top-level scope is null");
> +  if (Context.getObjcProtoType().isNull()) {
> +    IdentifierInfo *ProtoIdent = &Context.Idents.get("Protocol");
> +    ScopedDecl *ProtoDecl = LookupScopedDecl(ProtoIdent,  
> Decl::IDNS_Ordinary,
> +                                           SourceLocation(),  
> TUScope);
> +    TypedefDecl *ObjcProtoTypedef = dyn_cast_or_null<TypedefDecl> 
> (ProtoDecl);
> +    if (!ObjcProtoTypedef) {
> +      Diag(Loc, diag::err_missing_proto_definition);
> +      return QualType();

This can return a null QualType.

> +++ cfe/trunk/Sema/SemaExpr.cpp Wed Oct 17 11:58:11 2007
> @@ -1929,6 +1929,20 @@
>    return new ObjCSelectorExpr(t, Sel, AtLoc, RParenLoc);
>  }
>
> +Sema::ExprResult Sema::ParseObjCProtocolExpression(IdentifierInfo  
> *ProtocolId,
> +                                                   SourceLocation  
> AtLoc,
> +                                                   SourceLocation  
> ProtoLoc,
> +                                                   SourceLocation  
> LParenLoc,
> +                                                   SourceLocation  
> RParenLoc) {
> +  ObjcProtocolDecl* PDecl = ObjcProtocols[ProtocolId];
> +  if (!PDecl) {
> +    Diag(ProtoLoc, diag::err_undeclared_protocol, ProtocolId- 
> >getName());
> +    return true;
> +  }
> +
> +  QualType t = GetObjcProtoType(AtLoc);

That means you should check to see if t.isNull() here, and return  
true if so.

-Chris






More information about the cfe-commits mailing list