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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148891 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 432e3dd..4394dbf 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1983,17 +1983,13 @@
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 @@
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;