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 17 namespace mcld 18 { 19 20 /** \class DiagnosticPrinter 21 * \brief DiagnosticPrinter provides the interface to customize diagnostic 22 * messages and output. 23 */ 24 class DiagnosticPrinter 25 { 26 public: 27 DiagnosticPrinter(); 28 29 virtual ~DiagnosticPrinter(); 30 beginInput(const Input & pInput,const LinkerConfig & pConfig)31 virtual void beginInput(const Input& pInput, const LinkerConfig& pConfig) {} 32 endInput()33 virtual void endInput() {} 34 finish()35 virtual void finish() {} 36 clear()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 getNumErrors()45 unsigned int getNumErrors() const { return m_NumErrors; } getNumWarnings()46 unsigned int getNumWarnings() const { return m_NumWarnings; } 47 48 protected: 49 unsigned int m_NumErrors; 50 unsigned int m_NumWarnings; 51 }; 52 53 } // namespace of mcld 54 55 #endif 56 57