samsonov added inline comments. ================ Comment at: lib/ubsan/ubsan_handlers.cc:57-58 @@ -57,2 +56,4 @@ + if (!Pointer) { + R.setErrorType(ErrorType::NullPointerUse); Diag(Loc, DL_Error, "%0 null pointer of type %1") << TypeCheckKinds[Data->TypeCheckKind] << Data->Type; ---------------- rsmith wrote: > samsonov wrote: > > rsmith wrote: > > > Can we pass the error type to `Diag` in the place of `DL_Error` instead > > > of specifying it separately? > > We still need error type somewhere outside `Diag`, because it will be used > > later when we print (or not print) summary, after several `Diag` > > invocations (for DL_Error and DL_Note). > We would make exactly one invocation to `Diag` with an error type, wouldn't > we? Is the summary information computed separately from diagnostic emission? The answer to last question is "yes". `Diag` object prints the diagnostic message in destructor (and there can be several `Diag` objects). We need to print summary information after all the diagnostics (DL_Error and DL_Note), so we do this in `ScopedReport` destructor.
There is a different benefit in passing error kind to Diag() object - we can print the actual error kind instead of generic `runtime error:` line, but that's a different problem, which can probably be addressed afterwards. http://reviews.llvm.org/D12215 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits