From 40136ecefc0a542da7d0f1736c51325edc5539b4 Mon Sep 17 00:00:00 2001 From: Stoorx Date: Tue, 18 Apr 2023 23:49:00 +0300 Subject: [clang] Make access to submodules via `iterator_range` In file `clang/lib/Basic/Module.cpp` the `Module` class had `submodule_begin()` and `submodule_end()` functions to retrieve corresponding iterators for private vector of Modules. This commit removes mentioned functions, and replaces all of theirs usages with `submodules()` function and range-based for-loops. Differential Revision: https://reviews.llvm.org/D148954 --- clang/lib/Basic/Module.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'clang/lib/Basic/Module.cpp') diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 9c4c834..e5994a7 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -59,9 +59,8 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, } Module::~Module() { - for (submodule_iterator I = submodule_begin(), IEnd = submodule_end(); - I != IEnd; ++I) { - delete *I; + for (auto *Submodule : SubModules) { + delete Submodule; } } @@ -339,11 +338,9 @@ void Module::markUnavailable(bool Unimportable) { Current->IsAvailable = false; Current->IsUnimportable |= Unimportable; - for (submodule_iterator Sub = Current->submodule_begin(), - SubEnd = Current->submodule_end(); - Sub != SubEnd; ++Sub) { - if (needUpdate(*Sub)) - Stack.push_back(*Sub); + for (auto *Submodule : Current->submodules()) { + if (needUpdate(Submodule)) + Stack.push_back(Submodule); } } } @@ -550,14 +547,13 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const { OS << "export_as" << ExportAsModule << "\n"; } - for (submodule_const_iterator MI = submodule_begin(), MIEnd = submodule_end(); - MI != MIEnd; ++MI) + for (auto *Submodule : submodules()) // Print inferred subframework modules so that we don't need to re-infer // them (requires expensive directory iteration + stat calls) when we build // the module. Regular inferred submodules are OK, as we need to look at all // those header files anyway. - if (!(*MI)->IsInferred || (*MI)->IsFramework) - (*MI)->print(OS, Indent + 2, Dump); + if (!Submodule->IsInferred || Submodule->IsFramework) + Submodule->print(OS, Indent + 2, Dump); for (unsigned I = 0, N = Exports.size(); I != N; ++I) { OS.indent(Indent + 2); -- cgit v1.1