[PATCH] D78016: [ADT/STLExtras.h] - Add llvm::is_sorted wrapper and update callers.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 08:34:35 PDT 2020


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

Looks great! Hope another reviewer can confirm.



================
Comment at: llvm/lib/IR/AsmWriter.cpp:231
 
-  if (std::is_sorted(
-          List.begin(), List.end(),
-          [](const Entry &L, const Entry &R) { return L.second < R.second; }))
+  if (llvm::is_sorted(List, [](const Entry &L, const Entry &R) {
+        return L.second < R.second;
----------------
This can be further simplified to `llvm::is_sorted(lll, llvm::less_second())`


================
Comment at: llvm/lib/IR/Attributes.cpp:1022
 
-  assert(std::is_sorted(Attrs.begin(), Attrs.end(),
-                        [](const std::pair<unsigned, Attribute> &LHS,
-                           const std::pair<unsigned, Attribute> &RHS) {
-                          return LHS.first < RHS.first;
-                        }) && "Misordered Attributes list!");
+  assert(llvm::is_sorted(Attrs,
+                         [](const std::pair<unsigned, Attribute> &LHS,
----------------
`llvm::is_sorted(..., llvm::less_first())`


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

https://reviews.llvm.org/D78016





More information about the llvm-commits mailing list