[cfe-commits] r171421 - /cfe/trunk/lib/Basic/DiagnosticIDs.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Jan 2 14:26:13 PST 2013
Author: akirtzidis
Date: Wed Jan 2 16:26:07 2013
New Revision: 171421
URL: http://llvm.org/viewvc/llvm-project?rev=171421&view=rev
Log:
DiagnosticIds: Fix offset/ID calculation, no impact outside this code.
Patch by Will Dietz:
Minor touchup so the values of Offset/ID reflect their intention.
Previously, the sum (Offset+ID) was correct, but Offset/ID
individually were wrong.
Caught by investigating unsigned overflow reported by -fsanitize=integer.
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=171421&r1=171420&r2=171421&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Wed Jan 2 16:26:07 2013
@@ -125,8 +125,8 @@
#define DIAG_START_COMMON 0 // Sentinel value.
#define CATEGORY(NAME, PREV) \
if (DiagID > DIAG_START_##NAME) { \
- Offset += NUM_BUILTIN_##PREV##_DIAGNOSTICS - DIAG_START_##PREV; \
- ID -= DIAG_START_##NAME - DIAG_START_##PREV + 1; \
+ Offset += NUM_BUILTIN_##PREV##_DIAGNOSTICS - DIAG_START_##PREV - 1; \
+ ID -= DIAG_START_##NAME - DIAG_START_##PREV; \
}
CATEGORY(DRIVER, COMMON)
CATEGORY(FRONTEND, DRIVER)
@@ -144,6 +144,8 @@
if (ID + Offset >= StaticDiagInfoSize)
return 0;
+ assert(ID < StaticDiagInfoSize && Offset < StaticDiagInfoSize);
+
const StaticDiagInfoRec *Found = &StaticDiagInfo[ID + Offset];
// If the diag id doesn't match we found a different diag, abort. This can
// happen when this function is called with an ID that points into a hole in
More information about the cfe-commits
mailing list