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