[PATCH] D25982: [PP] Replace some index based for loops with range based ones

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 04:55:54 PDT 2016


bkramer added inline comments.


================
Comment at: lib/Lex/PPLexerChange.cpp:43
          "Top level include stack isn't our primary lexer?");
-  for (unsigned i = 1, e = IncludeMacroStack.size(); i != e; ++i)
-    if (IsFileLexer(IncludeMacroStack[i]))
+  for (const IncludeStackInfo &ISI : llvm::reverse(
+         llvm::make_range(IncludeMacroStack.begin() + 1,
----------------
This wasn't a reverse loop?

Also I think at this point writing it with none_of is more readable:
```
return std::none_of(IncludeMacroStack.begin() + 1, IncludeMacroStack.end(), IsFileLexer);
```


https://reviews.llvm.org/D25982





More information about the cfe-commits mailing list