[Objective-C] Add objc_subclassing_restricted attribute
authorAlex Lorenz <arphaman@gmail.com>
Fri, 28 Oct 2016 10:25:10 +0000 (10:25 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 28 Oct 2016 10:25:10 +0000 (10:25 +0000)
commita8c44ba2c01e395ce478ae961ac9f8de1c37c149
tree293ab8805019b760ec4b104f1aba243347e90ef3
parent3315a6a662d20edef65355eb69102fd5baad5e78
[Objective-C] Add objc_subclassing_restricted attribute

This patch adds an objc_subclassing_restricted attribute into clang. This
attribute acts similarly to 'final' - Objective-C classes with this attribute
can't be subclassed. However, @interface declarations that have
objc_subclassing_restricted but don't have @implementation are allowed to
inherit other @interface declarations with objc_subclassing_restricted. This is
needed to describe the Swift class hierarchy in clang while making sure that
the Objective-C classes cannot subclass the Swift classes.

This attribute is already implemented in a fork of clang that's used for Swift
(https://github.com/apple/swift-clang) and this patch moves that code to the
upstream clang repository.

rdar://28937548

Differential Revision: https://reviews.llvm.org/D25993

llvm-svn: 285391
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/test/SemaObjC/subclassing-restricted-attr.m [new file with mode: 0644]