This is an archive of the discontinued LLVM Phabricator instance.

Support for attributes on @class declarations
Needs ReviewPublic

Authored by erik.pilkington on Aug 2 2019, 10:50 AM.

Details

Summary

This is useful to make availability checking work with forward declarations, but there also seem to be other attributes that make sense here.

rdar://43118198

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2019, 10:50 AM

I don't think I know enough about ObjC semantics to say much about the language design aspects of this patch.

clang/include/clang/Parse/Parser.h
1496

Slight preference for using ParsedAttributesWithRange instead when making new interfaces -- we often need the range when trying to prohibit attributes in places, or for other diagnostic purposes.

However, this may not be feasible depending on where you're getting the attributes from (some parts of the parser are still unfortunately deficient in this regard).

clang/lib/Parse/ParseObjc.cpp
124

Comment seems out of date now.

clang/test/CodeGenObjC/objc-asm-attribute-test.m
78

Can probably drop this spurious newline.

clang/test/SemaObjC/attr-forward-class.m
11–12

Do you have plans to fix this? If so, I'm fine with a FIXME for now, but I think the note is essentially a bug as it stands.

27

What is a "postfix attribute"? I would have assumed this was attempting to add a type attribute rather than a declaration attribute (based on the usual C and C++ semantics), so this diagnostic is a bit unhelpful.

Have you looked through the attributes that can be written on @interfaces and verified that they're all sensible to write on a @class? It's not hard to imagine that *some* of them should be diagnosed when added to a non-definition.