mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-01 12:43:47 +00:00
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:
parent
5f4618923c
commit
a0c32e9310
@ -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(
|
||||
|
@ -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" }
|
4
clang/test/Modules/Inputs/attr-unavailable/oneA.h
Normal file
4
clang/test/Modules/Inputs/attr-unavailable/oneA.h
Normal file
@ -0,0 +1,4 @@
|
||||
@interface C
|
||||
-(void)method2 __attribute__((unavailable));
|
||||
-(void)method3 __attribute__((unavailable));
|
||||
@end
|
5
clang/test/Modules/Inputs/attr-unavailable/oneB.h
Normal file
5
clang/test/Modules/Inputs/attr-unavailable/oneB.h
Normal file
@ -0,0 +1,5 @@
|
||||
@import oneA;
|
||||
|
||||
@interface D
|
||||
-(void)method2;
|
||||
@end
|
3
clang/test/Modules/Inputs/attr-unavailable/oneC.h
Normal file
3
clang/test/Modules/Inputs/attr-unavailable/oneC.h
Normal file
@ -0,0 +1,3 @@
|
||||
@interface E
|
||||
-(void)method3;
|
||||
@end
|
6
clang/test/Modules/Inputs/attr-unavailable/two.h
Normal file
6
clang/test/Modules/Inputs/attr-unavailable/two.h
Normal file
@ -0,0 +1,6 @@
|
||||
@interface A
|
||||
-(void)method1;
|
||||
@end
|
||||
@interface B
|
||||
-(void)method1 __attribute__((unavailable));
|
||||
@end
|
25
clang/test/Modules/attr-unavailable.m
Normal file
25
clang/test/Modules/attr-unavailable.m
Normal 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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user