1 //===- MsgHandler.cpp -----------------------------------------------------===// 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 #include <mcld/LD/MsgHandler.h> 10 #include <mcld/LD/DiagnosticEngine.h> 11 12 using namespace mcld; 13 MsgHandler(DiagnosticEngine & pEngine)14MsgHandler::MsgHandler(DiagnosticEngine& pEngine) 15 : m_Engine(pEngine), m_NumArgs(0) { 16 } 17 ~MsgHandler()18MsgHandler::~MsgHandler() 19 { 20 emit(); 21 } 22 emit()23bool MsgHandler::emit() 24 { 25 flushCounts(); 26 return m_Engine.emit(); 27 } 28 addString(llvm::StringRef pStr) const29void MsgHandler::addString(llvm::StringRef pStr) const 30 { 31 assert(m_NumArgs < DiagnosticEngine::MaxArguments && 32 "Too many arguments to diagnostic!"); 33 m_Engine.state().ArgumentKinds[m_NumArgs] = DiagnosticEngine::ak_std_string; 34 m_Engine.state().ArgumentStrs[m_NumArgs++] = pStr.data(); 35 } 36 addString(const std::string & pStr) const37void MsgHandler::addString(const std::string& pStr) const 38 { 39 assert(m_NumArgs < DiagnosticEngine::MaxArguments && 40 "Too many arguments to diagnostic!"); 41 m_Engine.state().ArgumentKinds[m_NumArgs] = DiagnosticEngine::ak_std_string; 42 m_Engine.state().ArgumentStrs[m_NumArgs++] = pStr; 43 } 44 addTaggedVal(intptr_t pValue,DiagnosticEngine::ArgumentKind pKind) const45void MsgHandler::addTaggedVal(intptr_t pValue, DiagnosticEngine::ArgumentKind pKind) const 46 { 47 assert(m_NumArgs < DiagnosticEngine::MaxArguments && 48 "Too many arguments to diagnostic!"); 49 m_Engine.state().ArgumentKinds[m_NumArgs] = pKind; 50 m_Engine.state().ArgumentVals[m_NumArgs++] = pValue; 51 } 52 53