[PATCH][ObjC] Cleanup ObjCInterfaceDecl lookup for ObjC literals
AlexDenisov
1101.debian at gmail.com
Thu Jul 23 13:43:14 PDT 2015
> 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.
It was my initial idea, but I’m stuck with default value in case
when ObjCLiteralKind doesn’t match any NSClassIdKindKind (e.g.: LK_Block or LK_None).
> 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.
Will do.
> On 23 Jul 2015, at 22:29, John McCall <rjmccall at apple.com> wrote:
>
>> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150723/885a8f67/attachment.sig>
More information about the cfe-commits
mailing list