diff options
author | Hugo Melder <service@hugomelder.com> | 2025-07-15 14:42:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-15 13:42:42 +0100 |
commit | 0b784269f16f0555d33e259f0b194ad4ad1a8e94 (patch) | |
tree | fbfb5fad438497b83c01e83b07c68f3c58b78304 /clang/lib/CodeGen | |
parent | acffe8324b6213db3bf39e8ef72545ffc0ef9ceb (diff) | |
download | llvm-0b784269f16f0555d33e259f0b194ad4ad1a8e94.zip llvm-0b784269f16f0555d33e259f0b194ad4ad1a8e94.tar.gz llvm-0b784269f16f0555d33e259f0b194ad4ad1a8e94.tar.bz2 |
[CodeGen][ObjC] Include all referenced protocols in protocol list (#148827)
When constructing the protocol list in the class metadata generation
(`GenerateClass`), only the protocols from the base class are added but
not protocols declared in class extensions.
This is fixed by using `all_referenced_protocol_{begin, end}` instead of
`protocol_{begin, end}`, matching the behaviour on Apple platforms.
A unit test is included to check if all protocol metadata was emitted
and that no duplication occurs in the protocol list.
Fixes https://github.com/gnustep/libobjc2/issues/339
CC: @davidchisnall
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGObjCGNU.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index d828702..8acf8d2 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -1942,8 +1942,9 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { // struct objc_class *sibling_class classFields.addNullPointer(PtrTy); // struct objc_protocol_list *protocols; - auto RuntimeProtocols = GetRuntimeProtocolList(classDecl->protocol_begin(), - classDecl->protocol_end()); + auto RuntimeProtocols = + GetRuntimeProtocolList(classDecl->all_referenced_protocol_begin(), + classDecl->all_referenced_protocol_end()); SmallVector<llvm::Constant *, 16> Protocols; for (const auto *I : RuntimeProtocols) Protocols.push_back(GenerateProtocolRef(I)); |