llvm-6502/lib/IR/DiagnosticPrinter.cpp
Alex Lorenz a15d888abf MIR Serialization: Connect the machine function analysis pass to the MIR parser.
This commit connects the machine function analysis pass (which creates machine
functions) to the MIR parser, which will initialize the machine functions 
with the state from the MIR file and reconstruct the machine IR.

This commit introduces a new interface called 'MachineFunctionInitializer',
which can be used to provide custom initialization for the machine functions.

This commit also introduces a new diagnostic class called 
'DiagnosticInfoMIRParser' which is used for MIR parsing errors.
This commit modifies the default diagnostic handling in LLVMContext - now the
the diagnostics are printed directly into llvm::errs() so that the MIR parsing 
errors can be printed with colours.  

Reviewers: Justin Bogner

Differential Revision: http://reviews.llvm.org/D9928


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239753 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-15 20:30:22 +00:00

118 lines
2.9 KiB
C++

//===- llvm/Support/DiagnosticInfo.cpp - Diagnostic Definitions -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines a diagnostic printer relying on raw_ostream.
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/Twine.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/SourceMgr.h"
using namespace llvm;
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(char C) {
Stream << C;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned char C) {
Stream << C;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(signed char C) {
Stream << C;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(StringRef Str) {
Stream << Str;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const char *Str) {
Stream << Str;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(
const std::string &Str) {
Stream << Str;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned long N) {
Stream << N;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(long N) {
Stream << N;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(
unsigned long long N) {
Stream << N;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(long long N) {
Stream << N;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const void *P) {
Stream << P;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(unsigned int N) {
Stream << N;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(int N) {
Stream << N;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(double N) {
Stream << N;
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Twine &Str) {
Str.print(Stream);
return *this;
}
// IR related types.
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Value &V) {
Stream << V.getName();
return *this;
}
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Module &M) {
Stream << M.getModuleIdentifier();
return *this;
}
// Other types.
DiagnosticPrinter &DiagnosticPrinterRawOStream::
operator<<(const SMDiagnostic &Diag) {
// We don't have to print the SMDiagnostic kind, as the diagnostic severity
// is printed by the diagnostic handler.
Diag.print("", Stream, /*ShowColors=*/true, /*ShowKindLabel=*/false);
return *this;
}