Add warning capabilities in LLVM.
[oota-llvm.git] / include / llvm / Support / DiagnosticPrinter.h
1 //===- llvm/Support/DiagnosticPrinter.h - Diagnostic Printer ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the main interface for printer backend diagnostic.
11 //
12 // Clients of the backend diagnostics should overload this interface based
13 // on their needs.
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_SUPPORT_DIAGNOSTICPRINTER_H
17 #define LLVM_SUPPORT_DIAGNOSTICPRINTER_H
18
19 #include <string>
20
21 namespace llvm {
22 // Forward declarations.
23 class raw_ostream;
24 class StringRef;
25 class Twine;
26 class Value;
27
28 /// \brief Interface for custom diagnostic printing.
29 class DiagnosticPrinter {
30 public:
31   virtual ~DiagnosticPrinter() {}
32
33   // Simple types.
34   virtual DiagnosticPrinter &operator<<(char C) = 0;
35   virtual DiagnosticPrinter &operator<<(unsigned char C) = 0;
36   virtual DiagnosticPrinter &operator<<(signed char C) = 0;
37   virtual DiagnosticPrinter &operator<<(StringRef Str) = 0;
38   virtual DiagnosticPrinter &operator<<(const char *Str) = 0;
39   virtual DiagnosticPrinter &operator<<(const std::string &Str) = 0;
40   virtual DiagnosticPrinter &operator<<(unsigned long N) = 0;
41   virtual DiagnosticPrinter &operator<<(long N) = 0;
42   virtual DiagnosticPrinter &operator<<(unsigned long long N) = 0;
43   virtual DiagnosticPrinter &operator<<(long long N) = 0;
44   virtual DiagnosticPrinter &operator<<(const void *P) = 0;
45   virtual DiagnosticPrinter &operator<<(unsigned int N) = 0;
46   virtual DiagnosticPrinter &operator<<(int N) = 0;
47   virtual DiagnosticPrinter &operator<<(double N) = 0;
48   virtual DiagnosticPrinter &operator<<(const Twine &Str) = 0;
49
50   // IR related types.
51   virtual DiagnosticPrinter &operator<<(const Value &V) = 0;
52 };
53
54 /// \brief Basic diagnostic printer that uses an underlying raw_ostream.
55 class DiagnosticPrinterRawOStream : public DiagnosticPrinter {
56 protected:
57   raw_ostream &Stream;
58
59 public:
60   DiagnosticPrinterRawOStream(raw_ostream &Stream) : Stream(Stream) {};
61
62   // Simple types.
63   virtual DiagnosticPrinter &operator<<(char C);
64   virtual DiagnosticPrinter &operator<<(unsigned char C);
65   virtual DiagnosticPrinter &operator<<(signed char C);
66   virtual DiagnosticPrinter &operator<<(StringRef Str);
67   virtual DiagnosticPrinter &operator<<(const char *Str);
68   virtual DiagnosticPrinter &operator<<(const std::string &Str);
69   virtual DiagnosticPrinter &operator<<(unsigned long N);
70   virtual DiagnosticPrinter &operator<<(long N);
71   virtual DiagnosticPrinter &operator<<(unsigned long long N);
72   virtual DiagnosticPrinter &operator<<(long long N);
73   virtual DiagnosticPrinter &operator<<(const void *P);
74   virtual DiagnosticPrinter &operator<<(unsigned int N);
75   virtual DiagnosticPrinter &operator<<(int N);
76   virtual DiagnosticPrinter &operator<<(double N);
77   virtual DiagnosticPrinter &operator<<(const Twine &Str);
78
79   // IR related types.
80   virtual DiagnosticPrinter &operator<<(const Value &V);
81 };
82 } // End namespace llvm
83
84 #endif