From 4881e8b239e2feb5cb5f7cb82b9bc98c61683fca Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 10 Jun 2015 01:37:59 +0000 Subject: [PATCH] [cleanup] Remove unused default argument and tidy up. The RequestingModule argument was unused and always its default value of nullptr. Also move a declaration closer to its use, and range-for'ify. llvm-svn: 239453 --- clang/include/clang/Lex/ModuleMap.h | 7 +------ clang/lib/Lex/ModuleMap.cpp | 30 ++++++----------------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/clang/include/clang/Lex/ModuleMap.h b/clang/include/clang/Lex/ModuleMap.h index e41efc5d419d..0bbcfac3b81b 100644 --- a/clang/include/clang/Lex/ModuleMap.h +++ b/clang/include/clang/Lex/ModuleMap.h @@ -268,15 +268,10 @@ public: /// /// \param File The header file that is likely to be included. /// - /// \param RequestingModule Specifies the module the header is intended to be - /// used from. Used to disambiguate if a header is present in multiple - /// modules. - /// /// \returns The module KnownHeader, which provides the module that owns the /// given header file. The KnownHeader is default constructed to indicate /// that no module owns this header file. - KnownHeader findModuleForHeader(const FileEntry *File, - Module *RequestingModule = nullptr); + KnownHeader findModuleForHeader(const FileEntry *File); /// \brief Reports errors if a module must not include a specific file. /// diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index addad59c5a3e..c67ce248010f 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -330,41 +330,23 @@ static bool isBetterKnownHeader(const ModuleMap::KnownHeader &New, return false; } -ModuleMap::KnownHeader -ModuleMap::findModuleForHeader(const FileEntry *File, - Module *RequestingModule) { - HeadersMap::iterator Known = findKnownHeader(File); - +ModuleMap::KnownHeader ModuleMap::findModuleForHeader(const FileEntry *File) { auto MakeResult = [&](ModuleMap::KnownHeader R) -> ModuleMap::KnownHeader { if (R.getRole() & ModuleMap::TextualHeader) return ModuleMap::KnownHeader(); return R; }; + HeadersMap::iterator Known = findKnownHeader(File); if (Known != Headers.end()) { ModuleMap::KnownHeader Result; - // Iterate over all modules that 'File' is part of to find the best fit. - for (SmallVectorImpl::iterator I = Known->second.begin(), - E = Known->second.end(); - I != E; ++I) { + for (KnownHeader &H : Known->second) { // Cannot use a module if it is unavailable. - if (!I->getModule()->isAvailable()) + if (!H.getModule()->isAvailable()) continue; - - // If 'File' is part of 'RequestingModule', 'RequestingModule' is the - // module we are looking for. - if (I->getModule() == RequestingModule) - return MakeResult(*I); - - // If uses need to be specified explicitly, we are only allowed to return - // modules that are explicitly used by the requesting module. - if (RequestingModule && LangOpts.ModulesDeclUse && - !RequestingModule->directlyUses(I->getModule())) - continue; - - if (!Result || isBetterKnownHeader(*I, Result)) - Result = *I; + if (!Result || isBetterKnownHeader(H, Result)) + Result = H; } return MakeResult(Result); }