blob: 1c68375f3cdd1d9be3bfdba255858a53d89fbdaa [file] [log] [blame]
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +00001//===--- DiagnosticIDs.cpp - Diagnostic IDs Handling ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Diagnostic IDs-related interfaces.
11//
12//===----------------------------------------------------------------------===//
13
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000014#include "clang/Basic/DiagnosticIDs.h"
David Blaikie6c448862012-02-15 21:58:34 +000015#include "clang/Basic/AllDiagnostics.h"
John McCall923cd572011-06-15 21:46:43 +000016#include "clang/Basic/DiagnosticCategories.h"
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000017#include "clang/Basic/SourceManager.h"
David Majnemercfaa5522013-07-20 07:15:15 +000018#include "llvm/ADT/STLExtras.h"
Stephen Hines651f13c2014-04-23 16:59:28 -070019#include "llvm/ADT/SmallVector.h"
David Blaikie9fe8c742011-09-23 05:35:21 +000020#include "llvm/Support/ErrorHandling.h"
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000021#include <map>
22using namespace clang;
23
24//===----------------------------------------------------------------------===//
25// Builtin Diagnostic information
26//===----------------------------------------------------------------------===//
27
28namespace {
29
30// Diagnostic classes.
31enum {
32 CLASS_NOTE = 0x01,
Stephen Hines651f13c2014-04-23 16:59:28 -070033 CLASS_REMARK = 0x02,
34 CLASS_WARNING = 0x03,
35 CLASS_EXTENSION = 0x04,
36 CLASS_ERROR = 0x05
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000037};
38
39struct StaticDiagInfoRec {
Craig Topper8bfffa52013-07-21 21:56:18 +000040 uint16_t DiagID;
Stephen Hinesc568f1e2014-07-21 00:47:37 -070041 unsigned DefaultSeverity : 3;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000042 unsigned Class : 3;
Richard Smith3347b492013-11-12 02:41:45 +000043 unsigned SFINAE : 2;
Daniel Dunbar4213df32011-09-29 00:34:06 +000044 unsigned WarnNoWerror : 1;
45 unsigned WarnShowInSystemHeader : 1;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000046 unsigned Category : 5;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000047
Benjamin Kramerd49cb202012-02-15 20:57:03 +000048 uint16_t OptionGroupIndex;
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +000049
50 uint16_t DescriptionLen;
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +000051 const char *DescriptionStr;
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +000052
Benjamin Kramerd49cb202012-02-15 20:57:03 +000053 unsigned getOptionGroupIndex() const {
54 return OptionGroupIndex;
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +000055 }
56
Chris Lattner5f9e2722011-07-23 10:55:15 +000057 StringRef getDescription() const {
58 return StringRef(DescriptionStr, DescriptionLen);
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +000059 }
Douglas Gregor7d2b8c12011-04-15 22:04:17 +000060
Stephen Hines176edba2014-12-01 14:53:08 -080061 diag::Flavor getFlavor() const {
62 return Class == CLASS_REMARK ? diag::Flavor::Remark
63 : diag::Flavor::WarningOrError;
64 }
65
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000066 bool operator<(const StaticDiagInfoRec &RHS) const {
67 return DiagID < RHS.DiagID;
68 }
69};
70
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +000071} // namespace anonymous
72
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000073static const StaticDiagInfoRec StaticDiagInfo[] = {
Stephen Hinesc568f1e2014-07-21 00:47:37 -070074#define DIAG(ENUM, CLASS, DEFAULT_SEVERITY, DESC, GROUP, SFINAE, NOWERROR, \
75 SHOWINSYSHEADER, CATEGORY) \
76 { \
77 diag::ENUM, DEFAULT_SEVERITY, CLASS, DiagnosticIDs::SFINAE, NOWERROR, \
78 SHOWINSYSHEADER, CATEGORY, GROUP, STR_SIZE(DESC, uint16_t), DESC \
79 } \
80 ,
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000081#include "clang/Basic/DiagnosticCommonKinds.inc"
82#include "clang/Basic/DiagnosticDriverKinds.inc"
83#include "clang/Basic/DiagnosticFrontendKinds.inc"
Chandler Carrutha2398d72011-12-09 00:02:23 +000084#include "clang/Basic/DiagnosticSerializationKinds.inc"
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000085#include "clang/Basic/DiagnosticLexKinds.inc"
86#include "clang/Basic/DiagnosticParseKinds.inc"
87#include "clang/Basic/DiagnosticASTKinds.inc"
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000088#include "clang/Basic/DiagnosticCommentKinds.inc"
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000089#include "clang/Basic/DiagnosticSemaKinds.inc"
90#include "clang/Basic/DiagnosticAnalysisKinds.inc"
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000091#undef DIAG
Douglas Gregor7d2b8c12011-04-15 22:04:17 +000092};
93
David Majnemercfaa5522013-07-20 07:15:15 +000094static const unsigned StaticDiagInfoSize = llvm::array_lengthof(StaticDiagInfo);
Douglas Gregor7d2b8c12011-04-15 22:04:17 +000095
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000096/// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
97/// or null if the ID is invalid.
98static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +000099 // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
100#ifndef NDEBUG
Craig Toppercbfb8d72013-07-21 18:58:40 +0000101 static bool IsFirst = true; // So the check is only performed on first call.
102 if (IsFirst) {
103 for (unsigned i = 1; i != StaticDiagInfoSize; ++i) {
104 assert(StaticDiagInfo[i-1].DiagID != StaticDiagInfo[i].DiagID &&
105 "Diag ID conflict, the enums at the start of clang::diag (in "
106 "DiagnosticIDs.h) probably need to be increased");
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000107
Craig Toppercbfb8d72013-07-21 18:58:40 +0000108 assert(StaticDiagInfo[i-1] < StaticDiagInfo[i] &&
109 "Improperly sorted diag info");
110 }
111 IsFirst = false;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000112 }
113#endif
114
Benjamin Kramera07b59e2012-12-11 18:00:22 +0000115 // Out of bounds diag. Can't be in the table.
116 using namespace diag;
David Majnemercfaa5522013-07-20 07:15:15 +0000117 if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700118 return nullptr;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000119
Benjamin Kramera07b59e2012-12-11 18:00:22 +0000120 // Compute the index of the requested diagnostic in the static table.
Stephen Hines651f13c2014-04-23 16:59:28 -0700121 // 1. Add the number of diagnostics in each category preceding the
Benjamin Kramera07b59e2012-12-11 18:00:22 +0000122 // diagnostic and of the category the diagnostic is in. This gives us
123 // the offset of the category in the table.
124 // 2. Subtract the number of IDs in each category from our ID. This gives us
125 // the offset of the diagnostic in the category.
126 // This is cheaper than a binary search on the table as it doesn't touch
127 // memory at all.
128 unsigned Offset = 0;
David Majnemercfaa5522013-07-20 07:15:15 +0000129 unsigned ID = DiagID - DIAG_START_COMMON - 1;
Benjamin Kramera07b59e2012-12-11 18:00:22 +0000130#define CATEGORY(NAME, PREV) \
131 if (DiagID > DIAG_START_##NAME) { \
Argyrios Kyrtzidis35abfcd2013-01-02 22:26:07 +0000132 Offset += NUM_BUILTIN_##PREV##_DIAGNOSTICS - DIAG_START_##PREV - 1; \
133 ID -= DIAG_START_##NAME - DIAG_START_##PREV; \
Benjamin Kramera07b59e2012-12-11 18:00:22 +0000134 }
135CATEGORY(DRIVER, COMMON)
136CATEGORY(FRONTEND, DRIVER)
137CATEGORY(SERIALIZATION, FRONTEND)
138CATEGORY(LEX, SERIALIZATION)
139CATEGORY(PARSE, LEX)
140CATEGORY(AST, PARSE)
141CATEGORY(COMMENT, AST)
142CATEGORY(SEMA, COMMENT)
143CATEGORY(ANALYSIS, SEMA)
144#undef CATEGORY
Benjamin Kramera07b59e2012-12-11 18:00:22 +0000145
146 // Avoid out of bounds reads.
147 if (ID + Offset >= StaticDiagInfoSize)
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700148 return nullptr;
Benjamin Kramera07b59e2012-12-11 18:00:22 +0000149
Argyrios Kyrtzidis35abfcd2013-01-02 22:26:07 +0000150 assert(ID < StaticDiagInfoSize && Offset < StaticDiagInfoSize);
151
Benjamin Kramera07b59e2012-12-11 18:00:22 +0000152 const StaticDiagInfoRec *Found = &StaticDiagInfo[ID + Offset];
153 // If the diag id doesn't match we found a different diag, abort. This can
154 // happen when this function is called with an ID that points into a hole in
155 // the diagID space.
156 if (Found->DiagID != DiagID)
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700157 return nullptr;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000158 return Found;
159}
160
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700161static DiagnosticMapping GetDefaultDiagMapping(unsigned DiagID) {
162 DiagnosticMapping Info = DiagnosticMapping::Make(
163 diag::Severity::Fatal, /*IsUser=*/false, /*IsPragma=*/false);
Daniel Dunbar4213df32011-09-29 00:34:06 +0000164
Daniel Dunbara5e41332011-09-29 01:52:06 +0000165 if (const StaticDiagInfoRec *StaticInfo = GetDiagInfo(DiagID)) {
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700166 Info.setSeverity((diag::Severity)StaticInfo->DefaultSeverity);
Daniel Dunbara5e41332011-09-29 01:52:06 +0000167
168 if (StaticInfo->WarnNoWerror) {
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700169 assert(Info.getSeverity() == diag::Severity::Warning &&
Daniel Dunbar4213df32011-09-29 00:34:06 +0000170 "Unexpected mapping with no-Werror bit!");
Daniel Dunbara5e41332011-09-29 01:52:06 +0000171 Info.setNoWarningAsError(true);
Daniel Dunbar4213df32011-09-29 00:34:06 +0000172 }
Daniel Dunbar4213df32011-09-29 00:34:06 +0000173 }
Daniel Dunbara5e41332011-09-29 01:52:06 +0000174
175 return Info;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000176}
177
Douglas Gregor7d2b8c12011-04-15 22:04:17 +0000178/// getCategoryNumberForDiag - Return the category number that a specified
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000179/// DiagID belongs to, or 0 if no category.
180unsigned DiagnosticIDs::getCategoryNumberForDiag(unsigned DiagID) {
181 if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
182 return Info->Category;
183 return 0;
184}
185
Benjamin Kramerdbda5132011-06-13 18:38:45 +0000186namespace {
187 // The diagnostic category names.
188 struct StaticDiagCategoryRec {
189 const char *NameStr;
190 uint8_t NameLen;
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000191
Chris Lattner5f9e2722011-07-23 10:55:15 +0000192 StringRef getName() const {
193 return StringRef(NameStr, NameLen);
Benjamin Kramerdbda5132011-06-13 18:38:45 +0000194 }
195 };
196}
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000197
Daniel Dunbarba494c62011-09-29 01:42:25 +0000198// Unfortunately, the split between DiagnosticIDs and Diagnostic is not
199// particularly clean, but for now we just implement this method here so we can
200// access GetDefaultDiagMapping.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700201DiagnosticMapping &
202DiagnosticsEngine::DiagState::getOrAddMapping(diag::kind Diag) {
203 std::pair<iterator, bool> Result =
204 DiagMap.insert(std::make_pair(Diag, DiagnosticMapping()));
Daniel Dunbarba494c62011-09-29 01:42:25 +0000205
206 // Initialize the entry if we added it.
Daniel Dunbaraeacae52011-09-29 02:03:01 +0000207 if (Result.second)
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700208 Result.first->second = GetDefaultDiagMapping(Diag);
Daniel Dunbarba494c62011-09-29 01:42:25 +0000209
210 return Result.first->second;
211}
212
Benjamin Kramerdbda5132011-06-13 18:38:45 +0000213static const StaticDiagCategoryRec CategoryNameTable[] = {
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000214#define GET_CATEGORY_TABLE
John McCall923cd572011-06-15 21:46:43 +0000215#define CATEGORY(X, ENUM) { X, STR_SIZE(X, uint8_t) },
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000216#include "clang/Basic/DiagnosticGroups.inc"
217#undef GET_CATEGORY_TABLE
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700218 { nullptr, 0 }
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000219};
220
221/// getNumberOfCategories - Return the number of categories
222unsigned DiagnosticIDs::getNumberOfCategories() {
Craig Topperb9602322013-07-15 03:38:40 +0000223 return llvm::array_lengthof(CategoryNameTable) - 1;
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000224}
225
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000226/// getCategoryNameFromID - Given a category ID, return the name of the
227/// category, an empty string if CategoryID is zero, or null if CategoryID is
228/// invalid.
Chris Lattner5f9e2722011-07-23 10:55:15 +0000229StringRef DiagnosticIDs::getCategoryNameFromID(unsigned CategoryID) {
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000230 if (CategoryID >= getNumberOfCategories())
Chris Lattner5f9e2722011-07-23 10:55:15 +0000231 return StringRef();
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000232 return CategoryNameTable[CategoryID].getName();
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000233}
234
235
236
Richard Smith3347b492013-11-12 02:41:45 +0000237DiagnosticIDs::SFINAEResponse
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000238DiagnosticIDs::getDiagnosticSFINAEResponse(unsigned DiagID) {
Richard Smith3347b492013-11-12 02:41:45 +0000239 if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
240 return static_cast<DiagnosticIDs::SFINAEResponse>(Info->SFINAE);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000241 return SFINAE_Report;
242}
243
Douglas Gregor7d2b8c12011-04-15 22:04:17 +0000244/// getBuiltinDiagClass - Return the class field of the diagnostic.
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000245///
246static unsigned getBuiltinDiagClass(unsigned DiagID) {
247 if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
248 return Info->Class;
249 return ~0U;
250}
251
252//===----------------------------------------------------------------------===//
253// Custom Diagnostic information
254//===----------------------------------------------------------------------===//
255
256namespace clang {
257 namespace diag {
258 class CustomDiagInfo {
259 typedef std::pair<DiagnosticIDs::Level, std::string> DiagDesc;
260 std::vector<DiagDesc> DiagInfo;
261 std::map<DiagDesc, unsigned> DiagIDs;
262 public:
263
264 /// getDescription - Return the description of the specified custom
265 /// diagnostic.
Chris Lattner5f9e2722011-07-23 10:55:15 +0000266 StringRef getDescription(unsigned DiagID) const {
Stephen Hines176edba2014-12-01 14:53:08 -0800267 assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() &&
Stefanus Du Toitfc093362013-03-01 21:41:22 +0000268 "Invalid diagnostic ID");
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000269 return DiagInfo[DiagID-DIAG_UPPER_LIMIT].second;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000270 }
271
272 /// getLevel - Return the level of the specified custom diagnostic.
273 DiagnosticIDs::Level getLevel(unsigned DiagID) const {
Stephen Hines176edba2014-12-01 14:53:08 -0800274 assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() &&
Stefanus Du Toitfc093362013-03-01 21:41:22 +0000275 "Invalid diagnostic ID");
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000276 return DiagInfo[DiagID-DIAG_UPPER_LIMIT].first;
277 }
278
Chris Lattner5f9e2722011-07-23 10:55:15 +0000279 unsigned getOrCreateDiagID(DiagnosticIDs::Level L, StringRef Message,
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000280 DiagnosticIDs &Diags) {
281 DiagDesc D(L, Message);
282 // Check to see if it already exists.
283 std::map<DiagDesc, unsigned>::iterator I = DiagIDs.lower_bound(D);
284 if (I != DiagIDs.end() && I->first == D)
285 return I->second;
286
287 // If not, assign a new ID.
288 unsigned ID = DiagInfo.size()+DIAG_UPPER_LIMIT;
289 DiagIDs.insert(std::make_pair(D, ID));
290 DiagInfo.push_back(D);
291 return ID;
292 }
293 };
294
295 } // end diag namespace
296} // end clang namespace
297
298
299//===----------------------------------------------------------------------===//
300// Common Diagnostic implementation
301//===----------------------------------------------------------------------===//
302
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700303DiagnosticIDs::DiagnosticIDs() { CustomDiagInfo = nullptr; }
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000304
305DiagnosticIDs::~DiagnosticIDs() {
306 delete CustomDiagInfo;
307}
308
309/// getCustomDiagID - Return an ID for a diagnostic with the specified message
Stefanus Du Toitfc093362013-03-01 21:41:22 +0000310/// and level. If this is the first request for this diagnostic, it is
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000311/// registered and created, otherwise the existing ID is returned.
Stephen Hines651f13c2014-04-23 16:59:28 -0700312///
313/// \param FormatString A fixed diagnostic format string that will be hashed and
314/// mapped to a unique DiagID.
315unsigned DiagnosticIDs::getCustomDiagID(Level L, StringRef FormatString) {
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700316 if (!CustomDiagInfo)
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000317 CustomDiagInfo = new diag::CustomDiagInfo();
Stephen Hines651f13c2014-04-23 16:59:28 -0700318 return CustomDiagInfo->getOrCreateDiagID(L, FormatString, *this);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000319}
320
321
322/// isBuiltinWarningOrExtension - Return true if the unmapped diagnostic
323/// level of the specified diagnostic ID is a Warning or Extension.
324/// This only works on builtin diagnostics, not custom ones, and is not legal to
325/// call on NOTEs.
326bool DiagnosticIDs::isBuiltinWarningOrExtension(unsigned DiagID) {
327 return DiagID < diag::DIAG_UPPER_LIMIT &&
328 getBuiltinDiagClass(DiagID) != CLASS_ERROR;
329}
330
331/// \brief Determine whether the given built-in diagnostic ID is a
332/// Note.
333bool DiagnosticIDs::isBuiltinNote(unsigned DiagID) {
334 return DiagID < diag::DIAG_UPPER_LIMIT &&
335 getBuiltinDiagClass(DiagID) == CLASS_NOTE;
336}
337
338/// isBuiltinExtensionDiag - Determine whether the given built-in diagnostic
339/// ID is for an extension of some sort. This also returns EnabledByDefault,
340/// which is set to indicate whether the diagnostic is ignored by default (in
341/// which case -pedantic enables it) or treated as a warning/error by default.
342///
343bool DiagnosticIDs::isBuiltinExtensionDiag(unsigned DiagID,
344 bool &EnabledByDefault) {
345 if (DiagID >= diag::DIAG_UPPER_LIMIT ||
346 getBuiltinDiagClass(DiagID) != CLASS_EXTENSION)
347 return false;
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700348
Daniel Dunbara5e41332011-09-29 01:52:06 +0000349 EnabledByDefault =
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700350 GetDefaultDiagMapping(DiagID).getSeverity() != diag::Severity::Ignored;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000351 return true;
352}
353
Daniel Dunbar76101cf2011-09-29 01:01:08 +0000354bool DiagnosticIDs::isDefaultMappingAsError(unsigned DiagID) {
355 if (DiagID >= diag::DIAG_UPPER_LIMIT)
356 return false;
357
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700358 return GetDefaultDiagMapping(DiagID).getSeverity() == diag::Severity::Error;
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700359}
360
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000361/// getDescription - Given a diagnostic ID, return a description of the
362/// issue.
Chris Lattner5f9e2722011-07-23 10:55:15 +0000363StringRef DiagnosticIDs::getDescription(unsigned DiagID) const {
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000364 if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000365 return Info->getDescription();
Stephen Hines176edba2014-12-01 14:53:08 -0800366 assert(CustomDiagInfo && "Invalid CustomDiagInfo");
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000367 return CustomDiagInfo->getDescription(DiagID);
368}
369
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700370static DiagnosticIDs::Level toLevel(diag::Severity SV) {
371 switch (SV) {
372 case diag::Severity::Ignored:
373 return DiagnosticIDs::Ignored;
374 case diag::Severity::Remark:
375 return DiagnosticIDs::Remark;
376 case diag::Severity::Warning:
377 return DiagnosticIDs::Warning;
378 case diag::Severity::Error:
379 return DiagnosticIDs::Error;
380 case diag::Severity::Fatal:
381 return DiagnosticIDs::Fatal;
382 }
383 llvm_unreachable("unexpected severity");
384}
385
David Blaikied6471f72011-09-25 23:23:43 +0000386/// getDiagnosticLevel - Based on the way the client configured the
387/// DiagnosticsEngine object, classify the specified diagnostic ID into a Level,
388/// by consumable the DiagnosticClient.
Argyrios Kyrtzidis08274082010-12-15 18:44:22 +0000389DiagnosticIDs::Level
390DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc,
Daniel Dunbar1656aae2011-09-29 01:20:28 +0000391 const DiagnosticsEngine &Diag) const {
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000392 // Handle custom diagnostics, which cannot be mapped.
Stephen Hines176edba2014-12-01 14:53:08 -0800393 if (DiagID >= diag::DIAG_UPPER_LIMIT) {
394 assert(CustomDiagInfo && "Invalid CustomDiagInfo");
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000395 return CustomDiagInfo->getLevel(DiagID);
Stephen Hines176edba2014-12-01 14:53:08 -0800396 }
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000397
398 unsigned DiagClass = getBuiltinDiagClass(DiagID);
Jordan Rosec6d64a22012-07-11 16:50:36 +0000399 if (DiagClass == CLASS_NOTE) return DiagnosticIDs::Note;
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700400 return toLevel(getDiagnosticSeverity(DiagID, Loc, Diag));
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000401}
402
Argyrios Kyrtzidis08274082010-12-15 18:44:22 +0000403/// \brief Based on the way the client configured the Diagnostic
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000404/// object, classify the specified diagnostic ID into a Level, consumable by
405/// the DiagnosticClient.
Argyrios Kyrtzidis08274082010-12-15 18:44:22 +0000406///
407/// \param Loc The source location we are interested in finding out the
408/// diagnostic state. Can be null in order to query the latest state.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700409diag::Severity
410DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
411 const DiagnosticsEngine &Diag) const {
412 assert(getBuiltinDiagClass(DiagID) != CLASS_NOTE);
413
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000414 // Specific non-error diagnostics may be mapped to various levels from ignored
415 // to error. Errors can only be mapped to fatal.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700416 diag::Severity Result = diag::Severity::Fatal;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000417
David Blaikied6471f72011-09-25 23:23:43 +0000418 DiagnosticsEngine::DiagStatePointsTy::iterator
Argyrios Kyrtzidis08274082010-12-15 18:44:22 +0000419 Pos = Diag.GetDiagStatePointForLoc(Loc);
David Blaikied6471f72011-09-25 23:23:43 +0000420 DiagnosticsEngine::DiagState *State = Pos->State;
Argyrios Kyrtzidis08274082010-12-15 18:44:22 +0000421
Daniel Dunbarba494c62011-09-29 01:42:25 +0000422 // Get the mapping information, or compute it lazily.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700423 DiagnosticMapping &Mapping = State->getOrAddMapping((diag::kind)DiagID);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000424
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700425 // TODO: Can a null severity really get here?
426 if (Mapping.getSeverity() != diag::Severity())
427 Result = Mapping.getSeverity();
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000428
Daniel Dunbarbe1aa412011-09-29 01:58:05 +0000429 // Upgrade ignored diagnostics if -Weverything is enabled.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700430 if (Diag.EnableAllWarnings && Result == diag::Severity::Ignored &&
Stephen Hines176edba2014-12-01 14:53:08 -0800431 !Mapping.isUser() && getBuiltinDiagClass(DiagID) != CLASS_REMARK)
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700432 Result = diag::Severity::Warning;
Daniel Dunbarbe1aa412011-09-29 01:58:05 +0000433
Bob Wilson18c407f2011-10-12 19:55:31 +0000434 // Ignore -pedantic diagnostics inside __extension__ blocks.
435 // (The diagnostics controlled by -pedantic are the extension diagnostics
436 // that are not enabled by default.)
Daniel Dunbarf3dee202011-11-28 22:19:36 +0000437 bool EnabledByDefault = false;
Bob Wilson18c407f2011-10-12 19:55:31 +0000438 bool IsExtensionDiag = isBuiltinExtensionDiag(DiagID, EnabledByDefault);
439 if (Diag.AllExtensionsSilenced && IsExtensionDiag && !EnabledByDefault)
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700440 return diag::Severity::Ignored;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000441
Daniel Dunbarbe1aa412011-09-29 01:58:05 +0000442 // For extension diagnostics that haven't been explicitly mapped, check if we
443 // should upgrade the diagnostic.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700444 if (IsExtensionDiag && !Mapping.isUser())
445 Result = std::max(Result, Diag.ExtBehavior);
Daniel Dunbarbe1aa412011-09-29 01:58:05 +0000446
447 // At this point, ignored errors can no longer be upgraded.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700448 if (Result == diag::Severity::Ignored)
Daniel Dunbarbe1aa412011-09-29 01:58:05 +0000449 return Result;
450
451 // Honor -w, which is lower in priority than pedantic-errors, but higher than
452 // -Werror.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700453 if (Result == diag::Severity::Warning && Diag.IgnoreAllWarnings)
454 return diag::Severity::Ignored;
Daniel Dunbarbe1aa412011-09-29 01:58:05 +0000455
456 // If -Werror is enabled, map warnings to errors unless explicitly disabled.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700457 if (Result == diag::Severity::Warning) {
458 if (Diag.WarningsAsErrors && !Mapping.hasNoWarningAsError())
459 Result = diag::Severity::Error;
Daniel Dunbarbe1aa412011-09-29 01:58:05 +0000460 }
461
462 // If -Wfatal-errors is enabled, map errors to fatal unless explicity
463 // disabled.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700464 if (Result == diag::Severity::Error) {
465 if (Diag.ErrorsAsFatal && !Mapping.hasNoErrorAsFatal())
466 Result = diag::Severity::Fatal;
Daniel Dunbarbe1aa412011-09-29 01:58:05 +0000467 }
468
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700469 // Custom diagnostics always are emitted in system headers.
470 bool ShowInSystemHeader =
471 !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader;
472
Daniel Dunbaraeacae52011-09-29 02:03:01 +0000473 // If we are in a system header, we ignore it. We look at the diagnostic class
474 // because we also want to ignore extensions and warnings in -Werror and
Argyrios Kyrtzidiscfdadfe2011-04-21 23:08:18 +0000475 // -pedantic-errors modes, which *map* warnings/extensions to errors.
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700476 if (Diag.SuppressSystemWarnings && !ShowInSystemHeader && Loc.isValid() &&
Argyrios Kyrtzidiscfdadfe2011-04-21 23:08:18 +0000477 Diag.getSourceManager().isInSystemHeader(
Chandler Carruth40278532011-07-25 16:49:02 +0000478 Diag.getSourceManager().getExpansionLoc(Loc)))
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700479 return diag::Severity::Ignored;
Argyrios Kyrtzidiscfdadfe2011-04-21 23:08:18 +0000480
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000481 return Result;
482}
483
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000484#define GET_DIAG_ARRAYS
485#include "clang/Basic/DiagnosticGroups.inc"
486#undef GET_DIAG_ARRAYS
487
Craig Topper46c8fca2013-08-29 06:06:18 +0000488namespace {
489 struct WarningOption {
490 uint16_t NameOffset;
491 uint16_t Members;
492 uint16_t SubGroups;
Craig Topper354f20a2013-08-29 05:18:04 +0000493
Craig Topper46c8fca2013-08-29 06:06:18 +0000494 // String is stored with a pascal-style length byte.
495 StringRef getName() const {
496 return StringRef(DiagGroupNames + NameOffset + 1,
497 DiagGroupNames[NameOffset]);
498 }
499 };
500}
Craig Topper354f20a2013-08-29 05:18:04 +0000501
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000502// Second the table of options, sorted by name for fast binary lookup.
503static const WarningOption OptionTable[] = {
504#define GET_DIAG_TABLE
505#include "clang/Basic/DiagnosticGroups.inc"
506#undef GET_DIAG_TABLE
507};
Craig Topperb9602322013-07-15 03:38:40 +0000508static const size_t OptionTableSize = llvm::array_lengthof(OptionTable);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000509
Craig Topper354f20a2013-08-29 05:18:04 +0000510static bool WarningOptionCompare(const WarningOption &LHS, StringRef RHS) {
511 return LHS.getName() < RHS;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000512}
513
Benjamin Kramerd49cb202012-02-15 20:57:03 +0000514/// getWarningOptionForDiag - Return the lowest-level warning option that
515/// enables the specified diagnostic. If there is no -Wfoo flag that controls
516/// the diagnostic, this returns null.
517StringRef DiagnosticIDs::getWarningOptionForDiag(unsigned DiagID) {
518 if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
519 return OptionTable[Info->getOptionGroupIndex()].getName();
520 return StringRef();
521}
522
Stephen Hines176edba2014-12-01 14:53:08 -0800523/// Return \c true if any diagnostics were found in this group, even if they
524/// were filtered out due to having the wrong flavor.
525static bool getDiagnosticsInGroup(diag::Flavor Flavor,
526 const WarningOption *Group,
Craig Topper46c8fca2013-08-29 06:06:18 +0000527 SmallVectorImpl<diag::kind> &Diags) {
Stephen Hines176edba2014-12-01 14:53:08 -0800528 // An empty group is considered to be a warning group: we have empty groups
529 // for GCC compatibility, and GCC does not have remarks.
530 if (!Group->Members && !Group->SubGroups)
531 return Flavor == diag::Flavor::Remark ? true : false;
532
533 bool NotFound = true;
534
Daniel Dunbar3f839462011-09-29 01:47:16 +0000535 // Add the members of the option diagnostic set.
Craig Topperb1aa16a2013-08-28 04:02:50 +0000536 const int16_t *Member = DiagArrays + Group->Members;
Stephen Hines176edba2014-12-01 14:53:08 -0800537 for (; *Member != -1; ++Member) {
538 if (GetDiagInfo(*Member)->getFlavor() == Flavor) {
539 NotFound = false;
540 Diags.push_back(*Member);
541 }
542 }
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000543
Daniel Dunbar3f839462011-09-29 01:47:16 +0000544 // Add the members of the subgroups.
Craig Topperb1aa16a2013-08-28 04:02:50 +0000545 const int16_t *SubGroups = DiagSubGroups + Group->SubGroups;
546 for (; *SubGroups != (int16_t)-1; ++SubGroups)
Stephen Hines176edba2014-12-01 14:53:08 -0800547 NotFound &= getDiagnosticsInGroup(Flavor, &OptionTable[(short)*SubGroups],
548 Diags);
549
550 return NotFound;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000551}
552
Stephen Hines176edba2014-12-01 14:53:08 -0800553bool
554DiagnosticIDs::getDiagnosticsInGroup(diag::Flavor Flavor, StringRef Group,
555 SmallVectorImpl<diag::kind> &Diags) const {
556 const WarningOption *Found = std::lower_bound(
557 OptionTable, OptionTable + OptionTableSize, Group, WarningOptionCompare);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000558 if (Found == OptionTable + OptionTableSize ||
Argyrios Kyrtzidis477aab62011-05-25 05:05:01 +0000559 Found->getName() != Group)
Daniel Dunbar3f839462011-09-29 01:47:16 +0000560 return true; // Option not found.
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000561
Stephen Hines176edba2014-12-01 14:53:08 -0800562 return ::getDiagnosticsInGroup(Flavor, Found, Diags);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000563}
564
Stephen Hines176edba2014-12-01 14:53:08 -0800565void DiagnosticIDs::getAllDiagnostics(diag::Flavor Flavor,
566 SmallVectorImpl<diag::kind> &Diags) const {
Argyrios Kyrtzidis11583c72012-01-27 06:15:43 +0000567 for (unsigned i = 0; i != StaticDiagInfoSize; ++i)
Stephen Hines176edba2014-12-01 14:53:08 -0800568 if (StaticDiagInfo[i].getFlavor() == Flavor)
569 Diags.push_back(StaticDiagInfo[i].DiagID);
Argyrios Kyrtzidis11583c72012-01-27 06:15:43 +0000570}
571
Stephen Hines176edba2014-12-01 14:53:08 -0800572StringRef DiagnosticIDs::getNearestOption(diag::Flavor Flavor,
573 StringRef Group) {
Benjamin Kramera70cb9d2011-11-14 23:30:34 +0000574 StringRef Best;
Benjamin Kramerdce63272011-11-15 12:26:39 +0000575 unsigned BestDistance = Group.size() + 1; // Sanity threshold.
Benjamin Kramera70cb9d2011-11-14 23:30:34 +0000576 for (const WarningOption *i = OptionTable, *e = OptionTable + OptionTableSize;
577 i != e; ++i) {
578 // Don't suggest ignored warning flags.
579 if (!i->Members && !i->SubGroups)
580 continue;
581
582 unsigned Distance = i->getName().edit_distance(Group, true, BestDistance);
Stephen Hines176edba2014-12-01 14:53:08 -0800583 if (Distance > BestDistance)
584 continue;
585
586 // Don't suggest groups that are not of this kind.
587 llvm::SmallVector<diag::kind, 8> Diags;
588 if (::getDiagnosticsInGroup(Flavor, i, Diags) || Diags.empty())
589 continue;
590
Benjamin Kramerdce63272011-11-15 12:26:39 +0000591 if (Distance == BestDistance) {
592 // Two matches with the same distance, don't prefer one over the other.
593 Best = "";
594 } else if (Distance < BestDistance) {
595 // This is a better match.
Benjamin Kramera70cb9d2011-11-14 23:30:34 +0000596 Best = i->getName();
597 BestDistance = Distance;
598 }
599 }
600
601 return Best;
602}
603
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000604/// ProcessDiag - This is the method used to report a diagnostic that is
605/// finally fully formed.
David Blaikied6471f72011-09-25 23:23:43 +0000606bool DiagnosticIDs::ProcessDiag(DiagnosticsEngine &Diag) const {
David Blaikie40847cf2011-09-26 01:18:08 +0000607 Diagnostic Info(&Diag);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000608
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000609 assert(Diag.getClient() && "DiagnosticClient not set!");
610
611 // Figure out the diagnostic level of this message.
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000612 unsigned DiagID = Info.getID();
Jordan Rosec6d64a22012-07-11 16:50:36 +0000613 DiagnosticIDs::Level DiagLevel
614 = getDiagnosticLevel(DiagID, Info.getLocation(), Diag);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000615
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700616 // Update counts for DiagnosticErrorTrap even if a fatal error occurred
617 // or diagnostics are suppressed.
618 if (DiagLevel >= DiagnosticIDs::Error) {
619 ++Diag.TrapNumErrorsOccurred;
620 if (isUnrecoverable(DiagID))
621 ++Diag.TrapNumUnrecoverableErrorsOccurred;
622 }
623
624 if (Diag.SuppressAllDiagnostics)
625 return false;
626
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000627 if (DiagLevel != DiagnosticIDs::Note) {
628 // Record that a fatal error occurred only when we see a second
629 // non-note diagnostic. This allows notes to be attached to the
630 // fatal error, but suppresses any diagnostics that follow those
631 // notes.
632 if (Diag.LastDiagLevel == DiagnosticIDs::Fatal)
633 Diag.FatalErrorOccurred = true;
634
635 Diag.LastDiagLevel = DiagLevel;
636 }
637
638 // If a fatal error has already been emitted, silence all subsequent
639 // diagnostics.
640 if (Diag.FatalErrorOccurred) {
641 if (DiagLevel >= DiagnosticIDs::Error &&
642 Diag.Client->IncludeInDiagnosticCounts()) {
643 ++Diag.NumErrors;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000644 }
645
646 return false;
647 }
648
649 // If the client doesn't care about this message, don't issue it. If this is
650 // a note and the last real diagnostic was ignored, ignore it too.
651 if (DiagLevel == DiagnosticIDs::Ignored ||
652 (DiagLevel == DiagnosticIDs::Note &&
653 Diag.LastDiagLevel == DiagnosticIDs::Ignored))
654 return false;
655
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000656 if (DiagLevel >= DiagnosticIDs::Error) {
Argyrios Kyrtzidisc0a575f2011-07-29 01:25:44 +0000657 if (isUnrecoverable(DiagID))
Douglas Gregor85bea972011-07-06 17:40:26 +0000658 Diag.UnrecoverableErrorOccurred = true;
Daniel Jasper1c84c682012-09-28 15:45:07 +0000659
DeLesley Hutchins12f37e42012-12-07 22:53:48 +0000660 // Warnings which have been upgraded to errors do not prevent compilation.
661 if (isDefaultMappingAsError(DiagID))
662 Diag.UncompilableErrorOccurred = true;
663
Daniel Jasper1c84c682012-09-28 15:45:07 +0000664 Diag.ErrorOccurred = true;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000665 if (Diag.Client->IncludeInDiagnosticCounts()) {
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000666 ++Diag.NumErrors;
667 }
668
Douglas Gregorf1d59482011-08-17 19:13:00 +0000669 // If we've emitted a lot of errors, emit a fatal error instead of it to
670 // stop a flood of bogus errors.
671 if (Diag.ErrorLimit && Diag.NumErrors > Diag.ErrorLimit &&
672 DiagLevel == DiagnosticIDs::Error) {
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000673 Diag.SetDelayedDiagnostic(diag::fatal_too_many_errors);
Douglas Gregorf1d59482011-08-17 19:13:00 +0000674 return false;
675 }
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000676 }
677
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000678 // Finally, report it.
Jordan Rosec6d64a22012-07-11 16:50:36 +0000679 EmitDiag(Diag, DiagLevel);
680 return true;
681}
682
683void DiagnosticIDs::EmitDiag(DiagnosticsEngine &Diag, Level DiagLevel) const {
684 Diagnostic Info(&Diag);
685 assert(DiagLevel != DiagnosticIDs::Ignored && "Cannot emit ignored diagnostics!");
686
David Blaikied6471f72011-09-25 23:23:43 +0000687 Diag.Client->HandleDiagnostic((DiagnosticsEngine::Level)DiagLevel, Info);
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000688 if (Diag.Client->IncludeInDiagnosticCounts()) {
689 if (DiagLevel == DiagnosticIDs::Warning)
690 ++Diag.NumWarnings;
691 }
692
693 Diag.CurDiagID = ~0U;
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000694}
John McCall923cd572011-06-15 21:46:43 +0000695
696bool DiagnosticIDs::isUnrecoverable(unsigned DiagID) const {
697 if (DiagID >= diag::DIAG_UPPER_LIMIT) {
Stephen Hines176edba2014-12-01 14:53:08 -0800698 assert(CustomDiagInfo && "Invalid CustomDiagInfo");
John McCall923cd572011-06-15 21:46:43 +0000699 // Custom diagnostics.
700 return CustomDiagInfo->getLevel(DiagID) >= DiagnosticIDs::Error;
701 }
702
703 // Only errors may be unrecoverable.
Douglas Gregor85bea972011-07-06 17:40:26 +0000704 if (getBuiltinDiagClass(DiagID) < CLASS_ERROR)
John McCall923cd572011-06-15 21:46:43 +0000705 return false;
706
707 if (DiagID == diag::err_unavailable ||
708 DiagID == diag::err_unavailable_message)
709 return false;
710
John McCallf85e1932011-06-15 23:02:42 +0000711 // Currently we consider all ARC errors as recoverable.
Ted Kremenekafdc21a2011-10-20 05:07:47 +0000712 if (isARCDiagnostic(DiagID))
John McCallf85e1932011-06-15 23:02:42 +0000713 return false;
714
John McCall923cd572011-06-15 21:46:43 +0000715 return true;
716}
Ted Kremenekafdc21a2011-10-20 05:07:47 +0000717
718bool DiagnosticIDs::isARCDiagnostic(unsigned DiagID) {
719 unsigned cat = getCategoryNumberForDiag(DiagID);
720 return DiagnosticIDs::getCategoryNameFromID(cat).startswith("ARC ");
721}