1 //===- llvm/Support/DiagnosticPrinter.h - Diagnostic Printer ----*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file declares the main interface for printer backend diagnostic.
11 // Clients of the backend diagnostics should overload this interface based
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_IR_DIAGNOSTICPRINTER_H
16 #define LLVM_IR_DIAGNOSTICPRINTER_H
22 // Forward declarations.
30 /// Interface for custom diagnostic printing.
31 class DiagnosticPrinter
{
33 virtual ~DiagnosticPrinter() = default;
36 virtual DiagnosticPrinter
&operator<<(char C
) = 0;
37 virtual DiagnosticPrinter
&operator<<(unsigned char C
) = 0;
38 virtual DiagnosticPrinter
&operator<<(signed char C
) = 0;
39 virtual DiagnosticPrinter
&operator<<(StringRef Str
) = 0;
40 virtual DiagnosticPrinter
&operator<<(const char *Str
) = 0;
41 virtual DiagnosticPrinter
&operator<<(const std::string
&Str
) = 0;
42 virtual DiagnosticPrinter
&operator<<(unsigned long N
) = 0;
43 virtual DiagnosticPrinter
&operator<<(long N
) = 0;
44 virtual DiagnosticPrinter
&operator<<(unsigned long long N
) = 0;
45 virtual DiagnosticPrinter
&operator<<(long long N
) = 0;
46 virtual DiagnosticPrinter
&operator<<(const void *P
) = 0;
47 virtual DiagnosticPrinter
&operator<<(unsigned int N
) = 0;
48 virtual DiagnosticPrinter
&operator<<(int N
) = 0;
49 virtual DiagnosticPrinter
&operator<<(double N
) = 0;
50 virtual DiagnosticPrinter
&operator<<(const Twine
&Str
) = 0;
53 virtual DiagnosticPrinter
&operator<<(const Value
&V
) = 0;
54 virtual DiagnosticPrinter
&operator<<(const Module
&M
) = 0;
57 virtual DiagnosticPrinter
&operator<<(const SMDiagnostic
&Diag
) = 0;
60 /// Basic diagnostic printer that uses an underlying raw_ostream.
61 class DiagnosticPrinterRawOStream
: public DiagnosticPrinter
{
66 DiagnosticPrinterRawOStream(raw_ostream
&Stream
) : Stream(Stream
) {}
69 DiagnosticPrinter
&operator<<(char C
) override
;
70 DiagnosticPrinter
&operator<<(unsigned char C
) override
;
71 DiagnosticPrinter
&operator<<(signed char C
) override
;
72 DiagnosticPrinter
&operator<<(StringRef Str
) override
;
73 DiagnosticPrinter
&operator<<(const char *Str
) override
;
74 DiagnosticPrinter
&operator<<(const std::string
&Str
) override
;
75 DiagnosticPrinter
&operator<<(unsigned long N
) override
;
76 DiagnosticPrinter
&operator<<(long N
) override
;
77 DiagnosticPrinter
&operator<<(unsigned long long N
) override
;
78 DiagnosticPrinter
&operator<<(long long N
) override
;
79 DiagnosticPrinter
&operator<<(const void *P
) override
;
80 DiagnosticPrinter
&operator<<(unsigned int N
) override
;
81 DiagnosticPrinter
&operator<<(int N
) override
;
82 DiagnosticPrinter
&operator<<(double N
) override
;
83 DiagnosticPrinter
&operator<<(const Twine
&Str
) override
;
86 DiagnosticPrinter
&operator<<(const Value
&V
) override
;
87 DiagnosticPrinter
&operator<<(const Module
&M
) override
;
90 DiagnosticPrinter
&operator<<(const SMDiagnostic
&Diag
) override
;
93 } // end namespace llvm
95 #endif // LLVM_IR_DIAGNOSTICPRINTER_H