[PATCH] D13500: Improve helpfulness of assert message when number of diagnostics overflows number of available enum values.
Richard Barton via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 7 01:30:41 PDT 2015
richard.barton.arm created this revision.
richard.barton.arm added a reviewer: rafael.
richard.barton.arm added a subscriber: cfe-commits.
There are two asserts that can trigger if the number of diagnostic messages in a
kind overflows the number of available enums values. The one that fires if you
exceed this limit by one is helpful. The one that fires if you exceed it by more than
one is not as helpful. Combining the two makes sense I think.
http://reviews.llvm.org/D13500
Files:
lib/Basic/DiagnosticIDs.cpp
Index: lib/Basic/DiagnosticIDs.cpp
===================================================================
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -101,12 +101,9 @@
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 &&
+ 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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13500.36714.patch
Type: text/x-patch
Size: 768 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151007/dc4553d3/attachment-0001.bin>
More information about the cfe-commits
mailing list