LLVM 22.0.0git
DiagnosticPrinter.h
Go to the documentation of this file.
1//===- llvm/IR/DiagnosticPrinter.h - Diagnostic Printer ---------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the main interface for printer backend diagnostic.
10//
11// Clients of the backend diagnostics should overload this interface based
12// on their needs.
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_IR_DIAGNOSTICPRINTER_H
16#define LLVM_IR_DIAGNOSTICPRINTER_H
17
19#include <string>
20
21namespace llvm {
22
23// Forward declarations.
24class Module;
25class raw_ostream;
26class SMDiagnostic;
27class StringRef;
28class Twine;
29class Value;
30
31/// Interface for custom diagnostic printing.
33public:
34 virtual ~DiagnosticPrinter() = default;
35
36 // Simple types.
37 virtual DiagnosticPrinter &operator<<(char C) = 0;
38 virtual DiagnosticPrinter &operator<<(unsigned char C) = 0;
39 virtual DiagnosticPrinter &operator<<(signed char C) = 0;
41 virtual DiagnosticPrinter &operator<<(const char *Str) = 0;
42 virtual DiagnosticPrinter &operator<<(const std::string &Str) = 0;
43 virtual DiagnosticPrinter &operator<<(unsigned long N) = 0;
44 virtual DiagnosticPrinter &operator<<(long N) = 0;
45 virtual DiagnosticPrinter &operator<<(unsigned long long N) = 0;
46 virtual DiagnosticPrinter &operator<<(long long N) = 0;
47 virtual DiagnosticPrinter &operator<<(const void *P) = 0;
48 virtual DiagnosticPrinter &operator<<(unsigned int N) = 0;
49 virtual DiagnosticPrinter &operator<<(int N) = 0;
50 virtual DiagnosticPrinter &operator<<(double N) = 0;
51 virtual DiagnosticPrinter &operator<<(const Twine &Str) = 0;
52
53 // IR related types.
54 virtual DiagnosticPrinter &operator<<(const Value &V) = 0;
55 virtual DiagnosticPrinter &operator<<(const Module &M) = 0;
56
57 // Other types.
58 virtual DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) = 0;
59};
60
61/// Basic diagnostic printer that uses an underlying raw_ostream.
63protected:
65
66public:
67 DiagnosticPrinterRawOStream(raw_ostream &Stream) : Stream(Stream) {}
68
69 // Simple types.
70 DiagnosticPrinter &operator<<(char C) override;
71 DiagnosticPrinter &operator<<(unsigned char C) override;
72 DiagnosticPrinter &operator<<(signed char C) override;
74 DiagnosticPrinter &operator<<(const char *Str) override;
75 DiagnosticPrinter &operator<<(const std::string &Str) override;
76 DiagnosticPrinter &operator<<(unsigned long N) override;
77 DiagnosticPrinter &operator<<(long N) override;
78 DiagnosticPrinter &operator<<(unsigned long long N) override;
79 DiagnosticPrinter &operator<<(long long N) override;
80 DiagnosticPrinter &operator<<(const void *P) override;
81 DiagnosticPrinter &operator<<(unsigned int N) override;
82 DiagnosticPrinter &operator<<(int N) override;
83 DiagnosticPrinter &operator<<(double N) override;
84 DiagnosticPrinter &operator<<(const Twine &Str) override;
85
86 // IR related types.
87 DiagnosticPrinter &operator<<(const Value &V) override;
88 DiagnosticPrinter &operator<<(const Module &M) override;
89
90 // Other types.
91 DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) override;
92};
93
94} // end namespace llvm
95
96#endif // LLVM_IR_DIAGNOSTICPRINTER_H
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
raw_ostream & operator<<(raw_ostream &OS, const binary_le_impl< value_type > &BLE)
#define LLVM_ABI
Definition: Compiler.h:213
Machine Check Debug Module
#define P(N)
Basic diagnostic printer that uses an underlying raw_ostream.
DiagnosticPrinterRawOStream(raw_ostream &Stream)
Interface for custom diagnostic printing.
virtual DiagnosticPrinter & operator<<(long N)=0
virtual DiagnosticPrinter & operator<<(double N)=0
virtual DiagnosticPrinter & operator<<(char C)=0
virtual ~DiagnosticPrinter()=default
virtual DiagnosticPrinter & operator<<(const Twine &Str)=0
virtual DiagnosticPrinter & operator<<(unsigned char C)=0
virtual DiagnosticPrinter & operator<<(unsigned int N)=0
virtual DiagnosticPrinter & operator<<(long long N)=0
virtual DiagnosticPrinter & operator<<(const SMDiagnostic &Diag)=0
virtual DiagnosticPrinter & operator<<(const std::string &Str)=0
virtual DiagnosticPrinter & operator<<(int N)=0
virtual DiagnosticPrinter & operator<<(unsigned long long N)=0
virtual DiagnosticPrinter & operator<<(unsigned long N)=0
virtual DiagnosticPrinter & operator<<(signed char C)=0
virtual DiagnosticPrinter & operator<<(const void *P)=0
virtual DiagnosticPrinter & operator<<(StringRef Str)=0
virtual DiagnosticPrinter & operator<<(const Value &V)=0
virtual DiagnosticPrinter & operator<<(const Module &M)=0
virtual DiagnosticPrinter & operator<<(const char *Str)=0
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:282
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:82
LLVM Value Representation.
Definition: Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
#define N