]> granicus.if.org Git - clang/commitdiff
Revert r186649 because it wasn't unnecessary and add a comment.
authorCraig Topper <craig.topper@gmail.com>
Sun, 21 Jul 2013 18:58:40 +0000 (18:58 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sun, 21 Jul 2013 18:58:40 +0000 (18:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186795 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/DiagnosticIDs.cpp

index e96d5097e620c4955e8edc1e735632f62f7a83de..898c51c497023fb79dc965696a201fa40637422f 100644 (file)
@@ -92,13 +92,17 @@ static const unsigned StaticDiagInfoSize = llvm::array_lengthof(StaticDiagInfo);
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
   // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
 #ifndef NDEBUG
-  for (unsigned i = 1; i != StaticDiagInfoSize; ++i) {
-    assert(StaticDiagInfo[i-1].DiagID != StaticDiagInfo[i].DiagID &&
-           "Diag ID conflict, the enums at the start of clang::diag (in "
-           "DiagnosticIDs.h) probably need to be increased");
-
-    assert(StaticDiagInfo[i-1] < StaticDiagInfo[i] &&
-           "Improperly sorted diag info");
+  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].DiagID != StaticDiagInfo[i].DiagID &&
+             "Diag ID conflict, the enums at the start of clang::diag (in "
+             "DiagnosticIDs.h) probably need to be increased");
+
+      assert(StaticDiagInfo[i-1] < StaticDiagInfo[i] &&
+             "Improperly sorted diag info");
+    }
+    IsFirst = false;
   }
 #endif