Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- Diagnostic.cpp - C Language Family Diagnostic Handling -----------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the Diagnostic-related interfaces. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/Basic/Diagnostic.h" |
Chris Lattner | 43b628c | 2008-11-19 07:32:16 +0000 | [diff] [blame] | 15 | #include "clang/Basic/IdentifierTable.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 16 | #include "clang/Basic/SourceLocation.h" |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/SmallVector.h" |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/StringExtras.h" |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 19 | #include <vector> |
| 20 | #include <map> |
Chris Lattner | 87cf5ac | 2008-03-10 17:04:53 +0000 | [diff] [blame] | 21 | #include <cstring> |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 22 | using namespace clang; |
| 23 | |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 24 | //===----------------------------------------------------------------------===// |
| 25 | // Builtin Diagnostic information |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 28 | /// Flag values for diagnostics. |
| 29 | enum { |
| 30 | // Diagnostic classes. |
| 31 | NOTE = 0x01, |
| 32 | WARNING = 0x02, |
| 33 | EXTENSION = 0x03, |
Daniel Dunbar | 4489fe1 | 2008-08-05 00:07:51 +0000 | [diff] [blame] | 34 | EXTWARN = 0x04, |
| 35 | ERROR = 0x05, |
Chris Lattner | da0cbc1 | 2009-02-05 22:47:05 +0000 | [diff] [blame] | 36 | FATAL = 0x06, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 37 | class_mask = 0x07 |
| 38 | }; |
| 39 | |
| 40 | /// DiagnosticFlags - A set of flags, or'd together, that describe the |
| 41 | /// diagnostic. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 42 | #define DIAG(ENUM,FLAGS,DESC) FLAGS, |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 43 | static unsigned char DiagnosticFlagsCommon[] = { |
| 44 | #include "clang/Basic/DiagnosticCommonKinds.def" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 45 | 0 |
| 46 | }; |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 47 | static unsigned char DiagnosticFlagsLex[] = { |
| 48 | #include "clang/Basic/DiagnosticLexKinds.def" |
| 49 | 0 |
| 50 | }; |
| 51 | static unsigned char DiagnosticFlagsParse[] = { |
| 52 | #include "clang/Basic/DiagnosticParseKinds.def" |
| 53 | 0 |
| 54 | }; |
| 55 | static unsigned char DiagnosticFlagsAST[] = { |
| 56 | #include "clang/Basic/DiagnosticASTKinds.def" |
| 57 | 0 |
| 58 | }; |
| 59 | static unsigned char DiagnosticFlagsSema[] = { |
| 60 | #include "clang/Basic/DiagnosticSemaKinds.def" |
| 61 | 0 |
| 62 | }; |
| 63 | static unsigned char DiagnosticFlagsAnalysis[] = { |
| 64 | #include "clang/Basic/DiagnosticAnalysisKinds.def" |
| 65 | 0 |
| 66 | }; |
| 67 | #undef DIAG |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 68 | |
| 69 | /// getDiagClass - Return the class field of the diagnostic. |
| 70 | /// |
Chris Lattner | 0750618 | 2007-11-30 22:53:43 +0000 | [diff] [blame] | 71 | static unsigned getBuiltinDiagClass(unsigned DiagID) { |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 72 | assert(DiagID < diag::DIAG_UPPER_LIMIT && |
Chris Lattner | 0750618 | 2007-11-30 22:53:43 +0000 | [diff] [blame] | 73 | "Diagnostic ID out of range!"); |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 74 | unsigned res; |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 75 | if (DiagID < diag::DIAG_START_LEX) |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 76 | res = DiagnosticFlagsCommon[DiagID]; |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 77 | else if (DiagID < diag::DIAG_START_PARSE) |
| 78 | res = DiagnosticFlagsLex[DiagID - diag::DIAG_START_LEX - 1]; |
| 79 | else if (DiagID < diag::DIAG_START_AST) |
| 80 | res = DiagnosticFlagsParse[DiagID - diag::DIAG_START_PARSE - 1]; |
| 81 | else if (DiagID < diag::DIAG_START_SEMA) |
| 82 | res = DiagnosticFlagsAST[DiagID - diag::DIAG_START_AST - 1]; |
| 83 | else if (DiagID < diag::DIAG_START_ANALYSIS) |
| 84 | res = DiagnosticFlagsSema[DiagID - diag::DIAG_START_SEMA - 1]; |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 85 | else |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 86 | res = DiagnosticFlagsAnalysis[DiagID - diag::DIAG_START_ANALYSIS - 1]; |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 87 | return res & class_mask; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /// DiagnosticText - An english message to print for the diagnostic. These |
| 91 | /// should be localized. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 92 | #define DIAG(ENUM,FLAGS,DESC) DESC, |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 93 | static const char * const DiagnosticTextCommon[] = { |
| 94 | #include "clang/Basic/DiagnosticCommonKinds.def" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 95 | 0 |
| 96 | }; |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 97 | static const char * const DiagnosticTextLex[] = { |
| 98 | #include "clang/Basic/DiagnosticLexKinds.def" |
| 99 | 0 |
| 100 | }; |
| 101 | static const char * const DiagnosticTextParse[] = { |
| 102 | #include "clang/Basic/DiagnosticParseKinds.def" |
| 103 | 0 |
| 104 | }; |
| 105 | static const char * const DiagnosticTextAST[] = { |
| 106 | #include "clang/Basic/DiagnosticASTKinds.def" |
| 107 | 0 |
| 108 | }; |
| 109 | static const char * const DiagnosticTextSema[] = { |
| 110 | #include "clang/Basic/DiagnosticSemaKinds.def" |
| 111 | 0 |
| 112 | }; |
| 113 | static const char * const DiagnosticTextAnalysis[] = { |
| 114 | #include "clang/Basic/DiagnosticAnalysisKinds.def" |
| 115 | 0 |
| 116 | }; |
| 117 | #undef DIAG |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 118 | |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 119 | //===----------------------------------------------------------------------===// |
| 120 | // Custom Diagnostic information |
| 121 | //===----------------------------------------------------------------------===// |
| 122 | |
| 123 | namespace clang { |
| 124 | namespace diag { |
| 125 | class CustomDiagInfo { |
| 126 | typedef std::pair<Diagnostic::Level, std::string> DiagDesc; |
| 127 | std::vector<DiagDesc> DiagInfo; |
| 128 | std::map<DiagDesc, unsigned> DiagIDs; |
| 129 | public: |
| 130 | |
| 131 | /// getDescription - Return the description of the specified custom |
| 132 | /// diagnostic. |
| 133 | const char *getDescription(unsigned DiagID) const { |
Chris Lattner | 88eccaf | 2009-01-29 06:55:46 +0000 | [diff] [blame] | 134 | assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() && |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 135 | "Invalid diagnosic ID"); |
Chris Lattner | 88eccaf | 2009-01-29 06:55:46 +0000 | [diff] [blame] | 136 | return DiagInfo[DiagID-DIAG_UPPER_LIMIT].second.c_str(); |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | /// getLevel - Return the level of the specified custom diagnostic. |
| 140 | Diagnostic::Level getLevel(unsigned DiagID) const { |
Chris Lattner | 88eccaf | 2009-01-29 06:55:46 +0000 | [diff] [blame] | 141 | assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() && |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 142 | "Invalid diagnosic ID"); |
Chris Lattner | 88eccaf | 2009-01-29 06:55:46 +0000 | [diff] [blame] | 143 | return DiagInfo[DiagID-DIAG_UPPER_LIMIT].first; |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Chris Lattner | a1f23cc | 2008-10-17 21:24:47 +0000 | [diff] [blame] | 146 | unsigned getOrCreateDiagID(Diagnostic::Level L, const char *Message, |
| 147 | Diagnostic &Diags) { |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 148 | DiagDesc D(L, Message); |
| 149 | // Check to see if it already exists. |
| 150 | std::map<DiagDesc, unsigned>::iterator I = DiagIDs.lower_bound(D); |
| 151 | if (I != DiagIDs.end() && I->first == D) |
| 152 | return I->second; |
| 153 | |
| 154 | // If not, assign a new ID. |
Chris Lattner | 88eccaf | 2009-01-29 06:55:46 +0000 | [diff] [blame] | 155 | unsigned ID = DiagInfo.size()+DIAG_UPPER_LIMIT; |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 156 | DiagIDs.insert(std::make_pair(D, ID)); |
| 157 | DiagInfo.push_back(D); |
Chris Lattner | a1f23cc | 2008-10-17 21:24:47 +0000 | [diff] [blame] | 158 | |
| 159 | // If this is a warning, and all warnings are supposed to map to errors, |
| 160 | // insert the mapping now. |
| 161 | if (L == Diagnostic::Warning && Diags.getWarningsAsErrors()) |
| 162 | Diags.setDiagnosticMapping((diag::kind)ID, diag::MAP_ERROR); |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 163 | return ID; |
| 164 | } |
| 165 | }; |
| 166 | |
| 167 | } // end diag namespace |
| 168 | } // end clang namespace |
| 169 | |
| 170 | |
| 171 | //===----------------------------------------------------------------------===// |
| 172 | // Common Diagnostic implementation |
| 173 | //===----------------------------------------------------------------------===// |
| 174 | |
Chris Lattner | 3fdf4b0 | 2008-11-23 09:21:17 +0000 | [diff] [blame] | 175 | static void DummyArgToStringFn(Diagnostic::ArgumentKind AK, intptr_t QT, |
| 176 | const char *Modifier, unsigned ML, |
| 177 | const char *Argument, unsigned ArgLen, |
| 178 | llvm::SmallVectorImpl<char> &Output) { |
| 179 | const char *Str = "<can't format argument>"; |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 180 | Output.append(Str, Str+strlen(Str)); |
| 181 | } |
| 182 | |
| 183 | |
Ted Kremenek | b4398aa | 2008-08-07 17:49:57 +0000 | [diff] [blame] | 184 | Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) { |
Chris Lattner | 5b4681c | 2008-05-29 15:36:45 +0000 | [diff] [blame] | 185 | IgnoreAllWarnings = false; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 186 | WarningsAsErrors = false; |
| 187 | WarnOnExtensions = false; |
| 188 | ErrorOnExtensions = false; |
Daniel Dunbar | 2fe0997 | 2008-09-12 18:10:20 +0000 | [diff] [blame] | 189 | SuppressSystemWarnings = false; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 190 | // Clear all mappings, setting them to MAP_DEFAULT. |
| 191 | memset(DiagMappings, 0, sizeof(DiagMappings)); |
| 192 | |
| 193 | ErrorOccurred = false; |
Chris Lattner | 1522142 | 2009-02-06 04:16:02 +0000 | [diff] [blame^] | 194 | FatalErrorOccurred = false; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 195 | NumDiagnostics = 0; |
| 196 | NumErrors = 0; |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 197 | CustomDiagInfo = 0; |
Chris Lattner | 3cbfe2c | 2008-11-22 00:59:29 +0000 | [diff] [blame] | 198 | CurDiagID = ~0U; |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 199 | |
Chris Lattner | 3fdf4b0 | 2008-11-23 09:21:17 +0000 | [diff] [blame] | 200 | ArgToStringFn = DummyArgToStringFn; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 203 | Diagnostic::~Diagnostic() { |
| 204 | delete CustomDiagInfo; |
| 205 | } |
| 206 | |
| 207 | /// getCustomDiagID - Return an ID for a diagnostic with the specified message |
| 208 | /// and level. If this is the first request for this diagnosic, it is |
| 209 | /// registered and created, otherwise the existing ID is returned. |
| 210 | unsigned Diagnostic::getCustomDiagID(Level L, const char *Message) { |
| 211 | if (CustomDiagInfo == 0) |
| 212 | CustomDiagInfo = new diag::CustomDiagInfo(); |
Chris Lattner | a1f23cc | 2008-10-17 21:24:47 +0000 | [diff] [blame] | 213 | return CustomDiagInfo->getOrCreateDiagID(L, Message, *this); |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | |
Chris Lattner | 0750618 | 2007-11-30 22:53:43 +0000 | [diff] [blame] | 217 | /// isBuiltinNoteWarningOrExtension - Return true if the unmapped diagnostic |
| 218 | /// level of the specified diagnostic ID is a Note, Warning, or Extension. |
| 219 | /// Note that this only works on builtin diagnostics, not custom ones. |
| 220 | bool Diagnostic::isBuiltinNoteWarningOrExtension(unsigned DiagID) { |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 221 | return DiagID < diag::DIAG_UPPER_LIMIT && getBuiltinDiagClass(DiagID) < ERROR; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | |
| 225 | /// getDescription - Given a diagnostic ID, return a description of the |
| 226 | /// issue. |
Chris Lattner | 0a14eee | 2008-11-18 07:04:44 +0000 | [diff] [blame] | 227 | const char *Diagnostic::getDescription(unsigned DiagID) const { |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 228 | if (DiagID < diag::DIAG_UPPER_LIMIT) { |
| 229 | if (DiagID < diag::DIAG_START_LEX) |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 230 | return DiagnosticTextCommon[DiagID]; |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 231 | else if (DiagID < diag::DIAG_START_PARSE) |
| 232 | return DiagnosticTextLex[DiagID - diag::DIAG_START_LEX - 1]; |
| 233 | else if (DiagID < diag::DIAG_START_AST) |
| 234 | return DiagnosticTextParse[DiagID - diag::DIAG_START_PARSE - 1]; |
| 235 | else if (DiagID < diag::DIAG_START_SEMA) |
| 236 | return DiagnosticTextAST[DiagID - diag::DIAG_START_AST - 1]; |
| 237 | else if (DiagID < diag::DIAG_START_ANALYSIS) |
| 238 | return DiagnosticTextSema[DiagID - diag::DIAG_START_SEMA - 1]; |
| 239 | else if (DiagID < diag::DIAG_UPPER_LIMIT) |
| 240 | return DiagnosticTextAnalysis[DiagID - diag::DIAG_START_ANALYSIS - 1]; |
Chris Lattner | 20c6b3b | 2009-01-27 18:30:58 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | return CustomDiagInfo->getDescription(DiagID); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /// getDiagnosticLevel - Based on the way the client configured the Diagnostic |
| 247 | /// object, classify the specified diagnostic ID into a Level, consumable by |
| 248 | /// the DiagnosticClient. |
| 249 | Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const { |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 250 | // Handle custom diagnostics, which cannot be mapped. |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 251 | if (DiagID >= diag::DIAG_UPPER_LIMIT) |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 252 | return CustomDiagInfo->getLevel(DiagID); |
Chris Lattner | 0750618 | 2007-11-30 22:53:43 +0000 | [diff] [blame] | 253 | |
| 254 | unsigned DiagClass = getBuiltinDiagClass(DiagID); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 255 | |
| 256 | // Specific non-error diagnostics may be mapped to various levels from ignored |
| 257 | // to error. |
| 258 | if (DiagClass < ERROR) { |
| 259 | switch (getDiagnosticMapping((diag::kind)DiagID)) { |
| 260 | case diag::MAP_DEFAULT: break; |
Chris Lattner | 5b4681c | 2008-05-29 15:36:45 +0000 | [diff] [blame] | 261 | case diag::MAP_IGNORE: return Diagnostic::Ignored; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 262 | case diag::MAP_WARNING: DiagClass = WARNING; break; |
| 263 | case diag::MAP_ERROR: DiagClass = ERROR; break; |
Chris Lattner | da0cbc1 | 2009-02-05 22:47:05 +0000 | [diff] [blame] | 264 | case diag::MAP_FATAL: DiagClass = FATAL; break; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 265 | } |
Chris Lattner | da0cbc1 | 2009-02-05 22:47:05 +0000 | [diff] [blame] | 266 | } else if (getDiagnosticMapping((diag::kind)DiagID) == diag::MAP_FATAL) { |
| 267 | DiagClass = FATAL; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | // Map diagnostic classes based on command line argument settings. |
| 271 | if (DiagClass == EXTENSION) { |
| 272 | if (ErrorOnExtensions) |
| 273 | DiagClass = ERROR; |
| 274 | else if (WarnOnExtensions) |
| 275 | DiagClass = WARNING; |
| 276 | else |
| 277 | return Ignored; |
Daniel Dunbar | 4489fe1 | 2008-08-05 00:07:51 +0000 | [diff] [blame] | 278 | } else if (DiagClass == EXTWARN) { |
| 279 | DiagClass = ErrorOnExtensions ? ERROR : WARNING; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 280 | } |
| 281 | |
Chris Lattner | 5b4681c | 2008-05-29 15:36:45 +0000 | [diff] [blame] | 282 | // If warnings are globally mapped to ignore or error, do it. |
| 283 | if (DiagClass == WARNING) { |
| 284 | if (IgnoreAllWarnings) |
| 285 | return Diagnostic::Ignored; |
| 286 | if (WarningsAsErrors) |
| 287 | DiagClass = ERROR; |
| 288 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 289 | |
| 290 | switch (DiagClass) { |
| 291 | default: assert(0 && "Unknown diagnostic class!"); |
| 292 | case NOTE: return Diagnostic::Note; |
| 293 | case WARNING: return Diagnostic::Warning; |
| 294 | case ERROR: return Diagnostic::Error; |
Chris Lattner | da0cbc1 | 2009-02-05 22:47:05 +0000 | [diff] [blame] | 295 | case FATAL: return Diagnostic::Fatal; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | |
Chris Lattner | 0a14eee | 2008-11-18 07:04:44 +0000 | [diff] [blame] | 299 | /// ProcessDiag - This is the method used to report a diagnostic that is |
| 300 | /// finally fully formed. |
Chris Lattner | 3cbfe2c | 2008-11-22 00:59:29 +0000 | [diff] [blame] | 301 | void Diagnostic::ProcessDiag() { |
| 302 | DiagnosticInfo Info(this); |
| 303 | |
Chris Lattner | 1522142 | 2009-02-06 04:16:02 +0000 | [diff] [blame^] | 304 | // If a fatal error has already been emitted, silence all subsequent |
| 305 | // diagnostics. |
| 306 | if (FatalErrorOccurred) |
| 307 | return; |
| 308 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 309 | // Figure out the diagnostic level of this message. |
Chris Lattner | 0a14eee | 2008-11-18 07:04:44 +0000 | [diff] [blame] | 310 | Diagnostic::Level DiagLevel = getDiagnosticLevel(Info.getID()); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 311 | |
| 312 | // If the client doesn't care about this message, don't issue it. |
| 313 | if (DiagLevel == Diagnostic::Ignored) |
| 314 | return; |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 315 | |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 316 | // If this is not an error and we are in a system header, ignore it. We |
Chris Lattner | 0a14eee | 2008-11-18 07:04:44 +0000 | [diff] [blame] | 317 | // have to check on the original Diag ID here, because we also want to |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 318 | // ignore extensions and warnings in -Werror and -pedantic-errors modes, |
| 319 | // which *map* warnings/extensions to errors. |
Daniel Dunbar | 2fe0997 | 2008-09-12 18:10:20 +0000 | [diff] [blame] | 320 | if (SuppressSystemWarnings && |
Chris Lattner | 19e8e2c | 2009-01-29 17:46:13 +0000 | [diff] [blame] | 321 | Info.getID() < diag::DIAG_UPPER_LIMIT && |
Chris Lattner | 0a14eee | 2008-11-18 07:04:44 +0000 | [diff] [blame] | 322 | getBuiltinDiagClass(Info.getID()) != ERROR && |
| 323 | Info.getLocation().isValid() && |
Chris Lattner | df7c17a | 2009-01-16 07:00:02 +0000 | [diff] [blame] | 324 | Info.getLocation().getSpellingLoc().isInSystemHeader()) |
Chris Lattner | 7097d91 | 2008-02-03 09:00:04 +0000 | [diff] [blame] | 325 | return; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 326 | |
| 327 | if (DiagLevel >= Diagnostic::Error) { |
| 328 | ErrorOccurred = true; |
Chris Lattner | 0a14eee | 2008-11-18 07:04:44 +0000 | [diff] [blame] | 329 | ++NumErrors; |
Chris Lattner | 1522142 | 2009-02-06 04:16:02 +0000 | [diff] [blame^] | 330 | |
| 331 | if (DiagLevel == Diagnostic::Fatal) |
| 332 | FatalErrorOccurred = true; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 333 | } |
| 334 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 335 | // Finally, report it. |
Chris Lattner | 0a14eee | 2008-11-18 07:04:44 +0000 | [diff] [blame] | 336 | Client->HandleDiagnostic(DiagLevel, Info); |
Ted Kremenek | cabe668 | 2009-01-23 20:28:53 +0000 | [diff] [blame] | 337 | if (Client->IncludeInDiagnosticCounts()) ++NumDiagnostics; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 340 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 341 | DiagnosticClient::~DiagnosticClient() {} |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 342 | |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 343 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 344 | /// ModifierIs - Return true if the specified modifier matches specified string. |
| 345 | template <std::size_t StrLen> |
| 346 | static bool ModifierIs(const char *Modifier, unsigned ModifierLen, |
| 347 | const char (&Str)[StrLen]) { |
| 348 | return StrLen-1 == ModifierLen && !memcmp(Modifier, Str, StrLen-1); |
| 349 | } |
| 350 | |
| 351 | /// HandleSelectModifier - Handle the integer 'select' modifier. This is used |
| 352 | /// like this: %select{foo|bar|baz}2. This means that the integer argument |
| 353 | /// "%2" has a value from 0-2. If the value is 0, the diagnostic prints 'foo'. |
| 354 | /// If the value is 1, it prints 'bar'. If it has the value 2, it prints 'baz'. |
| 355 | /// This is very useful for certain classes of variant diagnostics. |
| 356 | static void HandleSelectModifier(unsigned ValNo, |
| 357 | const char *Argument, unsigned ArgumentLen, |
| 358 | llvm::SmallVectorImpl<char> &OutStr) { |
| 359 | const char *ArgumentEnd = Argument+ArgumentLen; |
| 360 | |
| 361 | // Skip over 'ValNo' |'s. |
| 362 | while (ValNo) { |
| 363 | const char *NextVal = std::find(Argument, ArgumentEnd, '|'); |
| 364 | assert(NextVal != ArgumentEnd && "Value for integer select modifier was" |
| 365 | " larger than the number of options in the diagnostic string!"); |
| 366 | Argument = NextVal+1; // Skip this string. |
| 367 | --ValNo; |
| 368 | } |
| 369 | |
| 370 | // Get the end of the value. This is either the } or the |. |
| 371 | const char *EndPtr = std::find(Argument, ArgumentEnd, '|'); |
| 372 | // Add the value to the output string. |
| 373 | OutStr.append(Argument, EndPtr); |
| 374 | } |
| 375 | |
| 376 | /// HandleIntegerSModifier - Handle the integer 's' modifier. This adds the |
| 377 | /// letter 's' to the string if the value is not 1. This is used in cases like |
| 378 | /// this: "you idiot, you have %4 parameter%s4!". |
| 379 | static void HandleIntegerSModifier(unsigned ValNo, |
| 380 | llvm::SmallVectorImpl<char> &OutStr) { |
| 381 | if (ValNo != 1) |
| 382 | OutStr.push_back('s'); |
| 383 | } |
| 384 | |
| 385 | |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 386 | /// PluralNumber - Parse an unsigned integer and advance Start. |
| 387 | static unsigned PluralNumber(const char *&Start, const char *End) |
| 388 | { |
| 389 | // Programming 101: Parse a decimal number :-) |
| 390 | unsigned Val = 0; |
| 391 | while (Start != End && *Start >= '0' && *Start <= '9') { |
| 392 | Val *= 10; |
| 393 | Val += *Start - '0'; |
| 394 | ++Start; |
| 395 | } |
| 396 | return Val; |
| 397 | } |
| 398 | |
| 399 | /// TestPluralRange - Test if Val is in the parsed range. Modifies Start. |
| 400 | static bool TestPluralRange(unsigned Val, const char *&Start, const char *End) |
| 401 | { |
| 402 | if (*Start != '[') { |
| 403 | unsigned Ref = PluralNumber(Start, End); |
| 404 | return Ref == Val; |
| 405 | } |
| 406 | |
| 407 | ++Start; |
| 408 | unsigned Low = PluralNumber(Start, End); |
| 409 | assert(*Start == ',' && "Bad plural expression syntax: expected ,"); |
| 410 | ++Start; |
| 411 | unsigned High = PluralNumber(Start, End); |
| 412 | assert(*Start == ']' && "Bad plural expression syntax: expected )"); |
| 413 | ++Start; |
| 414 | return Low <= Val && Val <= High; |
| 415 | } |
| 416 | |
| 417 | /// EvalPluralExpr - Actual expression evaluator for HandlePluralModifier. |
| 418 | static bool EvalPluralExpr(unsigned ValNo, const char *Start, const char *End) |
| 419 | { |
| 420 | // Empty condition? |
| 421 | if (*Start == ':') |
| 422 | return true; |
| 423 | |
| 424 | while (1) { |
| 425 | char C = *Start; |
| 426 | if (C == '%') { |
| 427 | // Modulo expression |
| 428 | ++Start; |
| 429 | unsigned Arg = PluralNumber(Start, End); |
| 430 | assert(*Start == '=' && "Bad plural expression syntax: expected ="); |
| 431 | ++Start; |
| 432 | unsigned ValMod = ValNo % Arg; |
| 433 | if (TestPluralRange(ValMod, Start, End)) |
| 434 | return true; |
| 435 | } else { |
Sebastian Redl | e206532 | 2008-11-27 07:28:14 +0000 | [diff] [blame] | 436 | assert((C == '[' || (C >= '0' && C <= '9')) && |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 437 | "Bad plural expression syntax: unexpected character"); |
| 438 | // Range expression |
| 439 | if (TestPluralRange(ValNo, Start, End)) |
| 440 | return true; |
| 441 | } |
| 442 | |
| 443 | // Scan for next or-expr part. |
| 444 | Start = std::find(Start, End, ','); |
| 445 | if(Start == End) |
| 446 | break; |
| 447 | ++Start; |
| 448 | } |
| 449 | return false; |
| 450 | } |
| 451 | |
| 452 | /// HandlePluralModifier - Handle the integer 'plural' modifier. This is used |
| 453 | /// for complex plural forms, or in languages where all plurals are complex. |
| 454 | /// The syntax is: %plural{cond1:form1|cond2:form2|:form3}, where condn are |
| 455 | /// conditions that are tested in order, the form corresponding to the first |
| 456 | /// that applies being emitted. The empty condition is always true, making the |
| 457 | /// last form a default case. |
| 458 | /// Conditions are simple boolean expressions, where n is the number argument. |
| 459 | /// Here are the rules. |
| 460 | /// condition := expression | empty |
| 461 | /// empty := -> always true |
| 462 | /// expression := numeric [',' expression] -> logical or |
| 463 | /// numeric := range -> true if n in range |
| 464 | /// | '%' number '=' range -> true if n % number in range |
| 465 | /// range := number |
| 466 | /// | '[' number ',' number ']' -> ranges are inclusive both ends |
| 467 | /// |
| 468 | /// Here are some examples from the GNU gettext manual written in this form: |
| 469 | /// English: |
| 470 | /// {1:form0|:form1} |
| 471 | /// Latvian: |
| 472 | /// {0:form2|%100=11,%10=0,%10=[2,9]:form1|:form0} |
| 473 | /// Gaeilge: |
| 474 | /// {1:form0|2:form1|:form2} |
| 475 | /// Romanian: |
| 476 | /// {1:form0|0,%100=[1,19]:form1|:form2} |
| 477 | /// Lithuanian: |
| 478 | /// {%10=0,%100=[10,19]:form2|%10=1:form0|:form1} |
| 479 | /// Russian (requires repeated form): |
| 480 | /// {%100=[11,14]:form2|%10=1:form0|%10=[2,4]:form1|:form2} |
| 481 | /// Slovak |
| 482 | /// {1:form0|[2,4]:form1|:form2} |
| 483 | /// Polish (requires repeated form): |
| 484 | /// {1:form0|%100=[10,20]:form2|%10=[2,4]:form1|:form2} |
| 485 | static void HandlePluralModifier(unsigned ValNo, |
| 486 | const char *Argument, unsigned ArgumentLen, |
| 487 | llvm::SmallVectorImpl<char> &OutStr) |
| 488 | { |
| 489 | const char *ArgumentEnd = Argument + ArgumentLen; |
| 490 | while (1) { |
| 491 | assert(Argument < ArgumentEnd && "Plural expression didn't match."); |
| 492 | const char *ExprEnd = Argument; |
| 493 | while (*ExprEnd != ':') { |
| 494 | assert(ExprEnd != ArgumentEnd && "Plural missing expression end"); |
| 495 | ++ExprEnd; |
| 496 | } |
| 497 | if (EvalPluralExpr(ValNo, Argument, ExprEnd)) { |
| 498 | Argument = ExprEnd + 1; |
| 499 | ExprEnd = std::find(Argument, ArgumentEnd, '|'); |
| 500 | OutStr.append(Argument, ExprEnd); |
| 501 | return; |
| 502 | } |
| 503 | Argument = std::find(Argument, ArgumentEnd - 1, '|') + 1; |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 508 | /// FormatDiagnostic - Format this diagnostic into a string, substituting the |
| 509 | /// formal arguments into the %0 slots. The result is appended onto the Str |
| 510 | /// array. |
| 511 | void DiagnosticInfo:: |
| 512 | FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const { |
| 513 | const char *DiagStr = getDiags()->getDescription(getID()); |
| 514 | const char *DiagEnd = DiagStr+strlen(DiagStr); |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 515 | |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 516 | while (DiagStr != DiagEnd) { |
| 517 | if (DiagStr[0] != '%') { |
| 518 | // Append non-%0 substrings to Str if we have one. |
| 519 | const char *StrEnd = std::find(DiagStr, DiagEnd, '%'); |
| 520 | OutStr.append(DiagStr, StrEnd); |
| 521 | DiagStr = StrEnd; |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 522 | continue; |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 523 | } else if (DiagStr[1] == '%') { |
| 524 | OutStr.push_back('%'); // %% -> %. |
| 525 | DiagStr += 2; |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 526 | continue; |
| 527 | } |
| 528 | |
| 529 | // Skip the %. |
| 530 | ++DiagStr; |
| 531 | |
| 532 | // This must be a placeholder for a diagnostic argument. The format for a |
| 533 | // placeholder is one of "%0", "%modifier0", or "%modifier{arguments}0". |
| 534 | // The digit is a number from 0-9 indicating which argument this comes from. |
| 535 | // The modifier is a string of digits from the set [-a-z]+, arguments is a |
| 536 | // brace enclosed string. |
| 537 | const char *Modifier = 0, *Argument = 0; |
| 538 | unsigned ModifierLen = 0, ArgumentLen = 0; |
| 539 | |
| 540 | // Check to see if we have a modifier. If so eat it. |
| 541 | if (!isdigit(DiagStr[0])) { |
| 542 | Modifier = DiagStr; |
| 543 | while (DiagStr[0] == '-' || |
| 544 | (DiagStr[0] >= 'a' && DiagStr[0] <= 'z')) |
| 545 | ++DiagStr; |
| 546 | ModifierLen = DiagStr-Modifier; |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 547 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 548 | // If we have an argument, get it next. |
| 549 | if (DiagStr[0] == '{') { |
| 550 | ++DiagStr; // Skip {. |
| 551 | Argument = DiagStr; |
| 552 | |
| 553 | for (; DiagStr[0] != '}'; ++DiagStr) |
| 554 | assert(DiagStr[0] && "Mismatched {}'s in diagnostic string!"); |
| 555 | ArgumentLen = DiagStr-Argument; |
| 556 | ++DiagStr; // Skip }. |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 557 | } |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | assert(isdigit(*DiagStr) && "Invalid format for argument in diagnostic"); |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 561 | unsigned ArgNo = *DiagStr++ - '0'; |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 562 | |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 563 | switch (getArgKind(ArgNo)) { |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 564 | // ---- STRINGS ---- |
Chris Lattner | 3cbfe2c | 2008-11-22 00:59:29 +0000 | [diff] [blame] | 565 | case Diagnostic::ak_std_string: { |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 566 | const std::string &S = getArgStdStr(ArgNo); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 567 | assert(ModifierLen == 0 && "No modifiers for strings yet"); |
| 568 | OutStr.append(S.begin(), S.end()); |
| 569 | break; |
| 570 | } |
Chris Lattner | 3cbfe2c | 2008-11-22 00:59:29 +0000 | [diff] [blame] | 571 | case Diagnostic::ak_c_string: { |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 572 | const char *S = getArgCStr(ArgNo); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 573 | assert(ModifierLen == 0 && "No modifiers for strings yet"); |
| 574 | OutStr.append(S, S + strlen(S)); |
| 575 | break; |
| 576 | } |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 577 | // ---- INTEGERS ---- |
Chris Lattner | 3cbfe2c | 2008-11-22 00:59:29 +0000 | [diff] [blame] | 578 | case Diagnostic::ak_sint: { |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 579 | int Val = getArgSInt(ArgNo); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 580 | |
| 581 | if (ModifierIs(Modifier, ModifierLen, "select")) { |
| 582 | HandleSelectModifier((unsigned)Val, Argument, ArgumentLen, OutStr); |
| 583 | } else if (ModifierIs(Modifier, ModifierLen, "s")) { |
| 584 | HandleIntegerSModifier(Val, OutStr); |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 585 | } else if (ModifierIs(Modifier, ModifierLen, "plural")) { |
| 586 | HandlePluralModifier((unsigned)Val, Argument, ArgumentLen, OutStr); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 587 | } else { |
| 588 | assert(ModifierLen == 0 && "Unknown integer modifier"); |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 589 | // FIXME: Optimize |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 590 | std::string S = llvm::itostr(Val); |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 591 | OutStr.append(S.begin(), S.end()); |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 592 | } |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 593 | break; |
| 594 | } |
Chris Lattner | 3cbfe2c | 2008-11-22 00:59:29 +0000 | [diff] [blame] | 595 | case Diagnostic::ak_uint: { |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 596 | unsigned Val = getArgUInt(ArgNo); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 597 | |
| 598 | if (ModifierIs(Modifier, ModifierLen, "select")) { |
| 599 | HandleSelectModifier(Val, Argument, ArgumentLen, OutStr); |
| 600 | } else if (ModifierIs(Modifier, ModifierLen, "s")) { |
| 601 | HandleIntegerSModifier(Val, OutStr); |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 602 | } else if (ModifierIs(Modifier, ModifierLen, "plural")) { |
| 603 | HandlePluralModifier((unsigned)Val, Argument, ArgumentLen, OutStr); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 604 | } else { |
| 605 | assert(ModifierLen == 0 && "Unknown integer modifier"); |
| 606 | |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 607 | // FIXME: Optimize |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 608 | std::string S = llvm::utostr_32(Val); |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 609 | OutStr.append(S.begin(), S.end()); |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 610 | } |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 611 | break; |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 612 | } |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 613 | // ---- NAMES and TYPES ---- |
| 614 | case Diagnostic::ak_identifierinfo: { |
| 615 | OutStr.push_back('\''); |
| 616 | const IdentifierInfo *II = getArgIdentifier(ArgNo); |
| 617 | assert(ModifierLen == 0 && "No modifiers for strings yet"); |
| 618 | OutStr.append(II->getName(), II->getName() + II->getLength()); |
| 619 | OutStr.push_back('\''); |
| 620 | break; |
| 621 | } |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 622 | case Diagnostic::ak_qualtype: |
Chris Lattner | 011bb4e | 2008-11-23 20:28:15 +0000 | [diff] [blame] | 623 | case Diagnostic::ak_declarationname: |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 624 | case Diagnostic::ak_nameddecl: |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 625 | OutStr.push_back('\''); |
Chris Lattner | 3fdf4b0 | 2008-11-23 09:21:17 +0000 | [diff] [blame] | 626 | getDiags()->ConvertArgToString(getArgKind(ArgNo), getRawArg(ArgNo), |
| 627 | Modifier, ModifierLen, |
| 628 | Argument, ArgumentLen, OutStr); |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 629 | OutStr.push_back('\''); |
| 630 | break; |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 631 | } |
| 632 | } |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 633 | } |
Ted Kremenek | cabe668 | 2009-01-23 20:28:53 +0000 | [diff] [blame] | 634 | |
| 635 | /// IncludeInDiagnosticCounts - This method (whose default implementation |
| 636 | /// returns true) indicates whether the diagnostics handled by this |
| 637 | /// DiagnosticClient should be included in the number of diagnostics |
| 638 | /// reported by Diagnostic. |
| 639 | bool DiagnosticClient::IncludeInDiagnosticCounts() const { return true; } |