[PATCH] D47297: [Modules][ObjC] Add protocol redefinition to the current scope/context
Bruno Cardoso Lopes via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 23 15:45:45 PDT 2018
bruno created this revision.
bruno added a reviewer: rsmith.
Not doing so causes the AST writter to assert since the decl in question never gets emitted. This is fine when modules is not used, but otherwise we need to serialize something other than garbage.
rdar://problem/39844933
Repository:
rC Clang
https://reviews.llvm.org/D47297
Files:
lib/Sema/SemaDeclObjC.cpp
test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h
test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
test/Modules/protocol-redefinition.m
Index: test/Modules/protocol-redefinition.m
===================================================================
--- /dev/null
+++ test/Modules/protocol-redefinition.m
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F%S/Inputs/protocol-redefinition -fsyntax-only %s -Wno-private-module -verify
+
+// expected-no-diagnostics
+
+ at import Kit;
Index: test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
===================================================================
--- /dev/null
+++ test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module Kit {
+ header "Kit.h"
+ export *
+}
\ No newline at end of file
Index: test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h
@@ -0,0 +1,6 @@
+#import <Base/Base.h>
+
+// REDECLARATION
+ at protocol Foo
+- (void)someMethodOnFoo;
+ at end
Index: test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
===================================================================
--- /dev/null
+++ test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module Base {
+ header "Base.h"
+ export *
+}
\ No newline at end of file
Index: test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
@@ -0,0 +1,3 @@
+ at protocol Foo
+- (void)someMethodOnFoo;
+ at end
Index: lib/Sema/SemaDeclObjC.cpp
===================================================================
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -1202,6 +1202,11 @@
PDecl = ObjCProtocolDecl::Create(Context, CurContext, ProtocolName,
ProtocolLoc, AtProtoInterfaceLoc,
/*PrevDecl=*/nullptr);
+
+ // If we are using modules, add the decl to the context in order to
+ // serialize something meaningful.
+ if (getLangOpts().Modules)
+ PushOnScopeChains(PDecl, TUScope);
PDecl->startDefinition();
} else {
if (PrevDecl) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47297.148308.patch
Type: text/x-patch
Size: 2402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180523/a6af688a/attachment.bin>
More information about the cfe-commits
mailing list