Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:00

0001 //===- llvm/IR/DiagnosticPrinter.h - Diagnostic Printer ---------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file declares the main interface for printer backend diagnostic.
0010 //
0011 // Clients of the backend diagnostics should overload this interface based
0012 // on their needs.
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_IR_DIAGNOSTICPRINTER_H
0016 #define LLVM_IR_DIAGNOSTICPRINTER_H
0017 
0018 #include <string>
0019 
0020 namespace llvm {
0021 
0022 // Forward declarations.
0023 class Module;
0024 class raw_ostream;
0025 class SMDiagnostic;
0026 class StringRef;
0027 class Twine;
0028 class Value;
0029 
0030 /// Interface for custom diagnostic printing.
0031 class DiagnosticPrinter {
0032 public:
0033   virtual ~DiagnosticPrinter() = default;
0034 
0035   // Simple types.
0036   virtual DiagnosticPrinter &operator<<(char C) = 0;
0037   virtual DiagnosticPrinter &operator<<(unsigned char C) = 0;
0038   virtual DiagnosticPrinter &operator<<(signed char C) = 0;
0039   virtual DiagnosticPrinter &operator<<(StringRef Str) = 0;
0040   virtual DiagnosticPrinter &operator<<(const char *Str) = 0;
0041   virtual DiagnosticPrinter &operator<<(const std::string &Str) = 0;
0042   virtual DiagnosticPrinter &operator<<(unsigned long N) = 0;
0043   virtual DiagnosticPrinter &operator<<(long N) = 0;
0044   virtual DiagnosticPrinter &operator<<(unsigned long long N) = 0;
0045   virtual DiagnosticPrinter &operator<<(long long N) = 0;
0046   virtual DiagnosticPrinter &operator<<(const void *P) = 0;
0047   virtual DiagnosticPrinter &operator<<(unsigned int N) = 0;
0048   virtual DiagnosticPrinter &operator<<(int N) = 0;
0049   virtual DiagnosticPrinter &operator<<(double N) = 0;
0050   virtual DiagnosticPrinter &operator<<(const Twine &Str) = 0;
0051 
0052   // IR related types.
0053   virtual DiagnosticPrinter &operator<<(const Value &V) = 0;
0054   virtual DiagnosticPrinter &operator<<(const Module &M) = 0;
0055 
0056   // Other types.
0057   virtual DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) = 0;
0058 };
0059 
0060 /// Basic diagnostic printer that uses an underlying raw_ostream.
0061 class DiagnosticPrinterRawOStream : public DiagnosticPrinter {
0062 protected:
0063   raw_ostream &Stream;
0064 
0065 public:
0066   DiagnosticPrinterRawOStream(raw_ostream &Stream) : Stream(Stream) {}
0067 
0068   // Simple types.
0069   DiagnosticPrinter &operator<<(char C) override;
0070   DiagnosticPrinter &operator<<(unsigned char C) override;
0071   DiagnosticPrinter &operator<<(signed char C) override;
0072   DiagnosticPrinter &operator<<(StringRef Str) override;
0073   DiagnosticPrinter &operator<<(const char *Str) override;
0074   DiagnosticPrinter &operator<<(const std::string &Str) override;
0075   DiagnosticPrinter &operator<<(unsigned long N) override;
0076   DiagnosticPrinter &operator<<(long N) override;
0077   DiagnosticPrinter &operator<<(unsigned long long N) override;
0078   DiagnosticPrinter &operator<<(long long N) override;
0079   DiagnosticPrinter &operator<<(const void *P) override;
0080   DiagnosticPrinter &operator<<(unsigned int N) override;
0081   DiagnosticPrinter &operator<<(int N) override;
0082   DiagnosticPrinter &operator<<(double N) override;
0083   DiagnosticPrinter &operator<<(const Twine &Str) override;
0084 
0085   // IR related types.
0086   DiagnosticPrinter &operator<<(const Value &V) override;
0087   DiagnosticPrinter &operator<<(const Module &M) override;
0088 
0089   // Other types.
0090   DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) override;
0091 };
0092 
0093 } // end namespace llvm
0094 
0095 #endif // LLVM_IR_DIAGNOSTICPRINTER_H