aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Module.cpp
diff options
context:
space:
mode:
authorStoorx <me@stoorx.one>2023-04-18 23:49:00 +0300
committerStoorx <me@stoorx.one>2023-04-24 12:05:59 +0300
commit40136ecefc0a542da7d0f1736c51325edc5539b4 (patch)
tree252e4cff7890431ff8f77a92184549fee68cc214 /clang/lib/Basic/Module.cpp
parent0a113c4c50f65a7d26d20be84bfb56562154753f (diff)
downloadllvm-40136ecefc0a542da7d0f1736c51325edc5539b4.zip
llvm-40136ecefc0a542da7d0f1736c51325edc5539b4.tar.gz
llvm-40136ecefc0a542da7d0f1736c51325edc5539b4.tar.bz2
[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
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r--clang/lib/Basic/Module.cpp20
1 files changed, 8 insertions, 12 deletions
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);