[PATCH] D49462: [ObjC] Error out when using forward-declared protocol in a @protocol expression
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 17 17:51:10 PDT 2018
arphaman created this revision.
arphaman added reviewers: rjmccall, ahatanak, erik.pilkington, jfb.
Herald added a subscriber: dexonsmith.
Clang emits invalid protocol metadata when a `@protocol` expression is used with a forward-declared protocol. The protocol metadata is missing protocol conformance list of the protocol since we don't have access to the definition of it in the compiled translation unit. The linker then might end up picking the invalid metadata when linking which will lead to incorrect runtime protocol conformance checks.
This patch makes sure that Clang fails to compile code that uses a `@protocol` expression with a forward-declared protocol. This ensures that Clang does not emit invalid protocol metadata. I added an extra assert in CodeGen to ensure that this kind of issue won't happen in other places.
Repository:
rC Clang
https://reviews.llvm.org/D49462
Files:
include/clang/Basic/DiagnosticSemaKinds.td
lib/CodeGen/CGObjCMac.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprObjC.cpp
test/CodeGenObjC/forward-declare-protocol-gnu.m
test/CodeGenObjC/forward-protocol-metadata-symbols.m
test/CodeGenObjC/hidden-visibility.m
test/CodeGenObjC/link-errors.m
test/CodeGenObjC/protocol-comdat.m
test/CodeGenObjC/protocols-lazy.m
test/CodeGenObjC/protocols.m
test/PCH/objc_exprs.h
test/Parser/objc-cxx-keyword-identifiers.mm
test/SemaObjC/protocol-expr-neg-1.m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49462.155993.patch
Type: text/x-patch
Size: 9276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180718/09fe4ceb/attachment.bin>
More information about the cfe-commits
mailing list