diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-02-12 23:36:21 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-02-12 23:36:21 +0000 |
commit | 2cbd427ec533f022f612fed0dd93ef5fa214478a (patch) | |
tree | 959d117a29a037d4685781442e2e162fc51a6daf /lib/Serialization | |
parent | b0112e122650cbc9a1a0af42ad84b7178ba0a876 (diff) |
Order the methods in the global method pool based on when they become visible, not when they become deserialized <rdar://problem/13203033>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 53fa21f9aa..6f0dcaae30 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2594,13 +2594,50 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) { } } +/// \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; + 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()); |