[PATCH][ObjC] Cleanup ObjCInterfaceDecl lookup for ObjC literals
John McCall
rjmccall at apple.com
Thu Jul 23 13:29:17 PDT 2015
> On Jul 23, 2015, at 8:33 AM, AlexDenisov <1101.debian at gmail.com> wrote:
>> Then, on the Sema side, you should define an enum that corresponds to
>> the different cases in that second parameter.
>
> I just reused ObjCLiteralKind, seems it fits for this task very well.
Sounds good.
>> If you do this, you should be able to unify all the different diagnostics for
>> NSNumber/NSArray/NSValue.
>
> Merged all specific errors into one err_undeclared_objc_literal_class, as you suggested.
>
> New version attached.
>
> <lookup_objc_literal_interface_decl.patch>
+static bool ValidateObjCLiteralInterfaceDecl(Sema &S, ObjCInterfaceDecl *Decl,
+ SourceLocation Loc,
+ NSAPI::NSClassIdKindKind ClassKind) {
I think it would make more sense to have this take an ObjCLiteralKind
and then map that to a NSAPI::NSClassIdKindKind than the other way
around.
+ ObjCInterfaceDecl *Decl = nullptr;
+ IdentifierInfo *II = S.NSAPIObj->getNSClassId(ClassKind);
+ NamedDecl *IF = S.LookupSingleName(S.TUScope, II, Loc,
+ Sema::LookupOrdinaryName);
+ Decl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
You should declare variables as close as possible to the point they’re initialized,
and you should try to avoid naming variables the same as a type.
So, specifically, please make this
ObjCInterfaceDecl *ID = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
Otherwise, this looks good, thanks!
John.
More information about the cfe-commits
mailing list