DiagnosticPrinter.h revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
1//===- DiagnosticPrinter.h ------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_DIAGNOSTIC_PRINTER_H 10#define MCLD_DIAGNOSTIC_PRINTER_H 11#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14#include <mcld/LD/DiagnosticEngine.h> 15#include <mcld/LD/Diagnostic.h> 16 17namespace mcld 18{ 19 20/** \class DiagnosticPrinter 21 * \brief DiagnosticPrinter provides the interface to customize diagnostic 22 * messages and output. 23 */ 24class DiagnosticPrinter 25{ 26public: 27 DiagnosticPrinter(); 28 29 virtual ~DiagnosticPrinter(); 30 31 virtual void beginInput(const Input& pInput, const LinkerConfig& pConfig) {} 32 33 virtual void endInput() {} 34 35 virtual void finish() {} 36 37 virtual void clear() 38 { m_NumErrors = m_NumWarnings = 0; } 39 40 /// HandleDiagnostic - Handle this diagnostic, reporting it to the user or 41 /// capturing it to a log as needed. 42 virtual void handleDiagnostic(DiagnosticEngine::Severity pSeverity, 43 const Diagnostic& pInfo); 44 45 unsigned int getNumErrors() const { return m_NumErrors; } 46 unsigned int getNumWarnings() const { return m_NumWarnings; } 47 48protected: 49 unsigned int m_NumErrors; 50 unsigned int m_NumWarnings; 51}; 52 53} // namespace of mcld 54 55#endif 56 57