summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-25 00:59:09 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-25 00:59:09 +0000
commit70f449bf416bb2cdd94b7aacd59fd6bb38374360 (patch)
treef14aa940208ac4678a1c0b1bdd97dcd5d7221e43
parent3b8dfa069b5aafe62abd8c761d47d22f78dc7642 (diff)
downloadbcm5719-llvm-70f449bf416bb2cdd94b7aacd59fd6bb38374360.tar.gz
bcm5719-llvm-70f449bf416bb2cdd94b7aacd59fd6bb38374360.zip
Whenever Sema attempts to look in the global method pool, try to load
additional data from the external Sema source. This properly copes with modules that are imported after we have already searched in the global method pool for a given selector. For PCH, it's a slight pessimization to be fixed soon. llvm-svn: 148891
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp32
-rw-r--r--clang/test/Modules/Inputs/MethodPoolA.h8
-rw-r--r--clang/test/Modules/Inputs/MethodPoolB.h13
-rw-r--r--clang/test/Modules/Inputs/module.map6
-rw-r--r--clang/test/Modules/method_pool.m30
5 files changed, 68 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 432e3ddf547..4394dbf9be1 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1983,17 +1983,13 @@ void Sema::ReadMethodPool(Selector Sel) {
void Sema::AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl,
bool instance) {
+ if (ExternalSource)
+ ReadMethodPool(Method->getSelector());
+
GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
- if (Pos == MethodPool.end()) {
- if (ExternalSource) {
- ReadMethodPool(Method->getSelector());
- Pos = MethodPool.find(Method->getSelector());
- }
-
- if (Pos == MethodPool.end())
- Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
- GlobalMethods())).first;
- }
+ if (Pos == MethodPool.end())
+ Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
+ GlobalMethods())).first;
Method->setDefined(impl);
@@ -2023,18 +2019,12 @@ static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen,
ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R,
bool receiverIdOrClass,
bool warn, bool instance) {
+ if (ExternalSource)
+ ReadMethodPool(Sel);
+
GlobalMethodPool::iterator Pos = MethodPool.find(Sel);
- if (Pos == MethodPool.end()) {
- if (ExternalSource) {
- ReadMethodPool(Sel);
-
- Pos = MethodPool.find(Sel);
- if (Pos == MethodPool.end())
- return 0;
-
- } else
- return 0;
- }
+ if (Pos == MethodPool.end())
+ return 0;
ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
diff --git a/clang/test/Modules/Inputs/MethodPoolA.h b/clang/test/Modules/Inputs/MethodPoolA.h
new file mode 100644
index 00000000000..6af24a92911
--- /dev/null
+++ b/clang/test/Modules/Inputs/MethodPoolA.h
@@ -0,0 +1,8 @@
+
+
+
+
+@interface A
++ (int)method1;
+- (int)method2:(int)param;
+@end
diff --git a/clang/test/Modules/Inputs/MethodPoolB.h b/clang/test/Modules/Inputs/MethodPoolB.h
new file mode 100644
index 00000000000..e1e86edaf84
--- /dev/null
+++ b/clang/test/Modules/Inputs/MethodPoolB.h
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+@interface B
+- (int)method1;
+- (int)method2:(float)param;
+@end
diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map
index 2819e62b8f1..e09073f818c 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/module.map
@@ -75,3 +75,9 @@ module namespaces_right {
header "namespaces-right.h"
export *
}
+module MethodPoolA {
+ header "MethodPoolA.h"
+}
+module MethodPoolB {
+ header "MethodPoolB.h"
+}
diff --git a/clang/test/Modules/method_pool.m b/clang/test/Modules/method_pool.m
new file mode 100644
index 00000000000..9574caa1528
--- /dev/null
+++ b/clang/test/Modules/method_pool.m
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-cache-path %t -fmodules -I %S/Inputs %s -verify
+
+@import MethodPoolA;
+
+
+// in other file: // expected-note{{using}}
+
+
+
+
+// in other file: expected-note{{also found}}
+
+void testMethod1(id object) {
+ [object method1];
+}
+
+void testMethod2(id object) {
+ [object method2:1];
+}
+
+@import MethodPoolB;
+
+void testMethod1Again(id object) {
+ [object method1];
+}
+
+void testMethod2Again(id object) {
+ [object method2:1]; // expected-warning{{multiple methods named 'method2:' found}}
+}
OpenPOWER on IntegriCloud