DiagnosticPrinter.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifndef LLVM_IR_DIAGNOSTICPRINTER_H
  16. #define LLVM_IR_DIAGNOSTICPRINTER_H
  17. #include <string>
  18. namespace llvm {
  19. // Forward declarations.
  20. class Module;
  21. class raw_ostream;
  22. class SMDiagnostic;
  23. class StringRef;
  24. class Twine;
  25. class Value;
  26. /// \brief Interface for custom diagnostic printing.
  27. class DiagnosticPrinter {
  28. public:
  29. virtual ~DiagnosticPrinter() {}
  30. // Simple types.
  31. virtual DiagnosticPrinter &operator<<(char C) = 0;
  32. virtual DiagnosticPrinter &operator<<(unsigned char C) = 0;
  33. virtual DiagnosticPrinter &operator<<(signed char C) = 0;
  34. virtual DiagnosticPrinter &operator<<(StringRef Str) = 0;
  35. virtual DiagnosticPrinter &operator<<(const char *Str) = 0;
  36. virtual DiagnosticPrinter &operator<<(const std::string &Str) = 0;
  37. virtual DiagnosticPrinter &operator<<(unsigned long N) = 0;
  38. virtual DiagnosticPrinter &operator<<(long N) = 0;
  39. virtual DiagnosticPrinter &operator<<(unsigned long long N) = 0;
  40. virtual DiagnosticPrinter &operator<<(long long N) = 0;
  41. virtual DiagnosticPrinter &operator<<(const void *P) = 0;
  42. virtual DiagnosticPrinter &operator<<(unsigned int N) = 0;
  43. virtual DiagnosticPrinter &operator<<(int N) = 0;
  44. virtual DiagnosticPrinter &operator<<(double N) = 0;
  45. virtual DiagnosticPrinter &operator<<(const Twine &Str) = 0;
  46. // IR related types.
  47. virtual DiagnosticPrinter &operator<<(const Value &V) = 0;
  48. virtual DiagnosticPrinter &operator<<(const Module &M) = 0;
  49. // Other types.
  50. virtual DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) = 0;
  51. virtual DiagnosticPrinter &
  52. operator<<(std::ios_base &(*iomanip)(std::ios_base &)) = 0; // HLSL Change
  53. };
  54. /// \brief Basic diagnostic printer that uses an underlying raw_ostream.
  55. class DiagnosticPrinterRawOStream : public DiagnosticPrinter {
  56. protected:
  57. raw_ostream &Stream;
  58. public:
  59. DiagnosticPrinterRawOStream(raw_ostream &Stream) : Stream(Stream) {};
  60. // Simple types.
  61. DiagnosticPrinter &operator<<(char C) override;
  62. DiagnosticPrinter &operator<<(unsigned char C) override;
  63. DiagnosticPrinter &operator<<(signed char C) override;
  64. DiagnosticPrinter &operator<<(StringRef Str) override;
  65. DiagnosticPrinter &operator<<(const char *Str) override;
  66. DiagnosticPrinter &operator<<(const std::string &Str) override;
  67. DiagnosticPrinter &operator<<(unsigned long N) override;
  68. DiagnosticPrinter &operator<<(long N) override;
  69. DiagnosticPrinter &operator<<(unsigned long long N) override;
  70. DiagnosticPrinter &operator<<(long long N) override;
  71. DiagnosticPrinter &operator<<(const void *P) override;
  72. DiagnosticPrinter &operator<<(unsigned int N) override;
  73. DiagnosticPrinter &operator<<(int N) override;
  74. DiagnosticPrinter &operator<<(double N) override;
  75. DiagnosticPrinter &operator<<(const Twine &Str) override;
  76. // IR related types.
  77. DiagnosticPrinter &operator<<(const Value &V) override;
  78. DiagnosticPrinter &operator<<(const Module &M) override;
  79. // Other types.
  80. DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) override;
  81. DiagnosticPrinter &operator<<(
  82. std::ios_base &(*iomanip)(std::ios_base &)) override; // HLSL Change
  83. };
  84. } // End namespace llvm
  85. #endif