[PATCH] D91033: [clang-tidy][NFC] Tweak GlobList to iterate backwards

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 10 05:54:54 PST 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a request to add a comment.



================
Comment at: clang-tools-extra/clang-tidy/GlobList.cpp:56
 bool GlobList::contains(StringRef S) {
-  bool Contains = false;
-  for (const GlobListItem &Item : Items) {
+  for (const GlobListItem &Item : llvm::reverse(Items)) {
     if (Item.Regex.match(S))
----------------
I'd appreciate a comment here that mentions *why* reversing backwards means we can early return. It took me a few tries to remember that glob patterns can undo earlier glob patterns, so that the last pattern is the one that matters.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91033/new/

https://reviews.llvm.org/D91033



More information about the cfe-commits mailing list