r336031 - Add protocol redefinition to the current scope/context
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 29 17:49:27 PDT 2018
Author: bruno
Date: Fri Jun 29 17:49:27 2018
New Revision: 336031
URL: http://llvm.org/viewvc/llvm-project?rev=336031&view=rev
Log:
Add protocol redefinition to the current scope/context
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
Differential Revision: https://reviews.llvm.org/D47297
Added:
cfe/trunk/test/Modules/Inputs/protocol-redefinition/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
cfe/trunk/test/Modules/protocol-redefinition.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=336031&r1=336030&r2=336031&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jun 29 17:49:27 2018
@@ -1210,6 +1210,11 @@ Sema::ActOnStartProtocolInterface(Source
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) {
Added: cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h?rev=336031&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h (added)
+++ cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h Fri Jun 29 17:49:27 2018
@@ -0,0 +1,3 @@
+ at protocol Foo
+- (void)someMethodOnFoo;
+ at end
Added: cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap?rev=336031&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap Fri Jun 29 17:49:27 2018
@@ -0,0 +1,4 @@
+framework module Base {
+ header "Base.h"
+ export *
+}
\ No newline at end of file
Added: cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h?rev=336031&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h (added)
+++ cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h Fri Jun 29 17:49:27 2018
@@ -0,0 +1,6 @@
+#import <Base/Base.h>
+
+// REDECLARATION
+ at protocol Foo
+- (void)someMethodOnFoo;
+ at end
Added: cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap?rev=336031&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap Fri Jun 29 17:49:27 2018
@@ -0,0 +1,4 @@
+framework module Kit {
+ header "Kit.h"
+ export *
+}
\ No newline at end of file
Added: cfe/trunk/test/Modules/protocol-redefinition.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/protocol-redefinition.m?rev=336031&view=auto
==============================================================================
--- cfe/trunk/test/Modules/protocol-redefinition.m (added)
+++ cfe/trunk/test/Modules/protocol-redefinition.m Fri Jun 29 17:49:27 2018
@@ -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;
More information about the cfe-commits
mailing list