r186795 - Revert r186649 because it wasn't unnecessary and add a comment.

Craig Topper craig.topper at gmail.com
Sun Jul 21 11:58:40 PDT 2013


Author: ctopper
Date: Sun Jul 21 13:58:40 2013
New Revision: 186795

URL: http://llvm.org/viewvc/llvm-project?rev=186795&view=rev
Log:
Revert r186649 because it wasn't unnecessary and add a comment.

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=186795&r1=186794&r2=186795&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Sun Jul 21 13:58:40 2013
@@ -92,13 +92,17 @@ static const unsigned StaticDiagInfoSize
 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");
+  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");
+      assert(StaticDiagInfo[i-1] < StaticDiagInfo[i] &&
+             "Improperly sorted diag info");
+    }
+    IsFirst = false;
   }
 #endif
 





More information about the cfe-commits mailing list