[all-commits] [llvm/llvm-project] 14f6bf: [clang] Implement objc_non_runtime_protocol to rem...

Nathan Lanza via All-commits all-commits at lists.llvm.org
Fri Oct 2 14:38:37 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 14f6bfcb52e77867a6a84fcfd9e21bb5f1f5795c
      https://github.com/llvm/llvm-project/commit/14f6bfcb52e77867a6a84fcfd9e21bb5f1f5795c
  Author: Nathan Lanza <nathan at lanza.io>
  Date:   2020-10-02 (Fri, 02 Oct 2020)

  Changed paths:
    M clang/include/clang/AST/DeclObjC.h
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/AST/DeclObjC.cpp
    M clang/lib/CodeGen/CGObjC.cpp
    M clang/lib/CodeGen/CGObjCGNU.cpp
    M clang/lib/CodeGen/CGObjCMac.cpp
    M clang/lib/CodeGen/CGObjCRuntime.h
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/lib/Sema/SemaExprObjC.cpp
    A clang/test/CodeGenObjC/non-runtime-protocol.m
    M clang/test/Misc/pragma-attribute-supported-attributes-list.test

  Log Message:
  -----------
  [clang] Implement objc_non_runtime_protocol to remove protocol metadata

Summary:
Motivated by the new objc_direct attribute, this change adds a new
attribute that remotes metadata from Protocols that the programmer knows
isn't going to be used at runtime. We simply have the frontend skip
generating any protocol metadata entries (e.g. OBJC_CLASS_NAME,
_OBJC_$_PROTOCOL_INSTANCE_METHDOS, _OBJC_PROTOCOL, etc) for a protocol
marked with `__attribute__((objc_non_runtime_protocol))`.

There are a few APIs used to retrieve a protocol at runtime.
`@protocol(SomeProtocol)` will now error out of the requested protocol
is marked with attribute. `objc_getProtocol` will return `NULL` which
is consistent with the behavior of a non-existing protocol.

Subscribers: cfe-commits

Tags: #clang

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




More information about the All-commits mailing list