blob: 6b7f732b3f0863a3314cf54e861afb39e68efa05 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- Diagnostic.cpp - C Language Family Diagnostic Handling -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Diagnostic-related interfaces.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Basic/Diagnostic.h"
Chris Lattner27ceb9d2009-04-15 07:01:18 +000015
16#include "clang/Lex/LexDiagnostic.h"
17#include "clang/Parse/ParseDiagnostic.h"
18#include "clang/AST/ASTDiagnostic.h"
19#include "clang/Sema/SemaDiagnostic.h"
20#include "clang/Frontend/FrontendDiagnostic.h"
21#include "clang/Analysis/AnalysisDiagnostic.h"
22#include "clang/Driver/DriverDiagnostic.h"
23
Chris Lattner43b628c2008-11-19 07:32:16 +000024#include "clang/Basic/IdentifierTable.h"
Reid Spencer5f016e22007-07-11 17:01:13 +000025#include "clang/Basic/SourceLocation.h"
Chris Lattnerf4c83962008-11-19 06:51:40 +000026#include "llvm/ADT/SmallVector.h"
Chris Lattner30bc9652008-11-19 07:22:31 +000027#include "llvm/ADT/StringExtras.h"
Chris Lattner182745a2007-12-02 01:09:57 +000028#include <vector>
29#include <map>
Chris Lattner87cf5ac2008-03-10 17:04:53 +000030#include <cstring>
Reid Spencer5f016e22007-07-11 17:01:13 +000031using namespace clang;
32
Chris Lattner182745a2007-12-02 01:09:57 +000033//===----------------------------------------------------------------------===//
34// Builtin Diagnostic information
35//===----------------------------------------------------------------------===//
36
Chris Lattner27ceb9d2009-04-15 07:01:18 +000037// DefaultDiagnosticMappings - This specifies the default mapping for each diag,
38// based on its kind. Yay for macros?
39
40struct DefaultMappingInfo {
41 unsigned DiagID : 14;
42 unsigned Mapping : 2;
43};
44
Chris Lattner27ceb9d2009-04-15 07:01:18 +000045static const DefaultMappingInfo DefaultMappings[] = {
Chris Lattner691f1ae2009-04-16 04:12:40 +000046#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC) { diag::ENUM, DEFAULT_MAPPING-1 },
Chris Lattner27ceb9d2009-04-15 07:01:18 +000047#include "clang/Basic/DiagnosticCommonKinds.inc"
48#include "clang/Basic/DiagnosticDriverKinds.inc"
49#include "clang/Basic/DiagnosticFrontendKinds.inc"
50#include "clang/Basic/DiagnosticLexKinds.inc"
51#include "clang/Basic/DiagnosticParseKinds.inc"
52#include "clang/Basic/DiagnosticASTKinds.inc"
53#include "clang/Basic/DiagnosticSemaKinds.inc"
54#include "clang/Basic/DiagnosticAnalysisKinds.inc"
55{ 0, 0 }
56};
Chris Lattner8a941e02009-04-15 16:56:26 +000057#undef DIAG
Chris Lattner27ceb9d2009-04-15 07:01:18 +000058
Chris Lattner691f1ae2009-04-16 04:12:40 +000059static unsigned GetDefaultDiagMapping(unsigned DiagID) {
60 // FIXME: Binary search.
61 for (unsigned i = 0, e = sizeof(DefaultMappings)/sizeof(DefaultMappings[0]);
62 i != e; ++i)
63 if (DefaultMappings[i].DiagID == DiagID)
64 return DefaultMappings[i].Mapping+1;
65 return diag::MAP_FATAL;
66}
67
68
Chris Lattner27ceb9d2009-04-15 07:01:18 +000069// Diagnostic classes.
Reid Spencer5f016e22007-07-11 17:01:13 +000070enum {
Chris Lattner8a941e02009-04-15 16:56:26 +000071 CLASS_NOTE = 0x01,
72 CLASS_WARNING = 0x02,
73 CLASS_EXTENSION = 0x03,
74 CLASS_ERROR = 0x04
Reid Spencer5f016e22007-07-11 17:01:13 +000075};
76
Chris Lattner27ceb9d2009-04-15 07:01:18 +000077/// DiagnosticClasses - The class for each diagnostic.
Chris Lattner4ac072a2009-04-15 16:44:12 +000078#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC) CLASS,
Chris Lattner27ceb9d2009-04-15 07:01:18 +000079static unsigned char DiagnosticClassesCommon[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +000080#include "clang/Basic/DiagnosticCommonKinds.inc"
Reid Spencer5f016e22007-07-11 17:01:13 +000081 0
82};
Chris Lattner27ceb9d2009-04-15 07:01:18 +000083static unsigned char DiagnosticClassesDriver[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +000084#include "clang/Basic/DiagnosticDriverKinds.inc"
Daniel Dunbar4ad4b3e2009-03-12 08:55:43 +000085 0
86};
Chris Lattner27ceb9d2009-04-15 07:01:18 +000087static unsigned char DiagnosticClassesFrontend[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +000088#include "clang/Basic/DiagnosticFrontendKinds.inc"
Daniel Dunbar50f4f462009-03-12 10:14:16 +000089 0
90};
Chris Lattner27ceb9d2009-04-15 07:01:18 +000091static unsigned char DiagnosticClassesLex[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +000092#include "clang/Basic/DiagnosticLexKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +000093 0
94};
Chris Lattner27ceb9d2009-04-15 07:01:18 +000095static unsigned char DiagnosticClassesParse[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +000096#include "clang/Basic/DiagnosticParseKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +000097 0
98};
Chris Lattner27ceb9d2009-04-15 07:01:18 +000099static unsigned char DiagnosticClassesAST[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000100#include "clang/Basic/DiagnosticASTKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000101 0
102};
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000103static unsigned char DiagnosticClassesSema[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000104#include "clang/Basic/DiagnosticSemaKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000105 0
106};
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000107static unsigned char DiagnosticClassesAnalysis[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000108#include "clang/Basic/DiagnosticAnalysisKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000109 0
110};
111#undef DIAG
Reid Spencer5f016e22007-07-11 17:01:13 +0000112
113/// getDiagClass - Return the class field of the diagnostic.
114///
Chris Lattner07506182007-11-30 22:53:43 +0000115static unsigned getBuiltinDiagClass(unsigned DiagID) {
Chris Lattner19e8e2c2009-01-29 17:46:13 +0000116 assert(DiagID < diag::DIAG_UPPER_LIMIT &&
Chris Lattner07506182007-11-30 22:53:43 +0000117 "Diagnostic ID out of range!");
Chris Lattnerfe526d22009-04-15 18:48:23 +0000118 unsigned char *Arr;
119 unsigned ArrSize;
120 if (DiagID <= diag::DIAG_START_DRIVER) {
121 DiagID -= 0;
122 Arr = DiagnosticClassesCommon;
123 ArrSize = sizeof(DiagnosticClassesCommon);
124 } else if (DiagID <= diag::DIAG_START_FRONTEND) {
125 DiagID -= diag::DIAG_START_DRIVER + 1;
126 Arr = DiagnosticClassesDriver;
127 ArrSize = sizeof(DiagnosticClassesDriver);
128 } else if (DiagID <= diag::DIAG_START_LEX) {
129 DiagID -= diag::DIAG_START_FRONTEND + 1;
130 Arr = DiagnosticClassesFrontend;
131 ArrSize = sizeof(DiagnosticClassesFrontend);
132 } else if (DiagID <= diag::DIAG_START_PARSE) {
133 DiagID -= diag::DIAG_START_LEX + 1;
134 Arr = DiagnosticClassesLex;
135 ArrSize = sizeof(DiagnosticClassesLex);
136 } else if (DiagID <= diag::DIAG_START_AST) {
137 DiagID -= diag::DIAG_START_PARSE + 1;
138 Arr = DiagnosticClassesParse;
139 ArrSize = sizeof(DiagnosticClassesParse);
140 } else if (DiagID <= diag::DIAG_START_SEMA) {
141 DiagID -= diag::DIAG_START_AST + 1;
142 Arr = DiagnosticClassesAST;
143 ArrSize = sizeof(DiagnosticClassesAST);
144
145 } else if (DiagID <= diag::DIAG_START_ANALYSIS) {
146 DiagID -= diag::DIAG_START_SEMA + 1;
147 Arr = DiagnosticClassesSema;
148 ArrSize = sizeof(DiagnosticClassesSema);
149 } else {
150 DiagID -= diag::DIAG_START_ANALYSIS + 1;
151 Arr = DiagnosticClassesAnalysis;
152 ArrSize = sizeof(DiagnosticClassesAnalysis);
153 }
154 return DiagID < ArrSize ? Arr[DiagID] : ~0U;
Reid Spencer5f016e22007-07-11 17:01:13 +0000155}
156
157/// DiagnosticText - An english message to print for the diagnostic. These
158/// should be localized.
Chris Lattner4ac072a2009-04-15 16:44:12 +0000159#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC) DESC,
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000160static const char * const DiagnosticTextCommon[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000161#include "clang/Basic/DiagnosticCommonKinds.inc"
Reid Spencer5f016e22007-07-11 17:01:13 +0000162 0
163};
Daniel Dunbar4ad4b3e2009-03-12 08:55:43 +0000164static const char * const DiagnosticTextDriver[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000165#include "clang/Basic/DiagnosticDriverKinds.inc"
Daniel Dunbar4ad4b3e2009-03-12 08:55:43 +0000166 0
167};
Daniel Dunbar50f4f462009-03-12 10:14:16 +0000168static const char * const DiagnosticTextFrontend[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000169#include "clang/Basic/DiagnosticFrontendKinds.inc"
Daniel Dunbar50f4f462009-03-12 10:14:16 +0000170 0
171};
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000172static const char * const DiagnosticTextLex[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000173#include "clang/Basic/DiagnosticLexKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000174 0
175};
176static const char * const DiagnosticTextParse[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000177#include "clang/Basic/DiagnosticParseKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000178 0
179};
180static const char * const DiagnosticTextAST[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000181#include "clang/Basic/DiagnosticASTKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000182 0
183};
184static const char * const DiagnosticTextSema[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000185#include "clang/Basic/DiagnosticSemaKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000186 0
187};
188static const char * const DiagnosticTextAnalysis[] = {
Sebastian Redl4d7a0892009-03-19 23:18:26 +0000189#include "clang/Basic/DiagnosticAnalysisKinds.inc"
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000190 0
191};
192#undef DIAG
Reid Spencer5f016e22007-07-11 17:01:13 +0000193
Chris Lattner182745a2007-12-02 01:09:57 +0000194//===----------------------------------------------------------------------===//
195// Custom Diagnostic information
196//===----------------------------------------------------------------------===//
197
198namespace clang {
199 namespace diag {
200 class CustomDiagInfo {
201 typedef std::pair<Diagnostic::Level, std::string> DiagDesc;
202 std::vector<DiagDesc> DiagInfo;
203 std::map<DiagDesc, unsigned> DiagIDs;
204 public:
205
206 /// getDescription - Return the description of the specified custom
207 /// diagnostic.
208 const char *getDescription(unsigned DiagID) const {
Chris Lattner88eccaf2009-01-29 06:55:46 +0000209 assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() &&
Chris Lattner182745a2007-12-02 01:09:57 +0000210 "Invalid diagnosic ID");
Chris Lattner88eccaf2009-01-29 06:55:46 +0000211 return DiagInfo[DiagID-DIAG_UPPER_LIMIT].second.c_str();
Chris Lattner182745a2007-12-02 01:09:57 +0000212 }
213
214 /// getLevel - Return the level of the specified custom diagnostic.
215 Diagnostic::Level getLevel(unsigned DiagID) const {
Chris Lattner88eccaf2009-01-29 06:55:46 +0000216 assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() &&
Chris Lattner182745a2007-12-02 01:09:57 +0000217 "Invalid diagnosic ID");
Chris Lattner88eccaf2009-01-29 06:55:46 +0000218 return DiagInfo[DiagID-DIAG_UPPER_LIMIT].first;
Chris Lattner182745a2007-12-02 01:09:57 +0000219 }
220
Chris Lattnera1f23cc2008-10-17 21:24:47 +0000221 unsigned getOrCreateDiagID(Diagnostic::Level L, const char *Message,
222 Diagnostic &Diags) {
Chris Lattner182745a2007-12-02 01:09:57 +0000223 DiagDesc D(L, Message);
224 // Check to see if it already exists.
225 std::map<DiagDesc, unsigned>::iterator I = DiagIDs.lower_bound(D);
226 if (I != DiagIDs.end() && I->first == D)
227 return I->second;
228
229 // If not, assign a new ID.
Chris Lattner88eccaf2009-01-29 06:55:46 +0000230 unsigned ID = DiagInfo.size()+DIAG_UPPER_LIMIT;
Chris Lattner182745a2007-12-02 01:09:57 +0000231 DiagIDs.insert(std::make_pair(D, ID));
232 DiagInfo.push_back(D);
Chris Lattnera1f23cc2008-10-17 21:24:47 +0000233
234 // If this is a warning, and all warnings are supposed to map to errors,
235 // insert the mapping now.
236 if (L == Diagnostic::Warning && Diags.getWarningsAsErrors())
237 Diags.setDiagnosticMapping((diag::kind)ID, diag::MAP_ERROR);
Chris Lattner182745a2007-12-02 01:09:57 +0000238 return ID;
239 }
240 };
241
242 } // end diag namespace
243} // end clang namespace
244
245
246//===----------------------------------------------------------------------===//
247// Common Diagnostic implementation
248//===----------------------------------------------------------------------===//
249
Chris Lattner3fdf4b02008-11-23 09:21:17 +0000250static void DummyArgToStringFn(Diagnostic::ArgumentKind AK, intptr_t QT,
251 const char *Modifier, unsigned ML,
252 const char *Argument, unsigned ArgLen,
Chris Lattner92dd3862009-02-19 23:53:20 +0000253 llvm::SmallVectorImpl<char> &Output,
254 void *Cookie) {
Chris Lattner3fdf4b02008-11-23 09:21:17 +0000255 const char *Str = "<can't format argument>";
Chris Lattner22caddc2008-11-23 09:13:29 +0000256 Output.append(Str, Str+strlen(Str));
257}
258
259
Ted Kremenekb4398aa2008-08-07 17:49:57 +0000260Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000261 AllExtensionsSilenced = 0;
Chris Lattner5b4681c2008-05-29 15:36:45 +0000262 IgnoreAllWarnings = false;
Reid Spencer5f016e22007-07-11 17:01:13 +0000263 WarningsAsErrors = false;
Daniel Dunbar2fe09972008-09-12 18:10:20 +0000264 SuppressSystemWarnings = false;
Reid Spencer5f016e22007-07-11 17:01:13 +0000265
266 ErrorOccurred = false;
Chris Lattner15221422009-02-06 04:16:02 +0000267 FatalErrorOccurred = false;
Reid Spencer5f016e22007-07-11 17:01:13 +0000268 NumDiagnostics = 0;
269 NumErrors = 0;
Chris Lattner182745a2007-12-02 01:09:57 +0000270 CustomDiagInfo = 0;
Chris Lattner3cbfe2c2008-11-22 00:59:29 +0000271 CurDiagID = ~0U;
Douglas Gregor525c4b02009-03-19 18:55:06 +0000272 LastDiagLevel = Ignored;
Chris Lattner22caddc2008-11-23 09:13:29 +0000273
Chris Lattner3fdf4b02008-11-23 09:21:17 +0000274 ArgToStringFn = DummyArgToStringFn;
Chris Lattner92dd3862009-02-19 23:53:20 +0000275 ArgToStringCookie = 0;
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000276
Chris Lattner691f1ae2009-04-16 04:12:40 +0000277 // Set all mappings to 'unset'.
278 memset(DiagMappings, 0, sizeof(DiagMappings));
Reid Spencer5f016e22007-07-11 17:01:13 +0000279}
280
Chris Lattner182745a2007-12-02 01:09:57 +0000281Diagnostic::~Diagnostic() {
282 delete CustomDiagInfo;
283}
284
285/// getCustomDiagID - Return an ID for a diagnostic with the specified message
286/// and level. If this is the first request for this diagnosic, it is
287/// registered and created, otherwise the existing ID is returned.
288unsigned Diagnostic::getCustomDiagID(Level L, const char *Message) {
289 if (CustomDiagInfo == 0)
290 CustomDiagInfo = new diag::CustomDiagInfo();
Chris Lattnera1f23cc2008-10-17 21:24:47 +0000291 return CustomDiagInfo->getOrCreateDiagID(L, Message, *this);
Chris Lattner182745a2007-12-02 01:09:57 +0000292}
293
294
Chris Lattnerf5d23282009-02-17 06:49:55 +0000295/// isBuiltinWarningOrExtension - Return true if the unmapped diagnostic
296/// level of the specified diagnostic ID is a Warning or Extension.
297/// This only works on builtin diagnostics, not custom ones, and is not legal to
298/// call on NOTEs.
299bool Diagnostic::isBuiltinWarningOrExtension(unsigned DiagID) {
Chris Lattner8a941e02009-04-15 16:56:26 +0000300 return DiagID < diag::DIAG_UPPER_LIMIT &&
301 getBuiltinDiagClass(DiagID) != CLASS_ERROR;
Reid Spencer5f016e22007-07-11 17:01:13 +0000302}
303
Douglas Gregoree1828a2009-03-10 18:03:33 +0000304/// \brief Determine whether the given built-in diagnostic ID is a
305/// Note.
306bool Diagnostic::isBuiltinNote(unsigned DiagID) {
Chris Lattner8a941e02009-04-15 16:56:26 +0000307 return DiagID < diag::DIAG_UPPER_LIMIT &&
308 getBuiltinDiagClass(DiagID) == CLASS_NOTE;
Douglas Gregoree1828a2009-03-10 18:03:33 +0000309}
310
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000311/// isBuiltinExtensionDiag - Determine whether the given built-in diagnostic
312/// ID is for an extension of some sort.
313///
314bool Diagnostic::isBuiltinExtensionDiag(unsigned DiagID) {
Chris Lattner8a941e02009-04-15 16:56:26 +0000315 return DiagID < diag::DIAG_UPPER_LIMIT &&
316 getBuiltinDiagClass(DiagID) == CLASS_EXTENSION;
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000317}
318
Reid Spencer5f016e22007-07-11 17:01:13 +0000319
320/// getDescription - Given a diagnostic ID, return a description of the
321/// issue.
Chris Lattner0a14eee2008-11-18 07:04:44 +0000322const char *Diagnostic::getDescription(unsigned DiagID) const {
Daniel Dunbar4ad4b3e2009-03-12 08:55:43 +0000323 if (DiagID < diag::DIAG_START_DRIVER)
Chris Lattnerf5d23282009-02-17 06:49:55 +0000324 return DiagnosticTextCommon[DiagID];
Daniel Dunbar50f4f462009-03-12 10:14:16 +0000325 else if (DiagID < diag::DIAG_START_FRONTEND)
Daniel Dunbar4ad4b3e2009-03-12 08:55:43 +0000326 return DiagnosticTextDriver[DiagID - diag::DIAG_START_DRIVER - 1];
Daniel Dunbar50f4f462009-03-12 10:14:16 +0000327 else if (DiagID < diag::DIAG_START_LEX)
328 return DiagnosticTextFrontend[DiagID - diag::DIAG_START_FRONTEND - 1];
Chris Lattnerf5d23282009-02-17 06:49:55 +0000329 else if (DiagID < diag::DIAG_START_PARSE)
330 return DiagnosticTextLex[DiagID - diag::DIAG_START_LEX - 1];
331 else if (DiagID < diag::DIAG_START_AST)
332 return DiagnosticTextParse[DiagID - diag::DIAG_START_PARSE - 1];
333 else if (DiagID < diag::DIAG_START_SEMA)
334 return DiagnosticTextAST[DiagID - diag::DIAG_START_AST - 1];
335 else if (DiagID < diag::DIAG_START_ANALYSIS)
336 return DiagnosticTextSema[DiagID - diag::DIAG_START_SEMA - 1];
337 else if (DiagID < diag::DIAG_UPPER_LIMIT)
338 return DiagnosticTextAnalysis[DiagID - diag::DIAG_START_ANALYSIS - 1];
Chris Lattner20c6b3b2009-01-27 18:30:58 +0000339 return CustomDiagInfo->getDescription(DiagID);
Reid Spencer5f016e22007-07-11 17:01:13 +0000340}
341
342/// getDiagnosticLevel - Based on the way the client configured the Diagnostic
343/// object, classify the specified diagnostic ID into a Level, consumable by
344/// the DiagnosticClient.
345Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
Chris Lattner182745a2007-12-02 01:09:57 +0000346 // Handle custom diagnostics, which cannot be mapped.
Chris Lattner19e8e2c2009-01-29 17:46:13 +0000347 if (DiagID >= diag::DIAG_UPPER_LIMIT)
Chris Lattner182745a2007-12-02 01:09:57 +0000348 return CustomDiagInfo->getLevel(DiagID);
Chris Lattner07506182007-11-30 22:53:43 +0000349
350 unsigned DiagClass = getBuiltinDiagClass(DiagID);
Chris Lattner8a941e02009-04-15 16:56:26 +0000351 assert(DiagClass != CLASS_NOTE && "Cannot get diagnostic level of a note!");
Chris Lattnerf5d23282009-02-17 06:49:55 +0000352 return getDiagnosticLevel(DiagID, DiagClass);
353}
354
355/// getDiagnosticLevel - Based on the way the client configured the Diagnostic
356/// object, classify the specified diagnostic ID into a Level, consumable by
357/// the DiagnosticClient.
358Diagnostic::Level
359Diagnostic::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass) const {
Reid Spencer5f016e22007-07-11 17:01:13 +0000360 // Specific non-error diagnostics may be mapped to various levels from ignored
Chris Lattnerf5d23282009-02-17 06:49:55 +0000361 // to error. Errors can only be mapped to fatal.
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000362 Diagnostic::Level Result = Diagnostic::Fatal;
Chris Lattner691f1ae2009-04-16 04:12:40 +0000363
364 // Get the mapping information, if unset, compute it lazily.
365 unsigned MappingInfo = getDiagnosticMappingInfo((diag::kind)DiagID);
366 if (MappingInfo == 0) {
367 MappingInfo = GetDefaultDiagMapping(DiagID);
368 setDiagnosticMappingInternal(DiagID, MappingInfo, false);
369 }
370
371 switch (MappingInfo & 7) {
372 default: assert(0 && "Unknown mapping!");
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000373 case diag::MAP_IGNORE:
374 return Diagnostic::Ignored;
375 case diag::MAP_ERROR:
376 Result = Diagnostic::Error;
377 break;
378 case diag::MAP_FATAL:
379 Result = Diagnostic::Fatal;
380 break;
381 case diag::MAP_WARNING:
382 // If warnings are globally mapped to ignore or error, do it.
Chris Lattner5b4681c2008-05-29 15:36:45 +0000383 if (IgnoreAllWarnings)
384 return Diagnostic::Ignored;
Chris Lattner2b07d8f2009-04-16 04:32:54 +0000385
386 Result = Diagnostic::Warning;
387 if (WarningsAsErrors)
388 Result = Diagnostic::Error;
389 break;
390 case diag::MAP_WARNING_NO_WERROR:
391 // Diagnostics specified with -Wno-error=foo should be set to warnings, but
392 // not be adjusted by -Werror or -pedantic-errors.
393 Result = Diagnostic::Warning;
394
395 // If warnings are globally mapped to ignore or error, do it.
396 if (IgnoreAllWarnings)
397 return Diagnostic::Ignored;
398
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000399 break;
Chris Lattner5b4681c2008-05-29 15:36:45 +0000400 }
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000401
402 // Okay, we're about to return this as a "diagnostic to emit" one last check:
403 // if this is any sort of extension warning, and if we're in an __extension__
404 // block, silence it.
405 if (AllExtensionsSilenced && isBuiltinExtensionDiag(DiagID))
406 return Diagnostic::Ignored;
Reid Spencer5f016e22007-07-11 17:01:13 +0000407
Chris Lattner27ceb9d2009-04-15 07:01:18 +0000408 return Result;
Reid Spencer5f016e22007-07-11 17:01:13 +0000409}
410
Chris Lattner0a14eee2008-11-18 07:04:44 +0000411/// ProcessDiag - This is the method used to report a diagnostic that is
412/// finally fully formed.
Chris Lattner3cbfe2c2008-11-22 00:59:29 +0000413void Diagnostic::ProcessDiag() {
414 DiagnosticInfo Info(this);
Douglas Gregor525c4b02009-03-19 18:55:06 +0000415
Reid Spencer5f016e22007-07-11 17:01:13 +0000416 // Figure out the diagnostic level of this message.
Chris Lattnerf5d23282009-02-17 06:49:55 +0000417 Diagnostic::Level DiagLevel;
418 unsigned DiagID = Info.getID();
Reid Spencer5f016e22007-07-11 17:01:13 +0000419
Chris Lattnerf5d23282009-02-17 06:49:55 +0000420 // ShouldEmitInSystemHeader - True if this diagnostic should be produced even
421 // in a system header.
422 bool ShouldEmitInSystemHeader;
423
424 if (DiagID >= diag::DIAG_UPPER_LIMIT) {
425 // Handle custom diagnostics, which cannot be mapped.
426 DiagLevel = CustomDiagInfo->getLevel(DiagID);
427
428 // Custom diagnostics always are emitted in system headers.
429 ShouldEmitInSystemHeader = true;
430 } else {
431 // Get the class of the diagnostic. If this is a NOTE, map it onto whatever
432 // the diagnostic level was for the previous diagnostic so that it is
433 // filtered the same as the previous diagnostic.
434 unsigned DiagClass = getBuiltinDiagClass(DiagID);
Chris Lattner8a941e02009-04-15 16:56:26 +0000435 if (DiagClass == CLASS_NOTE) {
Chris Lattnerf5d23282009-02-17 06:49:55 +0000436 DiagLevel = Diagnostic::Note;
437 ShouldEmitInSystemHeader = false; // extra consideration is needed
438 } else {
439 // If this is not an error and we are in a system header, we ignore it.
440 // Check the original Diag ID here, because we also want to ignore
441 // extensions and warnings in -Werror and -pedantic-errors modes, which
442 // *map* warnings/extensions to errors.
Chris Lattner8a941e02009-04-15 16:56:26 +0000443 ShouldEmitInSystemHeader = DiagClass == CLASS_ERROR;
Chris Lattnerf5d23282009-02-17 06:49:55 +0000444
445 DiagLevel = getDiagnosticLevel(DiagID, DiagClass);
446 }
447 }
448
Douglas Gregor525c4b02009-03-19 18:55:06 +0000449 if (DiagLevel != Diagnostic::Note) {
450 // Record that a fatal error occurred only when we see a second
451 // non-note diagnostic. This allows notes to be attached to the
452 // fatal error, but suppresses any diagnostics that follow those
453 // notes.
454 if (LastDiagLevel == Diagnostic::Fatal)
455 FatalErrorOccurred = true;
456
Chris Lattnerf5d23282009-02-17 06:49:55 +0000457 LastDiagLevel = DiagLevel;
Douglas Gregor525c4b02009-03-19 18:55:06 +0000458 }
459
460 // If a fatal error has already been emitted, silence all subsequent
461 // diagnostics.
462 if (FatalErrorOccurred)
463 return;
464
Chris Lattnerf5d23282009-02-17 06:49:55 +0000465 // If the client doesn't care about this message, don't issue it. If this is
466 // a note and the last real diagnostic was ignored, ignore it too.
467 if (DiagLevel == Diagnostic::Ignored ||
468 (DiagLevel == Diagnostic::Note && LastDiagLevel == Diagnostic::Ignored))
Reid Spencer5f016e22007-07-11 17:01:13 +0000469 return;
Nico Weber7bfaaae2008-08-10 19:59:06 +0000470
Chris Lattnerf5d23282009-02-17 06:49:55 +0000471 // If this diagnostic is in a system header and is not a clang error, suppress
472 // it.
473 if (SuppressSystemWarnings && !ShouldEmitInSystemHeader &&
Chris Lattner0a14eee2008-11-18 07:04:44 +0000474 Info.getLocation().isValid() &&
Chris Lattnerf5d23282009-02-17 06:49:55 +0000475 Info.getLocation().getSpellingLoc().isInSystemHeader() &&
Chris Lattner336f26b2009-02-17 06:52:20 +0000476 (DiagLevel != Diagnostic::Note || LastDiagLevel == Diagnostic::Ignored)) {
477 LastDiagLevel = Diagnostic::Ignored;
Chris Lattner7097d912008-02-03 09:00:04 +0000478 return;
Chris Lattner336f26b2009-02-17 06:52:20 +0000479 }
Chris Lattnerf5d23282009-02-17 06:49:55 +0000480
Reid Spencer5f016e22007-07-11 17:01:13 +0000481 if (DiagLevel >= Diagnostic::Error) {
482 ErrorOccurred = true;
Chris Lattner0a14eee2008-11-18 07:04:44 +0000483 ++NumErrors;
Reid Spencer5f016e22007-07-11 17:01:13 +0000484 }
Chris Lattnerf5d23282009-02-17 06:49:55 +0000485
Reid Spencer5f016e22007-07-11 17:01:13 +0000486 // Finally, report it.
Chris Lattner0a14eee2008-11-18 07:04:44 +0000487 Client->HandleDiagnostic(DiagLevel, Info);
Ted Kremenekcabe6682009-01-23 20:28:53 +0000488 if (Client->IncludeInDiagnosticCounts()) ++NumDiagnostics;
Douglas Gregoree1828a2009-03-10 18:03:33 +0000489
Douglas Gregoree1828a2009-03-10 18:03:33 +0000490 CurDiagID = ~0U;
Reid Spencer5f016e22007-07-11 17:01:13 +0000491}
492
Nico Weber7bfaaae2008-08-10 19:59:06 +0000493
Reid Spencer5f016e22007-07-11 17:01:13 +0000494DiagnosticClient::~DiagnosticClient() {}
Nico Weber7bfaaae2008-08-10 19:59:06 +0000495
Chris Lattnerf4c83962008-11-19 06:51:40 +0000496
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000497/// ModifierIs - Return true if the specified modifier matches specified string.
498template <std::size_t StrLen>
499static bool ModifierIs(const char *Modifier, unsigned ModifierLen,
500 const char (&Str)[StrLen]) {
501 return StrLen-1 == ModifierLen && !memcmp(Modifier, Str, StrLen-1);
502}
503
504/// HandleSelectModifier - Handle the integer 'select' modifier. This is used
505/// like this: %select{foo|bar|baz}2. This means that the integer argument
506/// "%2" has a value from 0-2. If the value is 0, the diagnostic prints 'foo'.
507/// If the value is 1, it prints 'bar'. If it has the value 2, it prints 'baz'.
508/// This is very useful for certain classes of variant diagnostics.
509static void HandleSelectModifier(unsigned ValNo,
510 const char *Argument, unsigned ArgumentLen,
511 llvm::SmallVectorImpl<char> &OutStr) {
512 const char *ArgumentEnd = Argument+ArgumentLen;
513
514 // Skip over 'ValNo' |'s.
515 while (ValNo) {
516 const char *NextVal = std::find(Argument, ArgumentEnd, '|');
517 assert(NextVal != ArgumentEnd && "Value for integer select modifier was"
518 " larger than the number of options in the diagnostic string!");
519 Argument = NextVal+1; // Skip this string.
520 --ValNo;
521 }
522
523 // Get the end of the value. This is either the } or the |.
524 const char *EndPtr = std::find(Argument, ArgumentEnd, '|');
525 // Add the value to the output string.
526 OutStr.append(Argument, EndPtr);
527}
528
529/// HandleIntegerSModifier - Handle the integer 's' modifier. This adds the
530/// letter 's' to the string if the value is not 1. This is used in cases like
531/// this: "you idiot, you have %4 parameter%s4!".
532static void HandleIntegerSModifier(unsigned ValNo,
533 llvm::SmallVectorImpl<char> &OutStr) {
534 if (ValNo != 1)
535 OutStr.push_back('s');
536}
537
538
Sebastian Redle4c452c2008-11-22 13:44:36 +0000539/// PluralNumber - Parse an unsigned integer and advance Start.
Chris Lattnerd2aa7c92009-04-15 17:13:42 +0000540static unsigned PluralNumber(const char *&Start, const char *End) {
Sebastian Redle4c452c2008-11-22 13:44:36 +0000541 // Programming 101: Parse a decimal number :-)
542 unsigned Val = 0;
543 while (Start != End && *Start >= '0' && *Start <= '9') {
544 Val *= 10;
545 Val += *Start - '0';
546 ++Start;
547 }
548 return Val;
549}
550
551/// TestPluralRange - Test if Val is in the parsed range. Modifies Start.
Chris Lattnerd2aa7c92009-04-15 17:13:42 +0000552static bool TestPluralRange(unsigned Val, const char *&Start, const char *End) {
Sebastian Redle4c452c2008-11-22 13:44:36 +0000553 if (*Start != '[') {
554 unsigned Ref = PluralNumber(Start, End);
555 return Ref == Val;
556 }
557
558 ++Start;
559 unsigned Low = PluralNumber(Start, End);
560 assert(*Start == ',' && "Bad plural expression syntax: expected ,");
561 ++Start;
562 unsigned High = PluralNumber(Start, End);
563 assert(*Start == ']' && "Bad plural expression syntax: expected )");
564 ++Start;
565 return Low <= Val && Val <= High;
566}
567
568/// EvalPluralExpr - Actual expression evaluator for HandlePluralModifier.
Chris Lattnerd2aa7c92009-04-15 17:13:42 +0000569static bool EvalPluralExpr(unsigned ValNo, const char *Start, const char *End) {
Sebastian Redle4c452c2008-11-22 13:44:36 +0000570 // Empty condition?
571 if (*Start == ':')
572 return true;
573
574 while (1) {
575 char C = *Start;
576 if (C == '%') {
577 // Modulo expression
578 ++Start;
579 unsigned Arg = PluralNumber(Start, End);
580 assert(*Start == '=' && "Bad plural expression syntax: expected =");
581 ++Start;
582 unsigned ValMod = ValNo % Arg;
583 if (TestPluralRange(ValMod, Start, End))
584 return true;
585 } else {
Sebastian Redle2065322008-11-27 07:28:14 +0000586 assert((C == '[' || (C >= '0' && C <= '9')) &&
Sebastian Redle4c452c2008-11-22 13:44:36 +0000587 "Bad plural expression syntax: unexpected character");
588 // Range expression
589 if (TestPluralRange(ValNo, Start, End))
590 return true;
591 }
592
593 // Scan for next or-expr part.
594 Start = std::find(Start, End, ',');
595 if(Start == End)
596 break;
597 ++Start;
598 }
599 return false;
600}
601
602/// HandlePluralModifier - Handle the integer 'plural' modifier. This is used
603/// for complex plural forms, or in languages where all plurals are complex.
604/// The syntax is: %plural{cond1:form1|cond2:form2|:form3}, where condn are
605/// conditions that are tested in order, the form corresponding to the first
606/// that applies being emitted. The empty condition is always true, making the
607/// last form a default case.
608/// Conditions are simple boolean expressions, where n is the number argument.
609/// Here are the rules.
610/// condition := expression | empty
611/// empty := -> always true
612/// expression := numeric [',' expression] -> logical or
613/// numeric := range -> true if n in range
614/// | '%' number '=' range -> true if n % number in range
615/// range := number
616/// | '[' number ',' number ']' -> ranges are inclusive both ends
617///
618/// Here are some examples from the GNU gettext manual written in this form:
619/// English:
620/// {1:form0|:form1}
621/// Latvian:
622/// {0:form2|%100=11,%10=0,%10=[2,9]:form1|:form0}
623/// Gaeilge:
624/// {1:form0|2:form1|:form2}
625/// Romanian:
626/// {1:form0|0,%100=[1,19]:form1|:form2}
627/// Lithuanian:
628/// {%10=0,%100=[10,19]:form2|%10=1:form0|:form1}
629/// Russian (requires repeated form):
630/// {%100=[11,14]:form2|%10=1:form0|%10=[2,4]:form1|:form2}
631/// Slovak
632/// {1:form0|[2,4]:form1|:form2}
633/// Polish (requires repeated form):
634/// {1:form0|%100=[10,20]:form2|%10=[2,4]:form1|:form2}
635static void HandlePluralModifier(unsigned ValNo,
636 const char *Argument, unsigned ArgumentLen,
637 llvm::SmallVectorImpl<char> &OutStr)
638{
639 const char *ArgumentEnd = Argument + ArgumentLen;
640 while (1) {
641 assert(Argument < ArgumentEnd && "Plural expression didn't match.");
642 const char *ExprEnd = Argument;
643 while (*ExprEnd != ':') {
644 assert(ExprEnd != ArgumentEnd && "Plural missing expression end");
645 ++ExprEnd;
646 }
647 if (EvalPluralExpr(ValNo, Argument, ExprEnd)) {
648 Argument = ExprEnd + 1;
649 ExprEnd = std::find(Argument, ArgumentEnd, '|');
650 OutStr.append(Argument, ExprEnd);
651 return;
652 }
653 Argument = std::find(Argument, ArgumentEnd - 1, '|') + 1;
654 }
655}
656
657
Chris Lattnerf4c83962008-11-19 06:51:40 +0000658/// FormatDiagnostic - Format this diagnostic into a string, substituting the
659/// formal arguments into the %0 slots. The result is appended onto the Str
660/// array.
661void DiagnosticInfo::
662FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
663 const char *DiagStr = getDiags()->getDescription(getID());
664 const char *DiagEnd = DiagStr+strlen(DiagStr);
Nico Weber7bfaaae2008-08-10 19:59:06 +0000665
Chris Lattnerf4c83962008-11-19 06:51:40 +0000666 while (DiagStr != DiagEnd) {
667 if (DiagStr[0] != '%') {
668 // Append non-%0 substrings to Str if we have one.
669 const char *StrEnd = std::find(DiagStr, DiagEnd, '%');
670 OutStr.append(DiagStr, StrEnd);
671 DiagStr = StrEnd;
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000672 continue;
Chris Lattnerf4c83962008-11-19 06:51:40 +0000673 } else if (DiagStr[1] == '%') {
674 OutStr.push_back('%'); // %% -> %.
675 DiagStr += 2;
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000676 continue;
677 }
678
679 // Skip the %.
680 ++DiagStr;
681
682 // This must be a placeholder for a diagnostic argument. The format for a
683 // placeholder is one of "%0", "%modifier0", or "%modifier{arguments}0".
684 // The digit is a number from 0-9 indicating which argument this comes from.
685 // The modifier is a string of digits from the set [-a-z]+, arguments is a
686 // brace enclosed string.
687 const char *Modifier = 0, *Argument = 0;
688 unsigned ModifierLen = 0, ArgumentLen = 0;
689
690 // Check to see if we have a modifier. If so eat it.
691 if (!isdigit(DiagStr[0])) {
692 Modifier = DiagStr;
693 while (DiagStr[0] == '-' ||
694 (DiagStr[0] >= 'a' && DiagStr[0] <= 'z'))
695 ++DiagStr;
696 ModifierLen = DiagStr-Modifier;
Chris Lattnerf4c83962008-11-19 06:51:40 +0000697
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000698 // If we have an argument, get it next.
699 if (DiagStr[0] == '{') {
700 ++DiagStr; // Skip {.
701 Argument = DiagStr;
702
703 for (; DiagStr[0] != '}'; ++DiagStr)
704 assert(DiagStr[0] && "Mismatched {}'s in diagnostic string!");
705 ArgumentLen = DiagStr-Argument;
706 ++DiagStr; // Skip }.
Chris Lattnerf4c83962008-11-19 06:51:40 +0000707 }
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000708 }
709
710 assert(isdigit(*DiagStr) && "Invalid format for argument in diagnostic");
Chris Lattner22caddc2008-11-23 09:13:29 +0000711 unsigned ArgNo = *DiagStr++ - '0';
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000712
Chris Lattner22caddc2008-11-23 09:13:29 +0000713 switch (getArgKind(ArgNo)) {
Chris Lattner08631c52008-11-23 21:45:46 +0000714 // ---- STRINGS ----
Chris Lattner3cbfe2c2008-11-22 00:59:29 +0000715 case Diagnostic::ak_std_string: {
Chris Lattner22caddc2008-11-23 09:13:29 +0000716 const std::string &S = getArgStdStr(ArgNo);
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000717 assert(ModifierLen == 0 && "No modifiers for strings yet");
718 OutStr.append(S.begin(), S.end());
719 break;
720 }
Chris Lattner3cbfe2c2008-11-22 00:59:29 +0000721 case Diagnostic::ak_c_string: {
Chris Lattner22caddc2008-11-23 09:13:29 +0000722 const char *S = getArgCStr(ArgNo);
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000723 assert(ModifierLen == 0 && "No modifiers for strings yet");
724 OutStr.append(S, S + strlen(S));
725 break;
726 }
Chris Lattner08631c52008-11-23 21:45:46 +0000727 // ---- INTEGERS ----
Chris Lattner3cbfe2c2008-11-22 00:59:29 +0000728 case Diagnostic::ak_sint: {
Chris Lattner22caddc2008-11-23 09:13:29 +0000729 int Val = getArgSInt(ArgNo);
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000730
731 if (ModifierIs(Modifier, ModifierLen, "select")) {
732 HandleSelectModifier((unsigned)Val, Argument, ArgumentLen, OutStr);
733 } else if (ModifierIs(Modifier, ModifierLen, "s")) {
734 HandleIntegerSModifier(Val, OutStr);
Sebastian Redle4c452c2008-11-22 13:44:36 +0000735 } else if (ModifierIs(Modifier, ModifierLen, "plural")) {
736 HandlePluralModifier((unsigned)Val, Argument, ArgumentLen, OutStr);
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000737 } else {
738 assert(ModifierLen == 0 && "Unknown integer modifier");
Chris Lattner30bc9652008-11-19 07:22:31 +0000739 // FIXME: Optimize
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000740 std::string S = llvm::itostr(Val);
Chris Lattner30bc9652008-11-19 07:22:31 +0000741 OutStr.append(S.begin(), S.end());
Chris Lattner30bc9652008-11-19 07:22:31 +0000742 }
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000743 break;
744 }
Chris Lattner3cbfe2c2008-11-22 00:59:29 +0000745 case Diagnostic::ak_uint: {
Chris Lattner22caddc2008-11-23 09:13:29 +0000746 unsigned Val = getArgUInt(ArgNo);
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000747
748 if (ModifierIs(Modifier, ModifierLen, "select")) {
749 HandleSelectModifier(Val, Argument, ArgumentLen, OutStr);
750 } else if (ModifierIs(Modifier, ModifierLen, "s")) {
751 HandleIntegerSModifier(Val, OutStr);
Sebastian Redle4c452c2008-11-22 13:44:36 +0000752 } else if (ModifierIs(Modifier, ModifierLen, "plural")) {
753 HandlePluralModifier((unsigned)Val, Argument, ArgumentLen, OutStr);
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000754 } else {
755 assert(ModifierLen == 0 && "Unknown integer modifier");
756
Chris Lattner30bc9652008-11-19 07:22:31 +0000757 // FIXME: Optimize
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000758 std::string S = llvm::utostr_32(Val);
Chris Lattner30bc9652008-11-19 07:22:31 +0000759 OutStr.append(S.begin(), S.end());
Chris Lattner30bc9652008-11-19 07:22:31 +0000760 }
Chris Lattner22caddc2008-11-23 09:13:29 +0000761 break;
Chris Lattneraf7ae4e2008-11-21 07:50:02 +0000762 }
Chris Lattner08631c52008-11-23 21:45:46 +0000763 // ---- NAMES and TYPES ----
764 case Diagnostic::ak_identifierinfo: {
Chris Lattner08631c52008-11-23 21:45:46 +0000765 const IdentifierInfo *II = getArgIdentifier(ArgNo);
766 assert(ModifierLen == 0 && "No modifiers for strings yet");
Chris Lattnerd0344a42009-02-19 23:45:49 +0000767 OutStr.push_back('\'');
Chris Lattner08631c52008-11-23 21:45:46 +0000768 OutStr.append(II->getName(), II->getName() + II->getLength());
769 OutStr.push_back('\'');
770 break;
771 }
Chris Lattner22caddc2008-11-23 09:13:29 +0000772 case Diagnostic::ak_qualtype:
Chris Lattner011bb4e2008-11-23 20:28:15 +0000773 case Diagnostic::ak_declarationname:
Douglas Gregor47b9a1c2009-02-04 17:27:36 +0000774 case Diagnostic::ak_nameddecl:
Chris Lattner3fdf4b02008-11-23 09:21:17 +0000775 getDiags()->ConvertArgToString(getArgKind(ArgNo), getRawArg(ArgNo),
776 Modifier, ModifierLen,
777 Argument, ArgumentLen, OutStr);
Chris Lattner22caddc2008-11-23 09:13:29 +0000778 break;
Nico Weber7bfaaae2008-08-10 19:59:06 +0000779 }
780 }
Nico Weber7bfaaae2008-08-10 19:59:06 +0000781}
Ted Kremenekcabe6682009-01-23 20:28:53 +0000782
783/// IncludeInDiagnosticCounts - This method (whose default implementation
784/// returns true) indicates whether the diagnostics handled by this
785/// DiagnosticClient should be included in the number of diagnostics
786/// reported by Diagnostic.
787bool DiagnosticClient::IncludeInDiagnosticCounts() const { return true; }