Path: blob/main/contrib/llvm-project/llvm/lib/IR/DiagnosticPrinter.cpp
35233 views
//===- llvm/IR/DiagnosticPrinter.cpp - Diagnostic Printer -------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines a diagnostic printer relying on raw_ostream.9//10//===----------------------------------------------------------------------===//1112#include "llvm/IR/DiagnosticPrinter.h"13#include "llvm/ADT/Twine.h"14#include "llvm/IR/Module.h"15#include "llvm/IR/Value.h"16#include "llvm/Support/SourceMgr.h"17#include "llvm/Support/raw_ostream.h"1819using namespace llvm;2021DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(char C) {22Stream << C;23return *this;24}2526DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned char C) {27Stream << C;28return *this;29}3031DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(signed char C) {32Stream << C;33return *this;34}3536DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(StringRef Str) {37Stream << Str;38return *this;39}4041DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const char *Str) {42Stream << Str;43return *this;44}4546DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(47const std::string &Str) {48Stream << Str;49return *this;50}5152DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned long N) {53Stream << N;54return *this;55}56DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(long N) {57Stream << N;58return *this;59}6061DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(62unsigned long long N) {63Stream << N;64return *this;65}6667DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(long long N) {68Stream << N;69return *this;70}7172DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const void *P) {73Stream << P;74return *this;75}7677DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned int N) {78Stream << N;79return *this;80}8182DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(int N) {83Stream << N;84return *this;85}8687DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(double N) {88Stream << N;89return *this;90}9192DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Twine &Str) {93Str.print(Stream);94return *this;95}9697// IR related types.98DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Value &V) {99Stream << V.getName();100return *this;101}102103DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Module &M) {104Stream << M.getModuleIdentifier();105return *this;106}107108// Other types.109DiagnosticPrinter &DiagnosticPrinterRawOStream::110operator<<(const SMDiagnostic &Diag) {111// We don't have to print the SMDiagnostic kind, as the diagnostic severity112// is printed by the diagnostic handler.113Diag.print("", Stream, /*ShowColors=*/true, /*ShowKindLabel=*/false);114return *this;115}116117118