aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm16/include/llvm/IR/DiagnosticPrinter.h
blob: 2ef4f432d6198c66e21e1e879253af8d07bc44d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif

//===- llvm/IR/DiagnosticPrinter.h - Diagnostic Printer ---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file declares the main interface for printer backend diagnostic.
//
// Clients of the backend diagnostics should overload this interface based
// on their needs.
//===----------------------------------------------------------------------===//

#ifndef LLVM_IR_DIAGNOSTICPRINTER_H
#define LLVM_IR_DIAGNOSTICPRINTER_H

#include <string>

namespace llvm {

// Forward declarations.
class Module;
class raw_ostream;
class SMDiagnostic;
class StringRef;
class Twine;
class Value;

/// Interface for custom diagnostic printing.
class DiagnosticPrinter {
public:
  virtual ~DiagnosticPrinter() = default;

  // Simple types.
  virtual DiagnosticPrinter &operator<<(char C) = 0;
  virtual DiagnosticPrinter &operator<<(unsigned char C) = 0;
  virtual DiagnosticPrinter &operator<<(signed char C) = 0;
  virtual DiagnosticPrinter &operator<<(StringRef Str) = 0;
  virtual DiagnosticPrinter &operator<<(const char *Str) = 0;
  virtual DiagnosticPrinter &operator<<(const std::string &Str) = 0;
  virtual DiagnosticPrinter &operator<<(unsigned long N) = 0;
  virtual DiagnosticPrinter &operator<<(long N) = 0;
  virtual DiagnosticPrinter &operator<<(unsigned long long N) = 0;
  virtual DiagnosticPrinter &operator<<(long long N) = 0;
  virtual DiagnosticPrinter &operator<<(const void *P) = 0;
  virtual DiagnosticPrinter &operator<<(unsigned int N) = 0;
  virtual DiagnosticPrinter &operator<<(int N) = 0;
  virtual DiagnosticPrinter &operator<<(double N) = 0;
  virtual DiagnosticPrinter &operator<<(const Twine &Str) = 0;

  // IR related types.
  virtual DiagnosticPrinter &operator<<(const Value &V) = 0;
  virtual DiagnosticPrinter &operator<<(const Module &M) = 0;

  // Other types.
  virtual DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) = 0;
};

/// Basic diagnostic printer that uses an underlying raw_ostream.
class DiagnosticPrinterRawOStream : public DiagnosticPrinter {
protected:
  raw_ostream &Stream;

public:
  DiagnosticPrinterRawOStream(raw_ostream &Stream) : Stream(Stream) {}

  // Simple types.
  DiagnosticPrinter &operator<<(char C) override;
  DiagnosticPrinter &operator<<(unsigned char C) override;
  DiagnosticPrinter &operator<<(signed char C) override;
  DiagnosticPrinter &operator<<(StringRef Str) override;
  DiagnosticPrinter &operator<<(const char *Str) override;
  DiagnosticPrinter &operator<<(const std::string &Str) override;
  DiagnosticPrinter &operator<<(unsigned long N) override;
  DiagnosticPrinter &operator<<(long N) override;
  DiagnosticPrinter &operator<<(unsigned long long N) override;
  DiagnosticPrinter &operator<<(long long N) override;
  DiagnosticPrinter &operator<<(const void *P) override;
  DiagnosticPrinter &operator<<(unsigned int N) override;
  DiagnosticPrinter &operator<<(int N) override;
  DiagnosticPrinter &operator<<(double N) override;
  DiagnosticPrinter &operator<<(const Twine &Str) override;

  // IR related types.
  DiagnosticPrinter &operator<<(const Value &V) override;
  DiagnosticPrinter &operator<<(const Module &M) override;

  // Other types.
  DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) override;
};

} // end namespace llvm

#endif // LLVM_IR_DIAGNOSTICPRINTER_H

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif