[clang] 32c2ea5 - [clang][lex] NFC: Simplify loop

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 5 05:40:52 PST 2022


Author: Jan Svoboda
Date: 2022-01-05T14:40:47+01:00
New Revision: 32c2ea5c33a710cb1497bbd903039d8a9641e98a

URL: https://github.com/llvm/llvm-project/commit/32c2ea5c33a710cb1497bbd903039d8a9641e98a
DIFF: https://github.com/llvm/llvm-project/commit/32c2ea5c33a710cb1497bbd903039d8a9641e98a.diff

LOG: [clang][lex] NFC: Simplify loop

Added: 
    

Modified: 
    clang/lib/Lex/HeaderSearch.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index a0b60118a1a81..5cb009dd68d1d 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -29,6 +29,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Capacity.h"
 #include "llvm/Support/Errc.h"
@@ -1779,11 +1780,8 @@ void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
   }
 
   // Populate the list of modules.
-  for (ModuleMap::module_iterator M = ModMap.module_begin(),
-                               MEnd = ModMap.module_end();
-       M != MEnd; ++M) {
-    Modules.push_back(M->getValue());
-  }
+  llvm::transform(ModMap.modules(), std::back_inserter(Modules),
+                  [](const auto &NameAndMod) { return NameAndMod.second; });
 }
 
 void HeaderSearch::loadTopLevelSystemModules() {


        


More information about the cfe-commits mailing list