r175018 - Order the methods in the global method pool based on when they become visible, not when they become deserialized <rdar://problem/13203033>.
Douglas Gregor
dgregor at apple.com
Tue Feb 12 15:36:21 PST 2013
Author: dgregor
Date: Tue Feb 12 17:36:21 2013
New Revision: 175018
URL: http://llvm.org/viewvc/llvm-project?rev=175018&view=rev
Log:
Order the methods in the global method pool based on when they become visible, not when they become deserialized <rdar://problem/13203033>.
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/Inputs/MethodPoolA.h
cfe/trunk/test/Modules/Inputs/MethodPoolASub.h
cfe/trunk/test/Modules/method_pool.m
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=175018&r1=175017&r2=175018&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Feb 12 17:36:21 2013
@@ -2594,13 +2594,50 @@ bool ASTReader::ReadASTBlock(ModuleFile
}
}
+/// \brief Move the given method to the back of the global list of methods.
+static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) {
+ // Find the entry for this selector in the method pool.
+ Sema::GlobalMethodPool::iterator Known
+ = S.MethodPool.find(Method->getSelector());
+ if (Known == S.MethodPool.end())
+ return;
+
+ // Retrieve the appropriate method list.
+ ObjCMethodList &Start = Method->isInstanceMethod()? Known->second.first
+ : Known->second.second;
+ bool Found = false;
+ for (ObjCMethodList *List = &Start; List; List = List->Next) {
+ if (!Found) {
+ if (List->Method == Method) {
+ Found = true;
+ } else {
+ // Keep searching.
+ continue;
+ }
+ }
+
+ if (List->Next)
+ List->Method = List->Next->Method;
+ else
+ List->Method = Method;
+ }
+}
+
void ASTReader::makeNamesVisible(const HiddenNames &Names) {
for (unsigned I = 0, N = Names.size(); I != N; ++I) {
switch (Names[I].getKind()) {
- case HiddenName::Declaration:
- Names[I].getDecl()->Hidden = false;
- break;
+ case HiddenName::Declaration: {
+ Decl *D = Names[I].getDecl();
+ bool wasHidden = D->Hidden;
+ D->Hidden = false;
+ if (wasHidden && SemaObj) {
+ if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D)) {
+ moveMethodToBackOfGlobalList(*SemaObj, Method);
+ }
+ }
+ break;
+ }
case HiddenName::MacroVisibility: {
std::pair<IdentifierInfo *, MacroInfo *> Macro = Names[I].getMacro();
Macro.second->setHidden(!Macro.second->isPublic());
Modified: cfe/trunk/test/Modules/Inputs/MethodPoolA.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MethodPoolA.h?rev=175018&r1=175017&r2=175018&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MethodPoolA.h (original)
+++ cfe/trunk/test/Modules/Inputs/MethodPoolA.h Tue Feb 12 17:36:21 2013
@@ -6,3 +6,9 @@
+ (int)method1;
- (int)method2:(int)param;
@end
+
+ at interface B : A
+ at end
+
+ at interface C
+ at end
Modified: cfe/trunk/test/Modules/Inputs/MethodPoolASub.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MethodPoolASub.h?rev=175018&r1=175017&r2=175018&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MethodPoolASub.h (original)
+++ cfe/trunk/test/Modules/Inputs/MethodPoolASub.h Tue Feb 12 17:36:21 2013
@@ -1,4 +1,6 @@
@interface A (Sub)
- (char)method3;
- (char*)method4;
+- (void)method5:(C*)obj;
@end
+
Modified: cfe/trunk/test/Modules/method_pool.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/method_pool.m?rev=175018&r1=175017&r2=175018&view=diff
==============================================================================
--- cfe/trunk/test/Modules/method_pool.m (original)
+++ cfe/trunk/test/Modules/method_pool.m Tue Feb 12 17:36:21 2013
@@ -1,15 +1,15 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -I %S/Inputs %s -verify
- at import MethodPoolA;
-
-
-// in other file: // expected-note{{using}}
-
+ at import MethodPoolA;
+ at interface D
+- (void)method5:(D*)obj;
+ at end
-// in other file: expected-note{{also found}}
+// in other file: // expected-note at 7{{using}}
+// in other file: expected-note at 12{{also found}}
void testMethod1(id object) {
[object method1];
@@ -23,6 +23,10 @@ void testMethod4(id object) {
[object method4]; // expected-warning{{instance method '-method4' not found (return type defaults to 'id')}}
}
+void testMethod5(id object, D* d) {
+ [object method5:d];
+}
+
@import MethodPoolB;
void testMethod1Again(id object) {
@@ -54,3 +58,7 @@ void testMethod3AgainAgain(id object) {
void testMethod4Again(id object) {
[object method4];
}
+
+void testMethod5Again(id object, D* d) {
+ [object method5:d];
+}
More information about the cfe-commits
mailing list