LLVM API Documentation

DiagnosticPrinter.h
Go to the documentation of this file.
00001 //===- llvm/Support/DiagnosticPrinter.h - Diagnostic Printer ----*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the main interface for printer backend diagnostic.
00011 //
00012 // Clients of the backend diagnostics should overload this interface based
00013 // on their needs.
00014 //===----------------------------------------------------------------------===//
00015 
00016 #ifndef LLVM_IR_DIAGNOSTICPRINTER_H
00017 #define LLVM_IR_DIAGNOSTICPRINTER_H
00018 
00019 #include <string>
00020 
00021 namespace llvm {
00022 // Forward declarations.
00023 class Module;
00024 class raw_ostream;
00025 class StringRef;
00026 class Twine;
00027 class Value;
00028 
00029 /// \brief Interface for custom diagnostic printing.
00030 class DiagnosticPrinter {
00031 public:
00032   virtual ~DiagnosticPrinter() {}
00033 
00034   // Simple types.
00035   virtual DiagnosticPrinter &operator<<(char C) = 0;
00036   virtual DiagnosticPrinter &operator<<(unsigned char C) = 0;
00037   virtual DiagnosticPrinter &operator<<(signed char C) = 0;
00038   virtual DiagnosticPrinter &operator<<(StringRef Str) = 0;
00039   virtual DiagnosticPrinter &operator<<(const char *Str) = 0;
00040   virtual DiagnosticPrinter &operator<<(const std::string &Str) = 0;
00041   virtual DiagnosticPrinter &operator<<(unsigned long N) = 0;
00042   virtual DiagnosticPrinter &operator<<(long N) = 0;
00043   virtual DiagnosticPrinter &operator<<(unsigned long long N) = 0;
00044   virtual DiagnosticPrinter &operator<<(long long N) = 0;
00045   virtual DiagnosticPrinter &operator<<(const void *P) = 0;
00046   virtual DiagnosticPrinter &operator<<(unsigned int N) = 0;
00047   virtual DiagnosticPrinter &operator<<(int N) = 0;
00048   virtual DiagnosticPrinter &operator<<(double N) = 0;
00049   virtual DiagnosticPrinter &operator<<(const Twine &Str) = 0;
00050 
00051   // IR related types.
00052   virtual DiagnosticPrinter &operator<<(const Value &V) = 0;
00053   virtual DiagnosticPrinter &operator<<(const Module &M) = 0;
00054 };
00055 
00056 /// \brief Basic diagnostic printer that uses an underlying raw_ostream.
00057 class DiagnosticPrinterRawOStream : public DiagnosticPrinter {
00058 protected:
00059   raw_ostream &Stream;
00060 
00061 public:
00062   DiagnosticPrinterRawOStream(raw_ostream &Stream) : Stream(Stream) {};
00063 
00064   // Simple types.
00065   DiagnosticPrinter &operator<<(char C) override;
00066   DiagnosticPrinter &operator<<(unsigned char C) override;
00067   DiagnosticPrinter &operator<<(signed char C) override;
00068   DiagnosticPrinter &operator<<(StringRef Str) override;
00069   DiagnosticPrinter &operator<<(const char *Str) override;
00070   DiagnosticPrinter &operator<<(const std::string &Str) override;
00071   DiagnosticPrinter &operator<<(unsigned long N) override;
00072   DiagnosticPrinter &operator<<(long N) override;
00073   DiagnosticPrinter &operator<<(unsigned long long N) override;
00074   DiagnosticPrinter &operator<<(long long N) override;
00075   DiagnosticPrinter &operator<<(const void *P) override;
00076   DiagnosticPrinter &operator<<(unsigned int N) override;
00077   DiagnosticPrinter &operator<<(int N) override;
00078   DiagnosticPrinter &operator<<(double N) override;
00079   DiagnosticPrinter &operator<<(const Twine &Str) override;
00080 
00081   // IR related types.
00082   DiagnosticPrinter &operator<<(const Value &V) override;
00083   DiagnosticPrinter &operator<<(const Module &M) override;
00084 };
00085 } // End namespace llvm
00086 
00087 #endif