@@ -272,6 +272,17 @@ class PotentialThrowReason {
272
272
CallRethrowsWithDefaultThrowingArgument,
273
273
};
274
274
275
+ static StringRef kindToString (Kind k) {
276
+ switch (k) {
277
+ case Kind::Throw: return " Throw" ;
278
+ case Kind::CallThrows: return " CallThrows" ;
279
+ case Kind::CallRethrowsWithExplicitThrowingArgument:
280
+ return " CallRethrowsWithExplicitThrowingArgument" ;
281
+ case Kind::CallRethrowsWithDefaultThrowingArgument:
282
+ return " CallRethrowsWithDefaultThrowingArgument" ;
283
+ }
284
+ }
285
+
275
286
private:
276
287
Expr *TheExpression;
277
288
Kind TheKind;
@@ -329,6 +340,26 @@ class Classification {
329
340
ThrowingKind Result = ThrowingKind::None;
330
341
Optional<PotentialThrowReason> Reason;
331
342
343
+ void print (raw_ostream &out) const {
344
+ out << " { IsInvalid = " << IsInvalid
345
+ << " , IsAsync = " << IsAsync
346
+ << " , Result = ThrowingKind::" ;
347
+
348
+ switch (Result) {
349
+ case ThrowingKind::None: out << " None" ; break ;
350
+ case ThrowingKind::RethrowingOnly: out << " RethrowingOnly" ; break ;
351
+ case ThrowingKind::Throws: out << " Throws" ; break ;
352
+ }
353
+
354
+ out << " , Reason = " ;
355
+ if (!Reason)
356
+ out << " nil" ;
357
+ else
358
+ out << PotentialThrowReason::kindToString (Reason.getValue ().getKind ());
359
+
360
+ out << " }" ;
361
+ }
362
+
332
363
public:
333
364
Classification () : Result(ThrowingKind::None) {}
334
365
explicit Classification (ThrowingKind result, PotentialThrowReason reason,
@@ -386,6 +417,10 @@ class Classification {
386
417
}
387
418
388
419
bool isAsync () const { return IsAsync; }
420
+
421
+ #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
422
+ LLVM_DUMP_METHOD void dump () const { print (llvm::errs ()); }
423
+ #endif
389
424
};
390
425
391
426
0 commit comments