DiagnosticPrinter.h revision affc150dc44fab1911775a49636d0ce85333b634
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 MCLDInfo& pLDInfo) {} 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 46 { return m_NumErrors; } 47 48 unsigned int getNumWarnings() const 49 { return m_NumWarnings; } 50 51protected: 52 unsigned int m_NumErrors; 53 unsigned int m_NumWarnings; 54}; 55 56} // namespace of mcld 57 58#endif 59 60