[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D37122



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311905: Change Diagnostic Category size error from runtime 
to compiletime (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D37122?vs=112916=112931#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37122

Files:
  cfe/trunk/include/clang/Basic/DiagnosticIDs.h
  cfe/trunk/lib/Basic/DiagnosticIDs.cpp

Index: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
===
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp
@@ -68,6 +68,29 @@
   }
 };
 
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   \
+  static_assert(   \
+  static_cast(diag::NUM_BUILTIN_##NAME##_DIAGNOSTICS) <  \
+  static_cast(diag::DIAG_START_##NAME) + \
+  static_cast(diag::DIAG_SIZE_##NAME),   \
+  STRINGIFY_NAME(  \
+  DIAG_SIZE_##NAME) " is insufficient to contain all " \
+"diagnostics, it may need to be made larger in "   \
+"DiagnosticIDs.h.");
+VALIDATE_DIAG_SIZE(COMMON)
+VALIDATE_DIAG_SIZE(DRIVER)
+VALIDATE_DIAG_SIZE(FRONTEND)
+VALIDATE_DIAG_SIZE(SERIALIZATION)
+VALIDATE_DIAG_SIZE(LEX)
+VALIDATE_DIAG_SIZE(PARSE)
+VALIDATE_DIAG_SIZE(AST)
+VALIDATE_DIAG_SIZE(COMMENT)
+VALIDATE_DIAG_SIZE(SEMA)
+VALIDATE_DIAG_SIZE(ANALYSIS)
+#undef VALIDATE_DIAG_SIZE
+#undef STRINGIFY_NAME
+
 } // namespace anonymous
 
 static const StaticDiagInfoRec StaticDiagInfo[] = {
@@ -96,18 +119,6 @@
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
-#ifndef NDEBUG
-  static bool IsFirst = true; // So the check is only performed on first call.
-  if (IsFirst) {
-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
-
   // Out of bounds diag. Can't be in the table.
   using namespace diag;
   if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Index: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
===
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h
@@ -26,19 +26,32 @@
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+  DIAG_START_COMMON=  0,
+  DIAG_START_DRIVER= DIAG_START_COMMON+ DIAG_SIZE_COMMON,
+  DIAG_START_FRONTEND  = DIAG_START_DRIVER+ DIAG_SIZE_DRIVER,
+  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND  + DIAG_SIZE_FRONTEND,
+  DIAG_START_LEX   = DIAG_START_SERIALIZATION + DIAG_SIZE_SERIALIZATION,
+  DIAG_START_PARSE = DIAG_START_LEX   + DIAG_SIZE_LEX,
+  DIAG_START_AST   = DIAG_START_PARSE + DIAG_SIZE_PARSE,
+  DIAG_START_COMMENT   = DIAG_START_AST   + DIAG_SIZE_AST,
+  DIAG_START_SEMA  = DIAG_START_COMMENT   + DIAG_SIZE_COMMENT,
+  DIAG_START_ANALYSIS  = DIAG_START_SEMA  + DIAG_SIZE_SEMA,
+  DIAG_UPPER_LIMIT = 

[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 112916.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Moved static assert into a .cpp file, DiagnosticIDs.cpp seems like the one that 
makes the most sense.


https://reviews.llvm.org/D37122

Files:
  include/clang/Basic/DiagnosticIDs.h
  lib/Basic/DiagnosticIDs.cpp

Index: lib/Basic/DiagnosticIDs.cpp
===
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -68,6 +68,29 @@
   }
 };
 
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   \
+  static_assert(   \
+  static_cast(diag::NUM_BUILTIN_##NAME##_DIAGNOSTICS) <  \
+  static_cast(diag::DIAG_START_##NAME) + \
+  static_cast(diag::DIAG_SIZE_##NAME),   \
+  STRINGIFY_NAME(  \
+  DIAG_SIZE_##NAME) " is insufficient to contain all " \
+"diagnostics, it may need to be made larger in "   \
+"DiagnosticIDs.h.");
+VALIDATE_DIAG_SIZE(COMMON)
+VALIDATE_DIAG_SIZE(DRIVER)
+VALIDATE_DIAG_SIZE(FRONTEND)
+VALIDATE_DIAG_SIZE(SERIALIZATION)
+VALIDATE_DIAG_SIZE(LEX)
+VALIDATE_DIAG_SIZE(PARSE)
+VALIDATE_DIAG_SIZE(AST)
+VALIDATE_DIAG_SIZE(COMMENT)
+VALIDATE_DIAG_SIZE(SEMA)
+VALIDATE_DIAG_SIZE(ANALYSIS)
+#undef VALIDATE_DIAG_SIZE
+#undef STRINGIFY_NAME
+
 } // namespace anonymous
 
 static const StaticDiagInfoRec StaticDiagInfo[] = {
@@ -96,18 +119,6 @@
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
-#ifndef NDEBUG
-  static bool IsFirst = true; // So the check is only performed on first call.
-  if (IsFirst) {
-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
-
   // Out of bounds diag. Can't be in the table.
   using namespace diag;
   if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -26,19 +26,32 @@
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+  DIAG_START_COMMON=  0,
+  DIAG_START_DRIVER= DIAG_START_COMMON+ DIAG_SIZE_COMMON,
+  DIAG_START_FRONTEND  = DIAG_START_DRIVER+ DIAG_SIZE_DRIVER,
+  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND  + DIAG_SIZE_FRONTEND,
+  DIAG_START_LEX   = DIAG_START_SERIALIZATION + DIAG_SIZE_SERIALIZATION,
+  DIAG_START_PARSE = DIAG_START_LEX   + DIAG_SIZE_LEX,
+  DIAG_START_AST   = DIAG_START_PARSE + DIAG_SIZE_PARSE,
+  DIAG_START_COMMENT   = DIAG_START_AST   + DIAG_SIZE_AST,
+  DIAG_START_SEMA  = DIAG_START_COMMENT   + DIAG_SIZE_COMMENT,
+  DIAG_START_ANALYSIS  = DIAG_START_SEMA  + DIAG_SIZE_SEMA,
+  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS  + DIAG_SIZE_ANALYSIS
 };
 
 class CustomDiagInfo;
___
cfe-commits mailing list

[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/Basic/AllDiagnostics.h:37
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   
\
+  static_assert(   
\

I'd prefer it if we sank this into a .cpp file so that when it fails, it 
doesn't create a waterfall of colorful static_assert errors. :)


https://reviews.llvm.org/D37122



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 112651.
erichkeane added a comment.

Removed file due to git weirdness.


https://reviews.llvm.org/D37122

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/DiagnosticIDs.h
  lib/Basic/DiagnosticIDs.cpp

Index: lib/Basic/DiagnosticIDs.cpp
===
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -96,18 +96,6 @@
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
-#ifndef NDEBUG
-  static bool IsFirst = true; // So the check is only performed on first call.
-  if (IsFirst) {
-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
-
   // Out of bounds diag. Can't be in the table.
   using namespace diag;
   if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -26,19 +26,32 @@
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+  DIAG_START_COMMON=  0,
+  DIAG_START_DRIVER= DIAG_START_COMMON+ DIAG_SIZE_COMMON,
+  DIAG_START_FRONTEND  = DIAG_START_DRIVER+ DIAG_SIZE_DRIVER,
+  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND  + DIAG_SIZE_FRONTEND,
+  DIAG_START_LEX   = DIAG_START_SERIALIZATION + DIAG_SIZE_SERIALIZATION,
+  DIAG_START_PARSE = DIAG_START_LEX   + DIAG_SIZE_LEX,
+  DIAG_START_AST   = DIAG_START_PARSE + DIAG_SIZE_PARSE,
+  DIAG_START_COMMENT   = DIAG_START_AST   + DIAG_SIZE_AST,
+  DIAG_START_SEMA  = DIAG_START_COMMENT   + DIAG_SIZE_COMMENT,
+  DIAG_START_ANALYSIS  = DIAG_START_SEMA  + DIAG_SIZE_SEMA,
+  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS  + DIAG_SIZE_ANALYSIS
 };
 
 class CustomDiagInfo;
Index: include/clang/Basic/AllDiagnostics.h
===
--- include/clang/Basic/AllDiagnostics.h
+++ include/clang/Basic/AllDiagnostics.h
@@ -32,6 +32,29 @@
 public:
   enum { Size = SizeOfStr };
 };
+
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   \
+  static_assert(   \
+  static_cast(diag::NUM_BUILTIN_##NAME##_DIAGNOSTICS) <  \
+  static_cast(diag::DIAG_START_##NAME) + \
+  static_cast(diag::DIAG_SIZE_##NAME),   \
+  STRINGIFY_NAME(  \
+  DIAG_SIZE_##NAME) " is insufficient to contain all " \
+"diagnostics, it may need to be made larger in "   \
+"DiagnosticIDs.h.");
+VALIDATE_DIAG_SIZE(COMMON)
+VALIDATE_DIAG_SIZE(DRIVER)
+VALIDATE_DIAG_SIZE(FRONTEND)
+VALIDATE_DIAG_SIZE(SERIALIZATION)
+VALIDATE_DIAG_SIZE(LEX)
+VALIDATE_DIAG_SIZE(PARSE)
+VALIDATE_DIAG_SIZE(AST)
+VALIDATE_DIAG_SIZE(COMMENT)
+VALIDATE_DIAG_SIZE(SEMA)
+VALIDATE_DIAG_SIZE(ANALYSIS)
+#undef VALIDATE_DIAG_SIZE
+#undef STRINGIFY_NAME
 } // 

[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D37122#852018, @rnk wrote:

> In https://reviews.llvm.org/D37122#851978, @erichkeane wrote:
>
> > Ugg... disregard the system-header-line-directive-ms-lineendings.c issue, 
> > I'm going to try to figure that out
>
>
> Yeah, I'm seeing issues with that as well. I'm not sure what's up.


I'm trying to research it... Some people (Stephen Hines & I) are having this 
issue with the git mirror, but others (CraigT) are not for some reason.  There 
is a cfe-dev discussion started by Stephen, but I've really got no idea whats 
wrong.


https://reviews.llvm.org/D37122



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D37122#851978, @erichkeane wrote:

> Ugg... disregard the system-header-line-directive-ms-lineendings.c issue, I'm 
> going to try to figure that out


Yeah, I'm seeing issues with that as well. I'm not sure what's up.


https://reviews.llvm.org/D37122



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ugg... disregard the system-header-line-directive-ms-lineendings.c issue, I'm 
going to try to figure that out


https://reviews.llvm.org/D37122



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

Diagnostic Categories are fairly annoying, and are only enforced
by a runtime-debug-only assert.  This puts in a touch more work
to get this all done at compile-time with static asserts.


https://reviews.llvm.org/D37122

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/DiagnosticIDs.h
  lib/Basic/DiagnosticIDs.cpp
  test/Frontend/system-header-line-directive-ms-lineendings.c

Index: test/Frontend/system-header-line-directive-ms-lineendings.c
===
--- test/Frontend/system-header-line-directive-ms-lineendings.c
+++ test/Frontend/system-header-line-directive-ms-lineendings.c
@@ -1,21 +1,21 @@
-// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s
-#include 
-#include 
-
-#include "line-directive.h"
-
-// This tests that the line numbers for the current file are correctly outputted
-// for the include-file-completed test case.  
-
-// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
-// CHECK: # 1 "{{.*}}noline.h" 1 3
-// CHECK: foo();
-// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
-// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
-//  The "3" below indicates that "foo.h" is considered a system header.
-// CHECK: # 1 "foo.h" 3
-// CHECK: foo();
-// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
-// CHECK: # 1 "{{.*}}line-directive.h" 1
-// CHECK: # 10 "foo.h"{{$}}
-// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly outputted
+// for the include-file-completed test case.  
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
Index: lib/Basic/DiagnosticIDs.cpp
===
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -96,18 +96,6 @@
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
-#ifndef NDEBUG
-  static bool IsFirst = true; // So the check is only performed on first call.
-  if (IsFirst) {
-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
-
   // Out of bounds diag. Can't be in the table.
   using namespace diag;
   if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -26,19 +26,32 @@
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+