]> granicus.if.org Git - clang/commitdiff
When building a module, keep *all* declared methods in the global method pool.
authorDouglas Gregor <dgregor@apple.com>
Fri, 21 Jun 2013 00:20:25 +0000 (00:20 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 21 Jun 2013 00:20:25 +0000 (00:20 +0000)
As an optimization, we only kept declared methods with distinct
signatures in the global method pool, to keep the method lists
small. Under modules, however, one could have two different methods
with the same signature that occur in different (sub)modules. If only
the later submodule is important, message sends to 'id' with that
selector would fail because the first method (the only one that got
into the method pool) was hidden. When building a module, keep *all*
of the declared methods.

I did a quick check of both module build time and uses of modules, and
found no performance regression despite this causing us to keep more
methods in the global method pool. Fixes <rdar://problem/14148896>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184504 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
test/Modules/Inputs/MethodPoolBSub.h
test/Modules/Inputs/module.map
test/Modules/method_pool.m

index 526e479af08182d0658094c0ad65ba4f830f37dd..618c9d99e1bcf8747c7e72c5de3410893e515bef 100644 (file)
@@ -2130,6 +2130,10 @@ void Sema::addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method) {
   // signature.
   ObjCMethodList *Previous = List;
   for (; List; Previous = List, List = List->getNext()) {
+    // If we are building a module, keep all of the methods.
+    if (getLangOpts().Modules && !getLangOpts().CurrentModule.empty())
+      continue;
+
     if (!MatchTwoMethodDeclarations(Method, List->Method))
       continue;
     
index 0a7899df81b79d6e34db042907d3090a1e500935..fbfc0aa1439207f633ee3b1aa950a4c1c30a0160 100644 (file)
@@ -1,4 +1,5 @@
 @interface B (Sub)
 - (char *)method3;
 - (char*)method4;
+- (id)method6;
 @end
index 249700a494ac0ce4667ee185f7d83a0a0bf9139a..5a95ce9edc0e9f41c3c8bd01f32f4fe482a506a3 100644 (file)
@@ -131,6 +131,10 @@ module MethodPoolA {
 module MethodPoolB {
   header "MethodPoolB.h"
 
+  explicit module Sub2 {
+    header "MethodPoolBSub2.h"
+  }
+
   explicit module Sub {
     header "MethodPoolBSub.h"
   }
index 6fd74b0885fd3cbb20c264f0a67bf94803fa01c9..f7d5ae700c9797d860cd3f0fd6d1961166abf82f 100644 (file)
@@ -47,6 +47,10 @@ void testMethod3Again(id object) {
   char *str = [object method3]; // okay: only found in MethodPoolB.Sub
 }
 
+void testMethod6(id object) {
+  [object method6];
+}
+
 @import MethodPoolA.Sub;
 
 void testMethod3AgainAgain(id object) {