DiagnosticPrinter.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //===- llvm/Support/DiagnosticInfo.cpp - Diagnostic Definitions -*- 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 defines a diagnostic printer relying on raw_ostream.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "llvm/ADT/Twine.h"
  14. #include "llvm/IR/DiagnosticPrinter.h"
  15. #include "llvm/IR/Module.h"
  16. #include "llvm/IR/Value.h"
  17. #include "llvm/Support/raw_ostream.h"
  18. #include "llvm/Support/SourceMgr.h"
  19. using namespace llvm;
  20. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(char C) {
  21. Stream << C;
  22. return *this;
  23. }
  24. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned char C) {
  25. Stream << C;
  26. return *this;
  27. }
  28. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(signed char C) {
  29. Stream << C;
  30. return *this;
  31. }
  32. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(StringRef Str) {
  33. Stream << Str;
  34. return *this;
  35. }
  36. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const char *Str) {
  37. Stream << Str;
  38. return *this;
  39. }
  40. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(
  41. const std::string &Str) {
  42. Stream << Str;
  43. return *this;
  44. }
  45. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned long N) {
  46. Stream << N;
  47. return *this;
  48. }
  49. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(long N) {
  50. Stream << N;
  51. return *this;
  52. }
  53. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(
  54. unsigned long long N) {
  55. Stream << N;
  56. return *this;
  57. }
  58. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(long long N) {
  59. Stream << N;
  60. return *this;
  61. }
  62. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const void *P) {
  63. Stream << P;
  64. return *this;
  65. }
  66. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned int N) {
  67. Stream << N;
  68. return *this;
  69. }
  70. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(int N) {
  71. Stream << N;
  72. return *this;
  73. }
  74. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(double N) {
  75. Stream << N;
  76. return *this;
  77. }
  78. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Twine &Str) {
  79. Str.print(Stream);
  80. return *this;
  81. }
  82. // HLSL Change Starts
  83. DiagnosticPrinter &DiagnosticPrinterRawOStream::
  84. operator<<(std::ios_base &(*iomanip)(std::ios_base &)) {
  85. Stream << iomanip;
  86. return *this;
  87. }
  88. // HLSL Change Ends.
  89. // IR related types.
  90. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Value &V) {
  91. Stream << V.getName();
  92. return *this;
  93. }
  94. DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Module &M) {
  95. Stream << M.getModuleIdentifier();
  96. return *this;
  97. }
  98. // Other types.
  99. DiagnosticPrinter &DiagnosticPrinterRawOStream::
  100. operator<<(const SMDiagnostic &Diag) {
  101. // We don't have to print the SMDiagnostic kind, as the diagnostic severity
  102. // is printed by the diagnostic handler.
  103. Diag.print("", Stream, /*ShowColors=*/true, /*ShowKindLabel=*/false);
  104. return *this;
  105. }