================ @@ -1534,6 +1535,72 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) { return Report(SourceLocation(), DiagID); } +//===----------------------------------------------------------------------===// +// RuntimeTrapDiagnosticBuilder +//===----------------------------------------------------------------------===// +/// Class to make it convenient to construct "trap reasons" to attach to trap +/// instructions. +/// +/// Although this class inherits from `DiagnosticBuilder` it has very different +/// semantics. +/// +/// * This class should only be used with trap diagnostics (declared in +/// `DiagnosticCodeGenKinds.td`). +/// * The `RuntimeTrapDiagnosticBuilder` does not emit diagnostics to the normal +/// diagnostics consumers on destruction like normal Diagnostic builders. +/// Instead it does nothing on destruction. +/// * Users of this class that want to retrieve the "trap reason" should call +/// call the `getMessage()` and `getCategory()` and use those results before +/// the builder is destroyed. +/// * Unlike the `DiagnosticBuilder` the `RuntimeDiagnosticBuilder` should never +/// be created as a temporary (i.e. rvalue) and instead should be stored. This ---------------- Sirraide wrote:
Making this class `[[nodiscard]]` would help avoid that. https://github.com/llvm/llvm-project/pull/154618 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits