[cfe-commits] r148891 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/Modules/Inputs/MethodPoolA.h test/Modules/Inputs/MethodPoolB.h test/Modules/Inputs/module.map test/Modules/method_pool.m
Douglas Gregor
dgregor at apple.com
Tue Jan 24 16:59:09 PST 2012
Author: dgregor
Date: Tue Jan 24 18:59:09 2012
New Revision: 148891
URL: http://llvm.org/viewvc/llvm-project?rev=148891&view=rev
Log:
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.
Added:
cfe/trunk/test/Modules/Inputs/MethodPoolA.h
cfe/trunk/test/Modules/Inputs/MethodPoolB.h
cfe/trunk/test/Modules/method_pool.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Modules/Inputs/module.map
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=148891&r1=148890&r2=148891&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Jan 24 18:59:09 2012
@@ -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;
Added: cfe/trunk/test/Modules/Inputs/MethodPoolA.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MethodPoolA.h?rev=148891&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MethodPoolA.h (added)
+++ cfe/trunk/test/Modules/Inputs/MethodPoolA.h Tue Jan 24 18:59:09 2012
@@ -0,0 +1,8 @@
+
+
+
+
+ at interface A
++ (int)method1;
+- (int)method2:(int)param;
+ at end
Added: cfe/trunk/test/Modules/Inputs/MethodPoolB.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MethodPoolB.h?rev=148891&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MethodPoolB.h (added)
+++ cfe/trunk/test/Modules/Inputs/MethodPoolB.h Tue Jan 24 18:59:09 2012
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+ at interface B
+- (int)method1;
+- (int)method2:(float)param;
+ at end
Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=148891&r1=148890&r2=148891&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Tue Jan 24 18:59:09 2012
@@ -75,3 +75,9 @@
header "namespaces-right.h"
export *
}
+module MethodPoolA {
+ header "MethodPoolA.h"
+}
+module MethodPoolB {
+ header "MethodPoolB.h"
+}
Added: cfe/trunk/test/Modules/method_pool.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/method_pool.m?rev=148891&view=auto
==============================================================================
--- cfe/trunk/test/Modules/method_pool.m (added)
+++ cfe/trunk/test/Modules/method_pool.m Tue Jan 24 18:59:09 2012
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-cache-path %t -fmodules -I %S/Inputs %s -verify
+
+ at 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];
+}
+
+ at import MethodPoolB;
+
+void testMethod1Again(id object) {
+ [object method1];
+}
+
+void testMethod2Again(id object) {
+ [object method2:1]; // expected-warning{{multiple methods named 'method2:' found}}
+}
More information about the cfe-commits
mailing list