Skip to content

Commit f11c0a1

Browse files
[ExecutionEngine] Use range-based for loops (NFC) (#98110)
1 parent ef9aba2 commit f11c0a1

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

llvm/lib/ExecutionEngine/ExecutionEngine.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,17 @@ bool ExecutionEngine::removeModule(Module *M) {
151151
}
152152

153153
Function *ExecutionEngine::FindFunctionNamed(StringRef FnName) {
154-
for (unsigned i = 0, e = Modules.size(); i != e; ++i) {
155-
Function *F = Modules[i]->getFunction(FnName);
154+
for (const auto &M : Modules) {
155+
Function *F = M->getFunction(FnName);
156156
if (F && !F->isDeclaration())
157157
return F;
158158
}
159159
return nullptr;
160160
}
161161

162162
GlobalVariable *ExecutionEngine::FindGlobalVariableNamed(StringRef Name, bool AllowInternal) {
163-
for (unsigned i = 0, e = Modules.size(); i != e; ++i) {
164-
GlobalVariable *GV = Modules[i]->getGlobalVariable(Name,AllowInternal);
163+
for (const auto &M : Modules) {
164+
GlobalVariable *GV = M->getGlobalVariable(Name, AllowInternal);
165165
if (GV && !GV->isDeclaration())
166166
return GV;
167167
}
@@ -314,8 +314,8 @@ const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
314314

315315
if (I != EEState.getGlobalAddressReverseMap().end()) {
316316
StringRef Name = I->second;
317-
for (unsigned i = 0, e = Modules.size(); i != e; ++i)
318-
if (GlobalValue *GV = Modules[i]->getNamedValue(Name))
317+
for (const auto &M : Modules)
318+
if (GlobalValue *GV = M->getNamedValue(Name))
319319
return GV;
320320
}
321321
return nullptr;
@@ -1219,9 +1219,8 @@ void ExecutionEngine::emitGlobals() {
12191219
const GlobalValue*> LinkedGlobalsMap;
12201220

12211221
if (Modules.size() != 1) {
1222-
for (unsigned m = 0, e = Modules.size(); m != e; ++m) {
1223-
Module &M = *Modules[m];
1224-
for (const auto &GV : M.globals()) {
1222+
for (const auto &M : Modules) {
1223+
for (const auto &GV : M->globals()) {
12251224
if (GV.hasLocalLinkage() || GV.isDeclaration() ||
12261225
GV.hasAppendingLinkage() || !GV.hasName())
12271226
continue;// Ignore external globals and globals with internal linkage.
@@ -1249,9 +1248,8 @@ void ExecutionEngine::emitGlobals() {
12491248
}
12501249

12511250
std::vector<const GlobalValue*> NonCanonicalGlobals;
1252-
for (unsigned m = 0, e = Modules.size(); m != e; ++m) {
1253-
Module &M = *Modules[m];
1254-
for (const auto &GV : M.globals()) {
1251+
for (const auto &M : Modules) {
1252+
for (const auto &GV : M->globals()) {
12551253
// In the multi-module case, see what this global maps to.
12561254
if (!LinkedGlobalsMap.empty()) {
12571255
if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
@@ -1293,7 +1291,7 @@ void ExecutionEngine::emitGlobals() {
12931291

12941292
// Now that all of the globals are set up in memory, loop through them all
12951293
// and initialize their contents.
1296-
for (const auto &GV : M.globals()) {
1294+
for (const auto &GV : M->globals()) {
12971295
if (!GV.isDeclaration()) {
12981296
if (!LinkedGlobalsMap.empty()) {
12991297
if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,7 @@ void RuntimeDyldImpl::reassignSectionAddress(unsigned SectionID,
10971097

10981098
void RuntimeDyldImpl::resolveRelocationList(const RelocationList &Relocs,
10991099
uint64_t Value) {
1100-
for (unsigned i = 0, e = Relocs.size(); i != e; ++i) {
1101-
const RelocationEntry &RE = Relocs[i];
1100+
for (const RelocationEntry &RE : Relocs) {
11021101
// Ignore relocations for sections that were not loaded
11031102
if (RE.SectionID != AbsoluteSymbolSection &&
11041103
Sections[RE.SectionID].getAddress() == nullptr)

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ RuntimeDyldELF::RuntimeDyldELF(RuntimeDyld::MemoryManager &MemMgr,
220220
RuntimeDyldELF::~RuntimeDyldELF() = default;
221221

222222
void RuntimeDyldELF::registerEHFrames() {
223-
for (int i = 0, e = UnregisteredEHFrameSections.size(); i != e; ++i) {
224-
SID EHFrameSID = UnregisteredEHFrameSections[i];
223+
for (SID EHFrameSID : UnregisteredEHFrameSections) {
225224
uint8_t *EHFrameAddr = Sections[EHFrameSID].getAddress();
226225
uint64_t EHFrameLoadAddr = Sections[EHFrameSID].getLoadAddress();
227226
size_t EHFrameSize = Sections[EHFrameSID].getSize();

0 commit comments

Comments
 (0)