r225659 - Fix bogus 'method is unavailable' errors with modules
Ben Langmuir
blangmuir at apple.com
Mon Jan 12 11:27:00 PST 2015
Author: benlangmuir
Date: Mon Jan 12 13:27:00 2015
New Revision: 225659
URL: http://llvm.org/viewvc/llvm-project?rev=225659&view=rev
Log:
Fix bogus 'method is unavailable' errors with modules
This just tweaks the fix from r224892 (which handled PCHs) to work with
modules, where we will serialize each method individually and hence the
hasMoreThanOneDecl bit needs to be updated as we add the methods.
Added:
cfe/trunk/test/Modules/Inputs/attr-unavailable/
cfe/trunk/test/Modules/Inputs/attr-unavailable/module.modulemap
cfe/trunk/test/Modules/Inputs/attr-unavailable/oneA.h
cfe/trunk/test/Modules/Inputs/attr-unavailable/oneB.h
cfe/trunk/test/Modules/Inputs/attr-unavailable/oneC.h
cfe/trunk/test/Modules/Inputs/attr-unavailable/two.h
cfe/trunk/test/Modules/attr-unavailable.m
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=225659&r1=225658&r2=225659&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Jan 12 13:27:00 2015
@@ -7161,13 +7161,17 @@ void ASTReader::ReadMethodPool(Selector
Sema &S = *getSema();
Sema::GlobalMethodPool::iterator Pos
= S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
-
- addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
- addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
+
Pos->second.first.setBits(Visitor.getInstanceBits());
Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
Pos->second.second.setBits(Visitor.getFactoryBits());
Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl());
+
+ // Add methods to the global pool *after* setting hasMoreThanOneDecl, since
+ // when building a module we keep every method individually and may need to
+ // update hasMoreThanOneDecl as we add the methods.
+ addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
+ addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
}
void ASTReader::ReadKnownNamespaces(
Added: cfe/trunk/test/Modules/Inputs/attr-unavailable/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/attr-unavailable/module.modulemap?rev=225659&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/attr-unavailable/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/attr-unavailable/module.modulemap Mon Jan 12 13:27:00 2015
@@ -0,0 +1,4 @@
+module two { header "two.h" }
+module oneA { header "oneA.h" }
+module oneB { header "oneB.h" export oneA }
+module oneC { header "oneC.h" }
Added: cfe/trunk/test/Modules/Inputs/attr-unavailable/oneA.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/attr-unavailable/oneA.h?rev=225659&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/attr-unavailable/oneA.h (added)
+++ cfe/trunk/test/Modules/Inputs/attr-unavailable/oneA.h Mon Jan 12 13:27:00 2015
@@ -0,0 +1,4 @@
+ at interface C
+-(void)method2 __attribute__((unavailable));
+-(void)method3 __attribute__((unavailable));
+ at end
Added: cfe/trunk/test/Modules/Inputs/attr-unavailable/oneB.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/attr-unavailable/oneB.h?rev=225659&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/attr-unavailable/oneB.h (added)
+++ cfe/trunk/test/Modules/Inputs/attr-unavailable/oneB.h Mon Jan 12 13:27:00 2015
@@ -0,0 +1,5 @@
+ at import oneA;
+
+ at interface D
+-(void)method2;
+ at end
Added: cfe/trunk/test/Modules/Inputs/attr-unavailable/oneC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/attr-unavailable/oneC.h?rev=225659&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/attr-unavailable/oneC.h (added)
+++ cfe/trunk/test/Modules/Inputs/attr-unavailable/oneC.h Mon Jan 12 13:27:00 2015
@@ -0,0 +1,3 @@
+ at interface E
+-(void)method3;
+ at end
Added: cfe/trunk/test/Modules/Inputs/attr-unavailable/two.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/attr-unavailable/two.h?rev=225659&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/attr-unavailable/two.h (added)
+++ cfe/trunk/test/Modules/Inputs/attr-unavailable/two.h Mon Jan 12 13:27:00 2015
@@ -0,0 +1,6 @@
+ at interface A
+-(void)method1;
+ at end
+ at interface B
+-(void)method1 __attribute__((unavailable));
+ at end
Added: cfe/trunk/test/Modules/attr-unavailable.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/attr-unavailable.m?rev=225659&view=auto
==============================================================================
--- cfe/trunk/test/Modules/attr-unavailable.m (added)
+++ cfe/trunk/test/Modules/attr-unavailable.m Mon Jan 12 13:27:00 2015
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/attr-unavailable %s -fsyntax-only -verify
+
+ at import two;
+void f(id x) {
+ [x method1];
+}
+
+ at import oneA;
+void g(id x) {
+ [x method2]; // expected-error{{'method2' is unavailable}}
+ // expected-note at oneA.h:2 {{'method2' has been explicitly marked unavailable here}}
+ [x method3]; // expected-error{{'method3' is unavailable}}
+ // expected-note at oneA.h:3 {{'method3' has been explicitly marked unavailable here}}
+}
+
+ at import oneB;
+void h(id x) {
+ [x method2]; // could be from interface D in module oneB
+}
+
+ at import oneC;
+void i(id x) {
+ [x method3]; // could be from interface E in module oncC
+}
More information about the cfe-commits
mailing list