[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata
Nathan Lanza via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 17:22:49 PDT 2020
lanza added inline comments.
================
Comment at: clang/lib/CodeGen/CGObjC.cpp:466
+ for (; begin != end; ++begin)
+ AppendFirstRuntimeProtocols(*begin, PDs);
+
----------------
rjmccall wrote:
> Should this make an effort to avoid declaring redundant bases? e.g.
>
> ```
> @protocol Base @end
> @protocol NonRuntime<Base> @end
> @protocol Runtime<Base> @end
> @interface MyClass <Runtime, NonRuntime> @end
> @implementation MyClass @end
> ```
>
> Ideally `MyClass` only declares conformance to `Runtime` rather than redundantly declaring conformance to `Base`, which I think you'd naturally get from this algorithm.
You are right. I fixed this but excluded the case where the declaration explicitly lists in it's `<>` declaration that it does inherit from a protocol. e.g. In the test case:
```
@protocol C @endp
@protocol B <C> @end
@protocol A <B> @end
__attribute__((objc_non_runtime_protocol)) @protocol Alpha<A> @end
__attribute__((objc_non_runtime_protocol)) @protocol Beta<B> @end
@interface Implementer : Root <Alpha, Beta, C> @end
@implementation Implementer @end
```
The non-runtime removing algorithm generates `A,B,C` as the list but B and C are both redundant. It makes sense to remove `B` for that reason but since the declaration explicitly mentions `C` I vote that it makes sense to leave it included as that's what one would expect from a `class_copyProtocolList`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75574/new/
https://reviews.llvm.org/D75574
More information about the cfe-commits
mailing list