forked from OSchip/llvm-project
[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
This commit is contained in:
parent
8dbe7e236c
commit
4881e8b239
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -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<KnownHeader>::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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue