mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
de262fecd2
This reapplies r197438 and fixes the link-time circular dependency between IR and Support. The fix consists in moving the diagnostic support into IR. The patch adds a new LLVMContext::diagnose that can be used to communicate to the front-end, if any, that something of interest happened. The diagnostics are supported by a new abstraction, the DiagnosticInfo class. The base class contains the following information: - The kind of the report: What this is about. - The severity of the report: How bad this is. This patch also adds 2 classes: - DiagnosticInfoInlineAsm: For inline asm reporting. Basically, this diagnostic will be used to switch to the new diagnostic API for LLVMContext::emitError. - DiagnosticStackSize: For stack size reporting. Comes as a replacement of the hard coded warning in PEI. This patch also features dynamic diagnostic identifiers. In other words plugins can use this infrastructure for their own diagnostics (for more details, see getNextAvailablePluginDiagnosticKind). This patch introduces a new DiagnosticHandlerTy and a new DiagnosticContext in the LLVMContext that should be set by the front-end to be able to map these diagnostics in its own system. http://llvm-reviews.chandlerc.com/D2376 <rdar://problem/15515174> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197508 91177308-0d34-0410-b5e6-96231b3b80d8
85 lines
3.1 KiB
C++
85 lines
3.1 KiB
C++
//===- llvm/Support/DiagnosticPrinter.h - Diagnostic Printer ----*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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_SUPPORT_DIAGNOSTICPRINTER_H
|
|
#define LLVM_SUPPORT_DIAGNOSTICPRINTER_H
|
|
|
|
#include <string>
|
|
|
|
namespace llvm {
|
|
// Forward declarations.
|
|
class raw_ostream;
|
|
class StringRef;
|
|
class Twine;
|
|
class Value;
|
|
|
|
/// \brief Interface for custom diagnostic printing.
|
|
class DiagnosticPrinter {
|
|
public:
|
|
virtual ~DiagnosticPrinter() {}
|
|
|
|
// 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;
|
|
};
|
|
|
|
/// \brief 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.
|
|
virtual DiagnosticPrinter &operator<<(char C);
|
|
virtual DiagnosticPrinter &operator<<(unsigned char C);
|
|
virtual DiagnosticPrinter &operator<<(signed char C);
|
|
virtual DiagnosticPrinter &operator<<(StringRef Str);
|
|
virtual DiagnosticPrinter &operator<<(const char *Str);
|
|
virtual DiagnosticPrinter &operator<<(const std::string &Str);
|
|
virtual DiagnosticPrinter &operator<<(unsigned long N);
|
|
virtual DiagnosticPrinter &operator<<(long N);
|
|
virtual DiagnosticPrinter &operator<<(unsigned long long N);
|
|
virtual DiagnosticPrinter &operator<<(long long N);
|
|
virtual DiagnosticPrinter &operator<<(const void *P);
|
|
virtual DiagnosticPrinter &operator<<(unsigned int N);
|
|
virtual DiagnosticPrinter &operator<<(int N);
|
|
virtual DiagnosticPrinter &operator<<(double N);
|
|
virtual DiagnosticPrinter &operator<<(const Twine &Str);
|
|
|
|
// IR related types.
|
|
virtual DiagnosticPrinter &operator<<(const Value &V);
|
|
};
|
|
} // End namespace llvm
|
|
|
|
#endif
|