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.

llvm-svn: 225659
This commit is contained in:
Ben Langmuir 2015-01-12 19:27:00 +00:00
parent 5f4618923c
commit a0c32e9310
7 changed files with 54 additions and 3 deletions

View File

@ -7161,13 +7161,17 @@ void ASTReader::ReadMethodPool(Selector Sel) {
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(

View File

@ -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" }

View File

@ -0,0 +1,4 @@
@interface C
-(void)method2 __attribute__((unavailable));
-(void)method3 __attribute__((unavailable));
@end

View File

@ -0,0 +1,5 @@
@import oneA;
@interface D
-(void)method2;
@end

View File

@ -0,0 +1,3 @@
@interface E
-(void)method3;
@end

View File

@ -0,0 +1,6 @@
@interface A
-(void)method1;
@end
@interface B
-(void)method1 __attribute__((unavailable));
@end

View File

@ -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
@import two;
void f(id x) {
[x method1];
}
@import oneA;
void g(id x) {
[x method2]; // expected-error{{'method2' is unavailable}}
// expected-note@oneA.h:2 {{'method2' has been explicitly marked unavailable here}}
[x method3]; // expected-error{{'method3' is unavailable}}
// expected-note@oneA.h:3 {{'method3' has been explicitly marked unavailable here}}
}
@import oneB;
void h(id x) {
[x method2]; // could be from interface D in module oneB
}
@import oneC;
void i(id x) {
[x method3]; // could be from interface E in module oncC
}