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 | |
Ted Kremenek | ec55c94 | 2010-04-12 19:54:17 +0000 | [diff] [blame] | 14 | #include "clang/Basic/Diagnostic.h" |
Chris Lattner | 43b628c | 2008-11-19 07:32:16 +0000 | [diff] [blame] | 15 | #include "clang/Basic/IdentifierTable.h" |
Ted Kremenek | ec55c94 | 2010-04-12 19:54:17 +0000 | [diff] [blame] | 16 | #include "clang/Basic/PartialDiagnostic.h" |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/SmallVector.h" |
Daniel Dunbar | 23e47c6 | 2009-10-17 18:12:14 +0000 | [diff] [blame] | 18 | #include "llvm/Support/raw_ostream.h" |
Ted Kremenek | 03201fb | 2011-03-21 18:40:07 +0000 | [diff] [blame] | 19 | #include "llvm/Support/CrashRecoveryContext.h" |
| 20 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 21 | using namespace clang; |
| 22 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 23 | static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT, |
Chris Lattner | 3fdf4b0 | 2008-11-23 09:21:17 +0000 | [diff] [blame] | 24 | const char *Modifier, unsigned ML, |
| 25 | const char *Argument, unsigned ArgLen, |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 26 | const DiagnosticsEngine::ArgumentValue *PrevArgs, |
Chris Lattner | b54d8af | 2009-10-20 05:25:22 +0000 | [diff] [blame] | 27 | unsigned NumPrevArgs, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 28 | SmallVectorImpl<char> &Output, |
Chandler Carruth | 0673cb3 | 2011-07-11 17:49:21 +0000 | [diff] [blame] | 29 | void *Cookie, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 30 | SmallVectorImpl<intptr_t> &QualTypeVals) { |
Chris Lattner | 3fdf4b0 | 2008-11-23 09:21:17 +0000 | [diff] [blame] | 31 | const char *Str = "<can't format argument>"; |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 32 | Output.append(Str, Str+strlen(Str)); |
| 33 | } |
| 34 | |
| 35 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 36 | DiagnosticsEngine::DiagnosticsEngine( |
| 37 | const llvm::IntrusiveRefCntPtr<DiagnosticIDs> &diags, |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 38 | DiagnosticConsumer *client, bool ShouldOwnClient) |
Argyrios Kyrtzidis | 33e4e70 | 2010-11-18 20:06:41 +0000 | [diff] [blame] | 39 | : Diags(diags), Client(client), OwnsDiagClient(ShouldOwnClient), |
| 40 | SourceMgr(0) { |
Chris Lattner | 3fdf4b0 | 2008-11-23 09:21:17 +0000 | [diff] [blame] | 41 | ArgToStringFn = DummyArgToStringFn; |
Chris Lattner | 92dd386 | 2009-02-19 23:53:20 +0000 | [diff] [blame] | 42 | ArgToStringCookie = 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 43 | |
Douglas Gregor | cc5888d | 2010-07-31 00:40:00 +0000 | [diff] [blame] | 44 | AllExtensionsSilenced = 0; |
| 45 | IgnoreAllWarnings = false; |
| 46 | WarningsAsErrors = false; |
Ted Kremenek | 1e473cc | 2011-08-18 01:12:56 +0000 | [diff] [blame] | 47 | EnableAllWarnings = false; |
Douglas Gregor | cc5888d | 2010-07-31 00:40:00 +0000 | [diff] [blame] | 48 | ErrorsAsFatal = false; |
| 49 | SuppressSystemWarnings = false; |
| 50 | SuppressAllDiagnostics = false; |
| 51 | ShowOverloads = Ovl_All; |
| 52 | ExtBehavior = Ext_Ignore; |
| 53 | |
| 54 | ErrorLimit = 0; |
| 55 | TemplateBacktraceLimit = 0; |
Richard Smith | 08d6e03 | 2011-12-16 19:06:07 +0000 | [diff] [blame] | 56 | ConstexprBacktraceLimit = 0; |
Douglas Gregor | cc5888d | 2010-07-31 00:40:00 +0000 | [diff] [blame] | 57 | |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 58 | Reset(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 59 | } |
| 60 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 61 | DiagnosticsEngine::~DiagnosticsEngine() { |
Argyrios Kyrtzidis | 33e4e70 | 2010-11-18 20:06:41 +0000 | [diff] [blame] | 62 | if (OwnsDiagClient) |
| 63 | delete Client; |
Chris Lattner | 182745a | 2007-12-02 01:09:57 +0000 | [diff] [blame] | 64 | } |
| 65 | |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 66 | void DiagnosticsEngine::setClient(DiagnosticConsumer *client, |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 67 | bool ShouldOwnClient) { |
Douglas Gregor | 4f5e21e | 2011-01-31 22:04:05 +0000 | [diff] [blame] | 68 | if (OwnsDiagClient && Client) |
| 69 | delete Client; |
| 70 | |
| 71 | Client = client; |
| 72 | OwnsDiagClient = ShouldOwnClient; |
| 73 | } |
Chris Lattner | 04ae2df | 2009-07-12 21:18:45 +0000 | [diff] [blame] | 74 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 75 | void DiagnosticsEngine::pushMappings(SourceLocation Loc) { |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 76 | DiagStateOnPushStack.push_back(GetCurDiagState()); |
Chris Lattner | 04ae2df | 2009-07-12 21:18:45 +0000 | [diff] [blame] | 77 | } |
| 78 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 79 | bool DiagnosticsEngine::popMappings(SourceLocation Loc) { |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 80 | if (DiagStateOnPushStack.empty()) |
Chris Lattner | 04ae2df | 2009-07-12 21:18:45 +0000 | [diff] [blame] | 81 | return false; |
| 82 | |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 83 | if (DiagStateOnPushStack.back() != GetCurDiagState()) { |
| 84 | // State changed at some point between push/pop. |
| 85 | PushDiagStatePoint(DiagStateOnPushStack.back(), Loc); |
| 86 | } |
| 87 | DiagStateOnPushStack.pop_back(); |
Chris Lattner | 04ae2df | 2009-07-12 21:18:45 +0000 | [diff] [blame] | 88 | return true; |
| 89 | } |
| 90 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 91 | void DiagnosticsEngine::Reset() { |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 92 | ErrorOccurred = false; |
| 93 | FatalErrorOccurred = false; |
Douglas Gregor | 85bea97 | 2011-07-06 17:40:26 +0000 | [diff] [blame] | 94 | UnrecoverableErrorOccurred = false; |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 95 | |
| 96 | NumWarnings = 0; |
| 97 | NumErrors = 0; |
| 98 | NumErrorsSuppressed = 0; |
Argyrios Kyrtzidis | c0a575f | 2011-07-29 01:25:44 +0000 | [diff] [blame] | 99 | TrapNumErrorsOccurred = 0; |
| 100 | TrapNumUnrecoverableErrorsOccurred = 0; |
Douglas Gregor | 85bea97 | 2011-07-06 17:40:26 +0000 | [diff] [blame] | 101 | |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 102 | CurDiagID = ~0U; |
Argyrios Kyrtzidis | 33e4e70 | 2010-11-18 20:06:41 +0000 | [diff] [blame] | 103 | // Set LastDiagLevel to an "unset" state. If we set it to 'Ignored', notes |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 104 | // using a DiagnosticsEngine associated to a translation unit that follow |
| 105 | // diagnostics from a DiagnosticsEngine associated to anoter t.u. will not be |
Argyrios Kyrtzidis | 33e4e70 | 2010-11-18 20:06:41 +0000 | [diff] [blame] | 106 | // displayed. |
| 107 | LastDiagLevel = (DiagnosticIDs::Level)-1; |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 108 | DelayedDiagID = 0; |
Argyrios Kyrtzidis | dc0a2da | 2011-03-26 18:58:17 +0000 | [diff] [blame] | 109 | |
| 110 | // Clear state related to #pragma diagnostic. |
| 111 | DiagStates.clear(); |
| 112 | DiagStatePoints.clear(); |
| 113 | DiagStateOnPushStack.clear(); |
| 114 | |
| 115 | // Create a DiagState and DiagStatePoint representing diagnostic changes |
| 116 | // through command-line. |
| 117 | DiagStates.push_back(DiagState()); |
| 118 | PushDiagStatePoint(&DiagStates.back(), SourceLocation()); |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 119 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 120 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 121 | void DiagnosticsEngine::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 122 | StringRef Arg2) { |
Douglas Gregor | 93ea5cb | 2010-03-22 15:10:57 +0000 | [diff] [blame] | 123 | if (DelayedDiagID) |
| 124 | return; |
| 125 | |
| 126 | DelayedDiagID = DiagID; |
Douglas Gregor | 9e2dac9 | 2010-03-22 15:47:45 +0000 | [diff] [blame] | 127 | DelayedDiagArg1 = Arg1.str(); |
| 128 | DelayedDiagArg2 = Arg2.str(); |
Douglas Gregor | 93ea5cb | 2010-03-22 15:10:57 +0000 | [diff] [blame] | 129 | } |
| 130 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 131 | void DiagnosticsEngine::ReportDelayed() { |
Douglas Gregor | 93ea5cb | 2010-03-22 15:10:57 +0000 | [diff] [blame] | 132 | Report(DelayedDiagID) << DelayedDiagArg1 << DelayedDiagArg2; |
| 133 | DelayedDiagID = 0; |
| 134 | DelayedDiagArg1.clear(); |
| 135 | DelayedDiagArg2.clear(); |
| 136 | } |
| 137 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 138 | DiagnosticsEngine::DiagStatePointsTy::iterator |
| 139 | DiagnosticsEngine::GetDiagStatePointForLoc(SourceLocation L) const { |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 140 | assert(!DiagStatePoints.empty()); |
| 141 | assert(DiagStatePoints.front().Loc.isInvalid() && |
| 142 | "Should have created a DiagStatePoint for command-line"); |
| 143 | |
| 144 | FullSourceLoc Loc(L, *SourceMgr); |
| 145 | if (Loc.isInvalid()) |
| 146 | return DiagStatePoints.end() - 1; |
| 147 | |
| 148 | DiagStatePointsTy::iterator Pos = DiagStatePoints.end(); |
| 149 | FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc; |
| 150 | if (LastStateChangePos.isValid() && |
| 151 | Loc.isBeforeInTranslationUnitThan(LastStateChangePos)) |
| 152 | Pos = std::upper_bound(DiagStatePoints.begin(), DiagStatePoints.end(), |
| 153 | DiagStatePoint(0, Loc)); |
| 154 | --Pos; |
| 155 | return Pos; |
| 156 | } |
| 157 | |
| 158 | /// \brief This allows the client to specify that certain |
| 159 | /// warnings are ignored. Notes can never be mapped, errors can only be |
| 160 | /// mapped to fatal, and WARNINGs and EXTENSIONs can be mapped arbitrarily. |
| 161 | /// |
| 162 | /// \param The source location that this change of diagnostic state should |
| 163 | /// take affect. It can be null if we are setting the latest state. |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 164 | void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map, |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 165 | SourceLocation L) { |
| 166 | assert(Diag < diag::DIAG_UPPER_LIMIT && |
| 167 | "Can only map builtin diagnostics"); |
| 168 | assert((Diags->isBuiltinWarningOrExtension(Diag) || |
| 169 | (Map == diag::MAP_FATAL || Map == diag::MAP_ERROR)) && |
| 170 | "Cannot map errors into warnings!"); |
| 171 | assert(!DiagStatePoints.empty()); |
| 172 | |
| 173 | FullSourceLoc Loc(L, *SourceMgr); |
| 174 | FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc; |
Argyrios Kyrtzidis | 87429a0 | 2011-11-09 01:24:17 +0000 | [diff] [blame] | 175 | DiagnosticMappingInfo MappingInfo = makeMappingInfo(Map, L); |
Daniel Dunbar | 53201a8 | 2011-10-04 21:17:24 +0000 | [diff] [blame] | 176 | |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 177 | // Common case; setting all the diagnostics of a group in one place. |
| 178 | if (Loc.isInvalid() || Loc == LastStateChangePos) { |
Daniel Dunbar | 09ea68d | 2011-09-29 01:34:47 +0000 | [diff] [blame] | 179 | GetCurDiagState()->setMappingInfo(Diag, MappingInfo); |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 180 | return; |
| 181 | } |
| 182 | |
| 183 | // Another common case; modifying diagnostic state in a source location |
| 184 | // after the previous one. |
| 185 | if ((Loc.isValid() && LastStateChangePos.isInvalid()) || |
| 186 | LastStateChangePos.isBeforeInTranslationUnitThan(Loc)) { |
Chris Lattner | fc8f0e1 | 2011-04-15 05:22:18 +0000 | [diff] [blame] | 187 | // A diagnostic pragma occurred, create a new DiagState initialized with |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 188 | // the current one and a new DiagStatePoint to record at which location |
| 189 | // the new state became active. |
| 190 | DiagStates.push_back(*GetCurDiagState()); |
| 191 | PushDiagStatePoint(&DiagStates.back(), Loc); |
Daniel Dunbar | 09ea68d | 2011-09-29 01:34:47 +0000 | [diff] [blame] | 192 | GetCurDiagState()->setMappingInfo(Diag, MappingInfo); |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 193 | return; |
| 194 | } |
| 195 | |
| 196 | // We allow setting the diagnostic state in random source order for |
| 197 | // completeness but it should not be actually happening in normal practice. |
| 198 | |
| 199 | DiagStatePointsTy::iterator Pos = GetDiagStatePointForLoc(Loc); |
| 200 | assert(Pos != DiagStatePoints.end()); |
| 201 | |
| 202 | // Update all diagnostic states that are active after the given location. |
| 203 | for (DiagStatePointsTy::iterator |
| 204 | I = Pos+1, E = DiagStatePoints.end(); I != E; ++I) { |
Daniel Dunbar | 09ea68d | 2011-09-29 01:34:47 +0000 | [diff] [blame] | 205 | GetCurDiagState()->setMappingInfo(Diag, MappingInfo); |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | // If the location corresponds to an existing point, just update its state. |
| 209 | if (Pos->Loc == Loc) { |
Daniel Dunbar | 09ea68d | 2011-09-29 01:34:47 +0000 | [diff] [blame] | 210 | GetCurDiagState()->setMappingInfo(Diag, MappingInfo); |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 211 | return; |
| 212 | } |
| 213 | |
| 214 | // Create a new state/point and fit it into the vector of DiagStatePoints |
| 215 | // so that the vector is always ordered according to location. |
| 216 | Pos->Loc.isBeforeInTranslationUnitThan(Loc); |
| 217 | DiagStates.push_back(*Pos->State); |
| 218 | DiagState *NewState = &DiagStates.back(); |
Daniel Dunbar | 09ea68d | 2011-09-29 01:34:47 +0000 | [diff] [blame] | 219 | GetCurDiagState()->setMappingInfo(Diag, MappingInfo); |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 220 | DiagStatePoints.insert(Pos+1, DiagStatePoint(NewState, |
| 221 | FullSourceLoc(Loc, *SourceMgr))); |
| 222 | } |
| 223 | |
Daniel Dunbar | 3f83946 | 2011-09-29 01:47:16 +0000 | [diff] [blame] | 224 | bool DiagnosticsEngine::setDiagnosticGroupMapping( |
| 225 | StringRef Group, diag::Mapping Map, SourceLocation Loc) |
| 226 | { |
| 227 | // Get the diagnostics in this group. |
| 228 | llvm::SmallVector<diag::kind, 8> GroupDiags; |
| 229 | if (Diags->getDiagnosticsInGroup(Group, GroupDiags)) |
| 230 | return true; |
| 231 | |
| 232 | // Set the mapping. |
| 233 | for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) |
| 234 | setDiagnosticMapping(GroupDiags[i], Map, Loc); |
| 235 | |
| 236 | return false; |
| 237 | } |
| 238 | |
Daniel Dunbar | 4aa8f2b | 2011-09-29 00:53:47 +0000 | [diff] [blame] | 239 | bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group, |
| 240 | bool Enabled) { |
Daniel Dunbar | a5e4133 | 2011-09-29 01:52:06 +0000 | [diff] [blame] | 241 | // If we are enabling this feature, just set the diagnostic mappings to map to |
| 242 | // errors. |
| 243 | if (Enabled) |
| 244 | return setDiagnosticGroupMapping(Group, diag::MAP_ERROR); |
| 245 | |
| 246 | // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and |
| 247 | // potentially downgrade anything already mapped to be a warning. |
| 248 | |
| 249 | // Get the diagnostics in this group. |
| 250 | llvm::SmallVector<diag::kind, 8> GroupDiags; |
| 251 | if (Diags->getDiagnosticsInGroup(Group, GroupDiags)) |
| 252 | return true; |
| 253 | |
| 254 | // Perform the mapping change. |
| 255 | for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) { |
| 256 | DiagnosticMappingInfo &Info = GetCurDiagState()->getOrAddMappingInfo( |
| 257 | GroupDiags[i]); |
| 258 | |
Daniel Dunbar | be1aa41 | 2011-09-29 01:58:05 +0000 | [diff] [blame] | 259 | if (Info.getMapping() == diag::MAP_ERROR || |
| 260 | Info.getMapping() == diag::MAP_FATAL) |
| 261 | Info.setMapping(diag::MAP_WARNING); |
| 262 | |
Daniel Dunbar | a5e4133 | 2011-09-29 01:52:06 +0000 | [diff] [blame] | 263 | Info.setNoWarningAsError(true); |
| 264 | } |
| 265 | |
| 266 | return false; |
Daniel Dunbar | 4aa8f2b | 2011-09-29 00:53:47 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | bool DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(StringRef Group, |
| 270 | bool Enabled) { |
Daniel Dunbar | a5e4133 | 2011-09-29 01:52:06 +0000 | [diff] [blame] | 271 | // If we are enabling this feature, just set the diagnostic mappings to map to |
| 272 | // fatal errors. |
| 273 | if (Enabled) |
| 274 | return setDiagnosticGroupMapping(Group, diag::MAP_FATAL); |
| 275 | |
| 276 | // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and |
| 277 | // potentially downgrade anything already mapped to be an error. |
| 278 | |
| 279 | // Get the diagnostics in this group. |
| 280 | llvm::SmallVector<diag::kind, 8> GroupDiags; |
| 281 | if (Diags->getDiagnosticsInGroup(Group, GroupDiags)) |
| 282 | return true; |
| 283 | |
| 284 | // Perform the mapping change. |
| 285 | for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) { |
| 286 | DiagnosticMappingInfo &Info = GetCurDiagState()->getOrAddMappingInfo( |
| 287 | GroupDiags[i]); |
| 288 | |
Daniel Dunbar | be1aa41 | 2011-09-29 01:58:05 +0000 | [diff] [blame] | 289 | if (Info.getMapping() == diag::MAP_FATAL) |
| 290 | Info.setMapping(diag::MAP_ERROR); |
| 291 | |
Daniel Dunbar | a5e4133 | 2011-09-29 01:52:06 +0000 | [diff] [blame] | 292 | Info.setNoErrorAsFatal(true); |
| 293 | } |
| 294 | |
| 295 | return false; |
Daniel Dunbar | 4aa8f2b | 2011-09-29 00:53:47 +0000 | [diff] [blame] | 296 | } |
| 297 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 298 | void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) { |
Argyrios Kyrtzidis | e59abb5 | 2011-05-05 07:54:59 +0000 | [diff] [blame] | 299 | assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!"); |
| 300 | |
| 301 | CurDiagLoc = storedDiag.getLocation(); |
| 302 | CurDiagID = storedDiag.getID(); |
| 303 | NumDiagArgs = 0; |
| 304 | |
| 305 | NumDiagRanges = storedDiag.range_size(); |
| 306 | assert(NumDiagRanges < sizeof(DiagRanges)/sizeof(DiagRanges[0]) && |
| 307 | "Too many arguments to diagnostic!"); |
| 308 | unsigned i = 0; |
| 309 | for (StoredDiagnostic::range_iterator |
| 310 | RI = storedDiag.range_begin(), |
| 311 | RE = storedDiag.range_end(); RI != RE; ++RI) |
| 312 | DiagRanges[i++] = *RI; |
| 313 | |
| 314 | NumFixItHints = storedDiag.fixit_size(); |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 315 | assert(NumFixItHints < DiagnosticsEngine::MaxFixItHints && |
| 316 | "Too many fix-it hints!"); |
Argyrios Kyrtzidis | e59abb5 | 2011-05-05 07:54:59 +0000 | [diff] [blame] | 317 | i = 0; |
| 318 | for (StoredDiagnostic::fixit_iterator |
| 319 | FI = storedDiag.fixit_begin(), |
| 320 | FE = storedDiag.fixit_end(); FI != FE; ++FI) |
| 321 | FixItHints[i++] = *FI; |
| 322 | |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 323 | assert(Client && "DiagnosticConsumer not set!"); |
Argyrios Kyrtzidis | e59abb5 | 2011-05-05 07:54:59 +0000 | [diff] [blame] | 324 | Level DiagLevel = storedDiag.getLevel(); |
David Blaikie | 40847cf | 2011-09-26 01:18:08 +0000 | [diff] [blame] | 325 | Diagnostic Info(this, storedDiag.getMessage()); |
Argyrios Kyrtzidis | e59abb5 | 2011-05-05 07:54:59 +0000 | [diff] [blame] | 326 | Client->HandleDiagnostic(DiagLevel, Info); |
| 327 | if (Client->IncludeInDiagnosticCounts()) { |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 328 | if (DiagLevel == DiagnosticsEngine::Warning) |
Argyrios Kyrtzidis | e59abb5 | 2011-05-05 07:54:59 +0000 | [diff] [blame] | 329 | ++NumWarnings; |
| 330 | } |
| 331 | |
| 332 | CurDiagID = ~0U; |
| 333 | } |
| 334 | |
Douglas Gregor | b535041 | 2010-10-13 17:22:14 +0000 | [diff] [blame] | 335 | void DiagnosticBuilder::FlushCounts() { |
| 336 | DiagObj->NumDiagArgs = NumArgs; |
| 337 | DiagObj->NumDiagRanges = NumRanges; |
| 338 | DiagObj->NumFixItHints = NumFixItHints; |
| 339 | } |
| 340 | |
Douglas Gregor | 93ea5cb | 2010-03-22 15:10:57 +0000 | [diff] [blame] | 341 | bool DiagnosticBuilder::Emit() { |
| 342 | // If DiagObj is null, then its soul was stolen by the copy ctor |
| 343 | // or the user called Emit(). |
| 344 | if (DiagObj == 0) return false; |
| 345 | |
| 346 | // When emitting diagnostics, we set the final argument count into |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 347 | // the DiagnosticsEngine object. |
Douglas Gregor | b535041 | 2010-10-13 17:22:14 +0000 | [diff] [blame] | 348 | FlushCounts(); |
Douglas Gregor | 93ea5cb | 2010-03-22 15:10:57 +0000 | [diff] [blame] | 349 | |
| 350 | // Process the diagnostic, sending the accumulated information to the |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 351 | // DiagnosticConsumer. |
Douglas Gregor | 93ea5cb | 2010-03-22 15:10:57 +0000 | [diff] [blame] | 352 | bool Emitted = DiagObj->ProcessDiag(); |
| 353 | |
| 354 | // Clear out the current diagnostic object. |
Douglas Gregor | 9e2dac9 | 2010-03-22 15:47:45 +0000 | [diff] [blame] | 355 | unsigned DiagID = DiagObj->CurDiagID; |
Douglas Gregor | 93ea5cb | 2010-03-22 15:10:57 +0000 | [diff] [blame] | 356 | DiagObj->Clear(); |
| 357 | |
| 358 | // If there was a delayed diagnostic, emit it now. |
Douglas Gregor | 9e2dac9 | 2010-03-22 15:47:45 +0000 | [diff] [blame] | 359 | if (DiagObj->DelayedDiagID && DiagObj->DelayedDiagID != DiagID) |
Douglas Gregor | 93ea5cb | 2010-03-22 15:10:57 +0000 | [diff] [blame] | 360 | DiagObj->ReportDelayed(); |
| 361 | |
| 362 | // This diagnostic is dead. |
| 363 | DiagObj = 0; |
| 364 | |
| 365 | return Emitted; |
| 366 | } |
| 367 | |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 368 | |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 369 | DiagnosticConsumer::~DiagnosticConsumer() {} |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 370 | |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 371 | void DiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, |
David Blaikie | 40847cf | 2011-09-26 01:18:08 +0000 | [diff] [blame] | 372 | const Diagnostic &Info) { |
Argyrios Kyrtzidis | f2224d8 | 2010-11-18 20:06:46 +0000 | [diff] [blame] | 373 | if (!IncludeInDiagnosticCounts()) |
| 374 | return; |
| 375 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 376 | if (DiagLevel == DiagnosticsEngine::Warning) |
Argyrios Kyrtzidis | f2224d8 | 2010-11-18 20:06:46 +0000 | [diff] [blame] | 377 | ++NumWarnings; |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 378 | else if (DiagLevel >= DiagnosticsEngine::Error) |
Argyrios Kyrtzidis | f2224d8 | 2010-11-18 20:06:46 +0000 | [diff] [blame] | 379 | ++NumErrors; |
| 380 | } |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 381 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 382 | /// ModifierIs - Return true if the specified modifier matches specified string. |
| 383 | template <std::size_t StrLen> |
| 384 | static bool ModifierIs(const char *Modifier, unsigned ModifierLen, |
| 385 | const char (&Str)[StrLen]) { |
| 386 | return StrLen-1 == ModifierLen && !memcmp(Modifier, Str, StrLen-1); |
| 387 | } |
| 388 | |
John McCall | 909c182 | 2010-01-14 20:11:39 +0000 | [diff] [blame] | 389 | /// ScanForward - Scans forward, looking for the given character, skipping |
| 390 | /// nested clauses and escaped characters. |
| 391 | static const char *ScanFormat(const char *I, const char *E, char Target) { |
| 392 | unsigned Depth = 0; |
| 393 | |
| 394 | for ( ; I != E; ++I) { |
| 395 | if (Depth == 0 && *I == Target) return I; |
| 396 | if (Depth != 0 && *I == '}') Depth--; |
| 397 | |
| 398 | if (*I == '%') { |
| 399 | I++; |
| 400 | if (I == E) break; |
| 401 | |
| 402 | // Escaped characters get implicitly skipped here. |
| 403 | |
| 404 | // Format specifier. |
| 405 | if (!isdigit(*I) && !ispunct(*I)) { |
| 406 | for (I++; I != E && !isdigit(*I) && *I != '{'; I++) ; |
| 407 | if (I == E) break; |
| 408 | if (*I == '{') |
| 409 | Depth++; |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | return E; |
| 414 | } |
| 415 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 416 | /// HandleSelectModifier - Handle the integer 'select' modifier. This is used |
| 417 | /// like this: %select{foo|bar|baz}2. This means that the integer argument |
| 418 | /// "%2" has a value from 0-2. If the value is 0, the diagnostic prints 'foo'. |
| 419 | /// If the value is 1, it prints 'bar'. If it has the value 2, it prints 'baz'. |
| 420 | /// This is very useful for certain classes of variant diagnostics. |
David Blaikie | 40847cf | 2011-09-26 01:18:08 +0000 | [diff] [blame] | 421 | static void HandleSelectModifier(const Diagnostic &DInfo, unsigned ValNo, |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 422 | const char *Argument, unsigned ArgumentLen, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 423 | SmallVectorImpl<char> &OutStr) { |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 424 | const char *ArgumentEnd = Argument+ArgumentLen; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 425 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 426 | // Skip over 'ValNo' |'s. |
| 427 | while (ValNo) { |
John McCall | 909c182 | 2010-01-14 20:11:39 +0000 | [diff] [blame] | 428 | const char *NextVal = ScanFormat(Argument, ArgumentEnd, '|'); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 429 | assert(NextVal != ArgumentEnd && "Value for integer select modifier was" |
| 430 | " larger than the number of options in the diagnostic string!"); |
| 431 | Argument = NextVal+1; // Skip this string. |
| 432 | --ValNo; |
| 433 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 434 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 435 | // Get the end of the value. This is either the } or the |. |
John McCall | 909c182 | 2010-01-14 20:11:39 +0000 | [diff] [blame] | 436 | const char *EndPtr = ScanFormat(Argument, ArgumentEnd, '|'); |
John McCall | 9f28614 | 2010-01-13 23:58:20 +0000 | [diff] [blame] | 437 | |
| 438 | // Recursively format the result of the select clause into the output string. |
| 439 | DInfo.FormatDiagnostic(Argument, EndPtr, OutStr); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | /// HandleIntegerSModifier - Handle the integer 's' modifier. This adds the |
| 443 | /// letter 's' to the string if the value is not 1. This is used in cases like |
| 444 | /// this: "you idiot, you have %4 parameter%s4!". |
| 445 | static void HandleIntegerSModifier(unsigned ValNo, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 446 | SmallVectorImpl<char> &OutStr) { |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 447 | if (ValNo != 1) |
| 448 | OutStr.push_back('s'); |
| 449 | } |
| 450 | |
John McCall | 3be16b7 | 2010-01-14 00:50:32 +0000 | [diff] [blame] | 451 | /// HandleOrdinalModifier - Handle the integer 'ord' modifier. This |
| 452 | /// prints the ordinal form of the given integer, with 1 corresponding |
| 453 | /// to the first ordinal. Currently this is hard-coded to use the |
| 454 | /// English form. |
| 455 | static void HandleOrdinalModifier(unsigned ValNo, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 456 | SmallVectorImpl<char> &OutStr) { |
John McCall | 3be16b7 | 2010-01-14 00:50:32 +0000 | [diff] [blame] | 457 | assert(ValNo != 0 && "ValNo must be strictly positive!"); |
| 458 | |
| 459 | llvm::raw_svector_ostream Out(OutStr); |
| 460 | |
| 461 | // We could use text forms for the first N ordinals, but the numeric |
| 462 | // forms are actually nicer in diagnostics because they stand out. |
| 463 | Out << ValNo; |
| 464 | |
| 465 | // It is critically important that we do this perfectly for |
| 466 | // user-written sequences with over 100 elements. |
| 467 | switch (ValNo % 100) { |
| 468 | case 11: |
| 469 | case 12: |
| 470 | case 13: |
| 471 | Out << "th"; return; |
| 472 | default: |
| 473 | switch (ValNo % 10) { |
| 474 | case 1: Out << "st"; return; |
| 475 | case 2: Out << "nd"; return; |
| 476 | case 3: Out << "rd"; return; |
| 477 | default: Out << "th"; return; |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 482 | |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 483 | /// PluralNumber - Parse an unsigned integer and advance Start. |
Chris Lattner | d2aa7c9 | 2009-04-15 17:13:42 +0000 | [diff] [blame] | 484 | static unsigned PluralNumber(const char *&Start, const char *End) { |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 485 | // Programming 101: Parse a decimal number :-) |
| 486 | unsigned Val = 0; |
| 487 | while (Start != End && *Start >= '0' && *Start <= '9') { |
| 488 | Val *= 10; |
| 489 | Val += *Start - '0'; |
| 490 | ++Start; |
| 491 | } |
| 492 | return Val; |
| 493 | } |
| 494 | |
| 495 | /// TestPluralRange - Test if Val is in the parsed range. Modifies Start. |
Chris Lattner | d2aa7c9 | 2009-04-15 17:13:42 +0000 | [diff] [blame] | 496 | static bool TestPluralRange(unsigned Val, const char *&Start, const char *End) { |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 497 | if (*Start != '[') { |
| 498 | unsigned Ref = PluralNumber(Start, End); |
| 499 | return Ref == Val; |
| 500 | } |
| 501 | |
| 502 | ++Start; |
| 503 | unsigned Low = PluralNumber(Start, End); |
| 504 | assert(*Start == ',' && "Bad plural expression syntax: expected ,"); |
| 505 | ++Start; |
| 506 | unsigned High = PluralNumber(Start, End); |
| 507 | assert(*Start == ']' && "Bad plural expression syntax: expected )"); |
| 508 | ++Start; |
| 509 | return Low <= Val && Val <= High; |
| 510 | } |
| 511 | |
| 512 | /// EvalPluralExpr - Actual expression evaluator for HandlePluralModifier. |
Chris Lattner | d2aa7c9 | 2009-04-15 17:13:42 +0000 | [diff] [blame] | 513 | static bool EvalPluralExpr(unsigned ValNo, const char *Start, const char *End) { |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 514 | // Empty condition? |
| 515 | if (*Start == ':') |
| 516 | return true; |
| 517 | |
| 518 | while (1) { |
| 519 | char C = *Start; |
| 520 | if (C == '%') { |
| 521 | // Modulo expression |
| 522 | ++Start; |
| 523 | unsigned Arg = PluralNumber(Start, End); |
| 524 | assert(*Start == '=' && "Bad plural expression syntax: expected ="); |
| 525 | ++Start; |
| 526 | unsigned ValMod = ValNo % Arg; |
| 527 | if (TestPluralRange(ValMod, Start, End)) |
| 528 | return true; |
| 529 | } else { |
Sebastian Redl | e206532 | 2008-11-27 07:28:14 +0000 | [diff] [blame] | 530 | assert((C == '[' || (C >= '0' && C <= '9')) && |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 531 | "Bad plural expression syntax: unexpected character"); |
| 532 | // Range expression |
| 533 | if (TestPluralRange(ValNo, Start, End)) |
| 534 | return true; |
| 535 | } |
| 536 | |
| 537 | // Scan for next or-expr part. |
| 538 | Start = std::find(Start, End, ','); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 539 | if (Start == End) |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 540 | break; |
| 541 | ++Start; |
| 542 | } |
| 543 | return false; |
| 544 | } |
| 545 | |
| 546 | /// HandlePluralModifier - Handle the integer 'plural' modifier. This is used |
| 547 | /// for complex plural forms, or in languages where all plurals are complex. |
| 548 | /// The syntax is: %plural{cond1:form1|cond2:form2|:form3}, where condn are |
| 549 | /// conditions that are tested in order, the form corresponding to the first |
| 550 | /// that applies being emitted. The empty condition is always true, making the |
| 551 | /// last form a default case. |
| 552 | /// Conditions are simple boolean expressions, where n is the number argument. |
| 553 | /// Here are the rules. |
| 554 | /// condition := expression | empty |
| 555 | /// empty := -> always true |
| 556 | /// expression := numeric [',' expression] -> logical or |
| 557 | /// numeric := range -> true if n in range |
| 558 | /// | '%' number '=' range -> true if n % number in range |
| 559 | /// range := number |
| 560 | /// | '[' number ',' number ']' -> ranges are inclusive both ends |
| 561 | /// |
| 562 | /// Here are some examples from the GNU gettext manual written in this form: |
| 563 | /// English: |
| 564 | /// {1:form0|:form1} |
| 565 | /// Latvian: |
| 566 | /// {0:form2|%100=11,%10=0,%10=[2,9]:form1|:form0} |
| 567 | /// Gaeilge: |
| 568 | /// {1:form0|2:form1|:form2} |
| 569 | /// Romanian: |
| 570 | /// {1:form0|0,%100=[1,19]:form1|:form2} |
| 571 | /// Lithuanian: |
| 572 | /// {%10=0,%100=[10,19]:form2|%10=1:form0|:form1} |
| 573 | /// Russian (requires repeated form): |
| 574 | /// {%100=[11,14]:form2|%10=1:form0|%10=[2,4]:form1|:form2} |
| 575 | /// Slovak |
| 576 | /// {1:form0|[2,4]:form1|:form2} |
| 577 | /// Polish (requires repeated form): |
| 578 | /// {1:form0|%100=[10,20]:form2|%10=[2,4]:form1|:form2} |
David Blaikie | 40847cf | 2011-09-26 01:18:08 +0000 | [diff] [blame] | 579 | static void HandlePluralModifier(const Diagnostic &DInfo, unsigned ValNo, |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 580 | const char *Argument, unsigned ArgumentLen, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 581 | SmallVectorImpl<char> &OutStr) { |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 582 | const char *ArgumentEnd = Argument + ArgumentLen; |
| 583 | while (1) { |
| 584 | assert(Argument < ArgumentEnd && "Plural expression didn't match."); |
| 585 | const char *ExprEnd = Argument; |
| 586 | while (*ExprEnd != ':') { |
| 587 | assert(ExprEnd != ArgumentEnd && "Plural missing expression end"); |
| 588 | ++ExprEnd; |
| 589 | } |
| 590 | if (EvalPluralExpr(ValNo, Argument, ExprEnd)) { |
| 591 | Argument = ExprEnd + 1; |
John McCall | 909c182 | 2010-01-14 20:11:39 +0000 | [diff] [blame] | 592 | ExprEnd = ScanFormat(Argument, ArgumentEnd, '|'); |
John McCall | e53a44b | 2010-10-14 01:55:31 +0000 | [diff] [blame] | 593 | |
| 594 | // Recursively format the result of the plural clause into the |
| 595 | // output string. |
| 596 | DInfo.FormatDiagnostic(Argument, ExprEnd, OutStr); |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 597 | return; |
| 598 | } |
John McCall | 909c182 | 2010-01-14 20:11:39 +0000 | [diff] [blame] | 599 | Argument = ScanFormat(Argument, ArgumentEnd - 1, '|') + 1; |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 600 | } |
| 601 | } |
| 602 | |
| 603 | |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 604 | /// FormatDiagnostic - Format this diagnostic into a string, substituting the |
| 605 | /// formal arguments into the %0 slots. The result is appended onto the Str |
| 606 | /// array. |
David Blaikie | 40847cf | 2011-09-26 01:18:08 +0000 | [diff] [blame] | 607 | void Diagnostic:: |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 608 | FormatDiagnostic(SmallVectorImpl<char> &OutStr) const { |
Argyrios Kyrtzidis | e59abb5 | 2011-05-05 07:54:59 +0000 | [diff] [blame] | 609 | if (!StoredDiagMessage.empty()) { |
| 610 | OutStr.append(StoredDiagMessage.begin(), StoredDiagMessage.end()); |
| 611 | return; |
| 612 | } |
| 613 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 614 | StringRef Diag = |
Argyrios Kyrtzidis | 477aab6 | 2011-05-25 05:05:01 +0000 | [diff] [blame] | 615 | getDiags()->getDiagnosticIDs()->getDescription(getID()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 616 | |
Argyrios Kyrtzidis | 477aab6 | 2011-05-25 05:05:01 +0000 | [diff] [blame] | 617 | FormatDiagnostic(Diag.begin(), Diag.end(), OutStr); |
John McCall | 9f28614 | 2010-01-13 23:58:20 +0000 | [diff] [blame] | 618 | } |
| 619 | |
David Blaikie | 40847cf | 2011-09-26 01:18:08 +0000 | [diff] [blame] | 620 | void Diagnostic:: |
John McCall | 9f28614 | 2010-01-13 23:58:20 +0000 | [diff] [blame] | 621 | FormatDiagnostic(const char *DiagStr, const char *DiagEnd, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 622 | SmallVectorImpl<char> &OutStr) const { |
John McCall | 9f28614 | 2010-01-13 23:58:20 +0000 | [diff] [blame] | 623 | |
Chris Lattner | b54d8af | 2009-10-20 05:25:22 +0000 | [diff] [blame] | 624 | /// FormattedArgs - Keep track of all of the arguments formatted by |
| 625 | /// ConvertArgToString and pass them into subsequent calls to |
| 626 | /// ConvertArgToString, allowing the implementation to avoid redundancies in |
| 627 | /// obvious cases. |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 628 | SmallVector<DiagnosticsEngine::ArgumentValue, 8> FormattedArgs; |
Chandler Carruth | 0673cb3 | 2011-07-11 17:49:21 +0000 | [diff] [blame] | 629 | |
| 630 | /// QualTypeVals - Pass a vector of arrays so that QualType names can be |
| 631 | /// compared to see if more information is needed to be printed. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 632 | SmallVector<intptr_t, 2> QualTypeVals; |
Chandler Carruth | 0673cb3 | 2011-07-11 17:49:21 +0000 | [diff] [blame] | 633 | for (unsigned i = 0, e = getNumArgs(); i < e; ++i) |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 634 | if (getArgKind(i) == DiagnosticsEngine::ak_qualtype) |
Chandler Carruth | 0673cb3 | 2011-07-11 17:49:21 +0000 | [diff] [blame] | 635 | QualTypeVals.push_back(getRawArg(i)); |
| 636 | |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 637 | while (DiagStr != DiagEnd) { |
| 638 | if (DiagStr[0] != '%') { |
| 639 | // Append non-%0 substrings to Str if we have one. |
| 640 | const char *StrEnd = std::find(DiagStr, DiagEnd, '%'); |
| 641 | OutStr.append(DiagStr, StrEnd); |
| 642 | DiagStr = StrEnd; |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 643 | continue; |
John McCall | 909c182 | 2010-01-14 20:11:39 +0000 | [diff] [blame] | 644 | } else if (ispunct(DiagStr[1])) { |
| 645 | OutStr.push_back(DiagStr[1]); // %% -> %. |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 646 | DiagStr += 2; |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 647 | continue; |
| 648 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 649 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 650 | // Skip the %. |
| 651 | ++DiagStr; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 652 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 653 | // This must be a placeholder for a diagnostic argument. The format for a |
| 654 | // placeholder is one of "%0", "%modifier0", or "%modifier{arguments}0". |
| 655 | // The digit is a number from 0-9 indicating which argument this comes from. |
| 656 | // The modifier is a string of digits from the set [-a-z]+, arguments is a |
| 657 | // brace enclosed string. |
| 658 | const char *Modifier = 0, *Argument = 0; |
| 659 | unsigned ModifierLen = 0, ArgumentLen = 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 660 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 661 | // Check to see if we have a modifier. If so eat it. |
| 662 | if (!isdigit(DiagStr[0])) { |
| 663 | Modifier = DiagStr; |
| 664 | while (DiagStr[0] == '-' || |
| 665 | (DiagStr[0] >= 'a' && DiagStr[0] <= 'z')) |
| 666 | ++DiagStr; |
| 667 | ModifierLen = DiagStr-Modifier; |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 668 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 669 | // If we have an argument, get it next. |
| 670 | if (DiagStr[0] == '{') { |
| 671 | ++DiagStr; // Skip {. |
| 672 | Argument = DiagStr; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 673 | |
John McCall | 909c182 | 2010-01-14 20:11:39 +0000 | [diff] [blame] | 674 | DiagStr = ScanFormat(DiagStr, DiagEnd, '}'); |
| 675 | assert(DiagStr != DiagEnd && "Mismatched {}'s in diagnostic string!"); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 676 | ArgumentLen = DiagStr-Argument; |
| 677 | ++DiagStr; // Skip }. |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 678 | } |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 679 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 680 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 681 | assert(isdigit(*DiagStr) && "Invalid format for argument in diagnostic"); |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 682 | unsigned ArgNo = *DiagStr++ - '0'; |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 683 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 684 | DiagnosticsEngine::ArgumentKind Kind = getArgKind(ArgNo); |
Chris Lattner | b54d8af | 2009-10-20 05:25:22 +0000 | [diff] [blame] | 685 | |
| 686 | switch (Kind) { |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 687 | // ---- STRINGS ---- |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 688 | case DiagnosticsEngine::ak_std_string: { |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 689 | const std::string &S = getArgStdStr(ArgNo); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 690 | assert(ModifierLen == 0 && "No modifiers for strings yet"); |
| 691 | OutStr.append(S.begin(), S.end()); |
| 692 | break; |
| 693 | } |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 694 | case DiagnosticsEngine::ak_c_string: { |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 695 | const char *S = getArgCStr(ArgNo); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 696 | assert(ModifierLen == 0 && "No modifiers for strings yet"); |
Daniel Dunbar | e46e354 | 2009-04-20 06:13:16 +0000 | [diff] [blame] | 697 | |
| 698 | // Don't crash if get passed a null pointer by accident. |
| 699 | if (!S) |
| 700 | S = "(null)"; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 701 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 702 | OutStr.append(S, S + strlen(S)); |
| 703 | break; |
| 704 | } |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 705 | // ---- INTEGERS ---- |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 706 | case DiagnosticsEngine::ak_sint: { |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 707 | int Val = getArgSInt(ArgNo); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 708 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 709 | if (ModifierIs(Modifier, ModifierLen, "select")) { |
John McCall | e53a44b | 2010-10-14 01:55:31 +0000 | [diff] [blame] | 710 | HandleSelectModifier(*this, (unsigned)Val, Argument, ArgumentLen, |
| 711 | OutStr); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 712 | } else if (ModifierIs(Modifier, ModifierLen, "s")) { |
| 713 | HandleIntegerSModifier(Val, OutStr); |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 714 | } else if (ModifierIs(Modifier, ModifierLen, "plural")) { |
John McCall | e53a44b | 2010-10-14 01:55:31 +0000 | [diff] [blame] | 715 | HandlePluralModifier(*this, (unsigned)Val, Argument, ArgumentLen, |
| 716 | OutStr); |
John McCall | 3be16b7 | 2010-01-14 00:50:32 +0000 | [diff] [blame] | 717 | } else if (ModifierIs(Modifier, ModifierLen, "ordinal")) { |
| 718 | HandleOrdinalModifier((unsigned)Val, OutStr); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 719 | } else { |
| 720 | assert(ModifierLen == 0 && "Unknown integer modifier"); |
Daniel Dunbar | 23e47c6 | 2009-10-17 18:12:14 +0000 | [diff] [blame] | 721 | llvm::raw_svector_ostream(OutStr) << Val; |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 722 | } |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 723 | break; |
| 724 | } |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 725 | case DiagnosticsEngine::ak_uint: { |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 726 | unsigned Val = getArgUInt(ArgNo); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 727 | |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 728 | if (ModifierIs(Modifier, ModifierLen, "select")) { |
John McCall | 9f28614 | 2010-01-13 23:58:20 +0000 | [diff] [blame] | 729 | HandleSelectModifier(*this, Val, Argument, ArgumentLen, OutStr); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 730 | } else if (ModifierIs(Modifier, ModifierLen, "s")) { |
| 731 | HandleIntegerSModifier(Val, OutStr); |
Sebastian Redl | e4c452c | 2008-11-22 13:44:36 +0000 | [diff] [blame] | 732 | } else if (ModifierIs(Modifier, ModifierLen, "plural")) { |
John McCall | e53a44b | 2010-10-14 01:55:31 +0000 | [diff] [blame] | 733 | HandlePluralModifier(*this, (unsigned)Val, Argument, ArgumentLen, |
| 734 | OutStr); |
John McCall | 3be16b7 | 2010-01-14 00:50:32 +0000 | [diff] [blame] | 735 | } else if (ModifierIs(Modifier, ModifierLen, "ordinal")) { |
| 736 | HandleOrdinalModifier(Val, OutStr); |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 737 | } else { |
| 738 | assert(ModifierLen == 0 && "Unknown integer modifier"); |
Daniel Dunbar | 23e47c6 | 2009-10-17 18:12:14 +0000 | [diff] [blame] | 739 | llvm::raw_svector_ostream(OutStr) << Val; |
Chris Lattner | 30bc965 | 2008-11-19 07:22:31 +0000 | [diff] [blame] | 740 | } |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 741 | break; |
Chris Lattner | af7ae4e | 2008-11-21 07:50:02 +0000 | [diff] [blame] | 742 | } |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 743 | // ---- NAMES and TYPES ---- |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 744 | case DiagnosticsEngine::ak_identifierinfo: { |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 745 | const IdentifierInfo *II = getArgIdentifier(ArgNo); |
| 746 | assert(ModifierLen == 0 && "No modifiers for strings yet"); |
Daniel Dunbar | e46e354 | 2009-04-20 06:13:16 +0000 | [diff] [blame] | 747 | |
| 748 | // Don't crash if get passed a null pointer by accident. |
| 749 | if (!II) { |
| 750 | const char *S = "(null)"; |
| 751 | OutStr.append(S, S + strlen(S)); |
| 752 | continue; |
| 753 | } |
| 754 | |
Daniel Dunbar | 01eb9b9 | 2009-10-18 21:17:35 +0000 | [diff] [blame] | 755 | llvm::raw_svector_ostream(OutStr) << '\'' << II->getName() << '\''; |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 756 | break; |
| 757 | } |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 758 | case DiagnosticsEngine::ak_qualtype: |
| 759 | case DiagnosticsEngine::ak_declarationname: |
| 760 | case DiagnosticsEngine::ak_nameddecl: |
| 761 | case DiagnosticsEngine::ak_nestednamespec: |
| 762 | case DiagnosticsEngine::ak_declcontext: |
Chris Lattner | b54d8af | 2009-10-20 05:25:22 +0000 | [diff] [blame] | 763 | getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo), |
Chris Lattner | 3fdf4b0 | 2008-11-23 09:21:17 +0000 | [diff] [blame] | 764 | Modifier, ModifierLen, |
Chris Lattner | b54d8af | 2009-10-20 05:25:22 +0000 | [diff] [blame] | 765 | Argument, ArgumentLen, |
| 766 | FormattedArgs.data(), FormattedArgs.size(), |
Chandler Carruth | 0673cb3 | 2011-07-11 17:49:21 +0000 | [diff] [blame] | 767 | OutStr, QualTypeVals); |
Chris Lattner | 22caddc | 2008-11-23 09:13:29 +0000 | [diff] [blame] | 768 | break; |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 769 | } |
Chris Lattner | b54d8af | 2009-10-20 05:25:22 +0000 | [diff] [blame] | 770 | |
| 771 | // Remember this argument info for subsequent formatting operations. Turn |
| 772 | // std::strings into a null terminated string to make it be the same case as |
| 773 | // all the other ones. |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 774 | if (Kind != DiagnosticsEngine::ak_std_string) |
Chris Lattner | b54d8af | 2009-10-20 05:25:22 +0000 | [diff] [blame] | 775 | FormattedArgs.push_back(std::make_pair(Kind, getRawArg(ArgNo))); |
| 776 | else |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 777 | FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_c_string, |
Chris Lattner | b54d8af | 2009-10-20 05:25:22 +0000 | [diff] [blame] | 778 | (intptr_t)getArgStdStr(ArgNo).c_str())); |
| 779 | |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 780 | } |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 781 | } |
Ted Kremenek | cabe668 | 2009-01-23 20:28:53 +0000 | [diff] [blame] | 782 | |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 783 | StoredDiagnostic::StoredDiagnostic() { } |
| 784 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 785 | StoredDiagnostic::StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 786 | StringRef Message) |
Benjamin Kramer | a6a32e2 | 2010-11-19 17:36:51 +0000 | [diff] [blame] | 787 | : ID(ID), Level(Level), Loc(), Message(Message) { } |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 788 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 789 | StoredDiagnostic::StoredDiagnostic(DiagnosticsEngine::Level Level, |
David Blaikie | 40847cf | 2011-09-26 01:18:08 +0000 | [diff] [blame] | 790 | const Diagnostic &Info) |
Douglas Gregor | aa5f135 | 2010-11-19 16:18:16 +0000 | [diff] [blame] | 791 | : ID(Info.getID()), Level(Level) |
| 792 | { |
Argyrios Kyrtzidis | 33e4e70 | 2010-11-18 20:06:41 +0000 | [diff] [blame] | 793 | assert((Info.getLocation().isInvalid() || Info.hasSourceManager()) && |
| 794 | "Valid source location without setting a source manager for diagnostic"); |
| 795 | if (Info.getLocation().isValid()) |
| 796 | Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager()); |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 797 | llvm::SmallString<64> Message; |
| 798 | Info.FormatDiagnostic(Message); |
| 799 | this->Message.assign(Message.begin(), Message.end()); |
| 800 | |
| 801 | Ranges.reserve(Info.getNumRanges()); |
| 802 | for (unsigned I = 0, N = Info.getNumRanges(); I != N; ++I) |
| 803 | Ranges.push_back(Info.getRange(I)); |
| 804 | |
Douglas Gregor | 849b243 | 2010-03-31 17:46:05 +0000 | [diff] [blame] | 805 | FixIts.reserve(Info.getNumFixItHints()); |
| 806 | for (unsigned I = 0, N = Info.getNumFixItHints(); I != N; ++I) |
| 807 | FixIts.push_back(Info.getFixItHint(I)); |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 808 | } |
| 809 | |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 810 | StoredDiagnostic::StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 811 | StringRef Message, FullSourceLoc Loc, |
Chris Lattner | 2d3ba4f | 2011-07-23 17:14:25 +0000 | [diff] [blame] | 812 | ArrayRef<CharSourceRange> Ranges, |
| 813 | ArrayRef<FixItHint> Fixits) |
Douglas Gregor | f62d43d | 2011-07-19 16:10:42 +0000 | [diff] [blame] | 814 | : ID(ID), Level(Level), Loc(Loc), Message(Message) |
| 815 | { |
| 816 | this->Ranges.assign(Ranges.begin(), Ranges.end()); |
| 817 | this->FixIts.assign(FixIts.begin(), FixIts.end()); |
| 818 | } |
| 819 | |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 820 | StoredDiagnostic::~StoredDiagnostic() { } |
| 821 | |
Ted Kremenek | cabe668 | 2009-01-23 20:28:53 +0000 | [diff] [blame] | 822 | /// IncludeInDiagnosticCounts - This method (whose default implementation |
| 823 | /// returns true) indicates whether the diagnostics handled by this |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 824 | /// DiagnosticConsumer should be included in the number of diagnostics |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 825 | /// reported by DiagnosticsEngine. |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 826 | bool DiagnosticConsumer::IncludeInDiagnosticCounts() const { return true; } |
Douglas Gregor | fe6b2d4 | 2010-03-29 23:34:08 +0000 | [diff] [blame] | 827 | |
David Blaikie | 99ba9e3 | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 828 | void IgnoringDiagConsumer::anchor() { } |
| 829 | |
Douglas Gregor | fe6b2d4 | 2010-03-29 23:34:08 +0000 | [diff] [blame] | 830 | PartialDiagnostic::StorageAllocator::StorageAllocator() { |
| 831 | for (unsigned I = 0; I != NumCached; ++I) |
| 832 | FreeList[I] = Cached + I; |
| 833 | NumFreeListEntries = NumCached; |
| 834 | } |
| 835 | |
| 836 | PartialDiagnostic::StorageAllocator::~StorageAllocator() { |
Ted Kremenek | 03201fb | 2011-03-21 18:40:07 +0000 | [diff] [blame] | 837 | // Don't assert if we are in a CrashRecovery context, as this |
| 838 | // invariant may be invalidated during a crash. |
Ted Kremenek | cd1eecf | 2011-03-21 18:40:10 +0000 | [diff] [blame] | 839 | assert((NumFreeListEntries == NumCached || llvm::CrashRecoveryContext::isRecoveringFromCrash()) && "A partial is on the lamb"); |
Douglas Gregor | fe6b2d4 | 2010-03-29 23:34:08 +0000 | [diff] [blame] | 840 | } |