LLVM 20.0.0git
DiagnosticPrinter.cpp
Go to the documentation of this file.
1//===- llvm/IR/DiagnosticPrinter.cpp - 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 defines a diagnostic printer relying on raw_ostream.
10//
11//===----------------------------------------------------------------------===//
12
14#include "llvm/ADT/Twine.h"
15#include "llvm/IR/Module.h"
16#include "llvm/IR/Value.h"
19
20using namespace llvm;
21
23 Stream << C;
24 return *this;
25}
26
28 Stream << C;
29 return *this;
30}
31
33 Stream << C;
34 return *this;
35}
36
38 Stream << Str;
39 return *this;
40}
41
43 Stream << Str;
44 return *this;
45}
46
48 const std::string &Str) {
49 Stream << Str;
50 return *this;
51}
52
54 Stream << N;
55 return *this;
56}
58 Stream << N;
59 return *this;
60}
61
63 unsigned long long N) {
64 Stream << N;
65 return *this;
66}
67
69 Stream << N;
70 return *this;
71}
72
74 Stream << P;
75 return *this;
76}
77
79 Stream << N;
80 return *this;
81}
82
84 Stream << N;
85 return *this;
86}
87
89 Stream << N;
90 return *this;
91}
92
94 Str.print(Stream);
95 return *this;
96}
97
98// IR related types.
100 // Avoid printing '@' prefix for named functions.
101 if (V.hasName())
102 Stream << V.getName();
103 else
104 V.printAsOperand(Stream, /*PrintType=*/false);
105
106 return *this;
107}
108
110 Stream << M.getModuleIdentifier();
111 return *this;
112}
113
114// Other types.
116operator<<(const SMDiagnostic &Diag) {
117 // We don't have to print the SMDiagnostic kind, as the diagnostic severity
118 // is printed by the diagnostic handler.
119 Diag.print("", Stream, /*ShowColors=*/true, /*ShowKindLabel=*/false);
120 return *this;
121}
Module.h This file contains the declarations for the Module class.
#define P(N)
DiagnosticPrinter & operator<<(char C) override
Interface for custom diagnostic printing.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:281
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true, bool ShowLocation=true) const
Definition: SourceMgr.cpp:484
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
LLVM Value Representation.
Definition: Value.h:74
@ 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