Skip to content

Commit 6007b0b

Browse files
committed
[clang][deps] NFC: Use range-based for loop instead of iterators
The iterator is not needed after the loop body anymore, meaning we can use more terse range-based for loop. Depends on D121295. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D121685
1 parent 77924d6 commit 6007b0b

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

clang/lib/Lex/HeaderSearch.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,20 +299,19 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
299299
SourceLocation ImportLoc,
300300
bool AllowExtraModuleMapSearch) {
301301
Module *Module = nullptr;
302-
SearchDirIterator It = nullptr;
303302

304303
// Look through the various header search paths to load any available module
305304
// maps, searching for a module map that describes this module.
306-
for (It = search_dir_begin(); It != search_dir_end(); ++It) {
307-
if (It->isFramework()) {
305+
for (DirectoryLookup Dir : search_dir_range()) {
306+
if (Dir.isFramework()) {
308307
// Search for or infer a module map for a framework. Here we use
309308
// SearchName rather than ModuleName, to permit finding private modules
310309
// named FooPrivate in buggy frameworks named Foo.
311310
SmallString<128> FrameworkDirName;
312-
FrameworkDirName += It->getFrameworkDir()->getName();
311+
FrameworkDirName += Dir.getFrameworkDir()->getName();
313312
llvm::sys::path::append(FrameworkDirName, SearchName + ".framework");
314313
if (auto FrameworkDir = FileMgr.getDirectory(FrameworkDirName)) {
315-
bool IsSystem = It->getDirCharacteristic() != SrcMgr::C_User;
314+
bool IsSystem = Dir.getDirCharacteristic() != SrcMgr::C_User;
316315
Module = loadFrameworkModule(ModuleName, *FrameworkDir, IsSystem);
317316
if (Module)
318317
break;
@@ -322,12 +321,12 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
322321
// FIXME: Figure out how header maps and module maps will work together.
323322

324323
// Only deal with normal search directories.
325-
if (!It->isNormalDir())
324+
if (!Dir.isNormalDir())
326325
continue;
327326

328-
bool IsSystem = It->isSystemHeaderDirectory();
327+
bool IsSystem = Dir.isSystemHeaderDirectory();
329328
// Search for a module map file in this directory.
330-
if (loadModuleMapFile(It->getDir(), IsSystem,
329+
if (loadModuleMapFile(Dir.getDir(), IsSystem,
331330
/*IsFramework*/false) == LMM_NewlyLoaded) {
332331
// We just loaded a module map file; check whether the module is
333332
// available now.
@@ -339,7 +338,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
339338
// Search for a module map in a subdirectory with the same name as the
340339
// module.
341340
SmallString<128> NestedModuleMapDirName;
342-
NestedModuleMapDirName = It->getDir()->getName();
341+
NestedModuleMapDirName = Dir.getDir()->getName();
343342
llvm::sys::path::append(NestedModuleMapDirName, ModuleName);
344343
if (loadModuleMapFile(NestedModuleMapDirName, IsSystem,
345344
/*IsFramework*/false) == LMM_NewlyLoaded){
@@ -351,13 +350,13 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
351350

352351
// If we've already performed the exhaustive search for module maps in this
353352
// search directory, don't do it again.
354-
if (It->haveSearchedAllModuleMaps())
353+
if (Dir.haveSearchedAllModuleMaps())
355354
continue;
356355

357356
// Load all module maps in the immediate subdirectories of this search
358357
// directory if ModuleName was from @import.
359358
if (AllowExtraModuleMapSearch)
360-
loadSubdirectoryModuleMaps(*It);
359+
loadSubdirectoryModuleMaps(Dir);
361360

362361
// Look again for the module.
363362
Module = ModMap.findModule(ModuleName);

0 commit comments

Comments
 (0)