r250645 - Use std::is_sorted instead of a manual loop.

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 17 22:29:21 PDT 2015


Author: ctopper
Date: Sun Oct 18 00:29:21 2015
New Revision: 250645

URL: http://llvm.org/viewvc/llvm-project?rev=250645&view=rev
Log:
Use std::is_sorted instead of a manual loop.

Modified:
    cfe/trunk/lib/Basic/DiagnosticIDs.cpp

Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=250645&r1=250644&r2=250645&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Sun Oct 18 00:29:21 2015
@@ -100,11 +100,10 @@ static const StaticDiagInfoRec *GetDiagI
 #ifndef NDEBUG
   static bool IsFirst = true; // So the check is only performed on first call.
   if (IsFirst) {
-    for (unsigned i = 1; i != StaticDiagInfoSize; ++i) {
-      assert(StaticDiagInfo[i-1] < StaticDiagInfo[i] &&
-             "Diag ID conflict, the enums at the start of clang::diag (in "
-             "DiagnosticIDs.h) probably need to be increased");
-    }
+    assert(std::is_sorted(std::begin(StaticDiagInfo),
+                          std::end(StaticDiagInfo)) &&
+           "Diag ID conflict, the enums at the start of clang::diag (in "
+           "DiagnosticIDs.h) probably need to be increased");
     IsFirst = false;
   }
 #endif




More information about the cfe-commits mailing list