Partial fix for ticket #380 (Error reporting on unused functions)

Returning hard coded line number 1 and assumed that severity should be "style"
https://apps.sourceforge.net/trac/cppcheck/ticket/380
This commit is contained in:
Reijo Tomperi 2009-06-09 23:45:31 +03:00
parent 39ce9ba39c
commit db7b8fb3fd
2 changed files with 7 additions and 12 deletions

View File

@ -175,17 +175,7 @@ void ErrorLogger::_writemsg(const Tokenizer *tokenizer, const std::list<const To
}
void ErrorLogger::_writemsg(const std::string &msg, const std::string &id)
{
std::ostringstream xml;
xml << "<error";
xml << " id=\"" << id << "\"";
xml << " msg=\"" << msg << "\"";
xml << ">";
std::list<ErrorLogger::ErrorMessage::FileLocation> loc;
reportErr(ErrorLogger::ErrorMessage(loc, "", msg, "id"));
}
std::string ErrorLogger::callStackToString(const std::list<ErrorLogger::ErrorMessage::FileLocation> &callStack)
{

View File

@ -160,8 +160,14 @@ public:
void unusedFunction(const std::string &filename, const std::string &funcname)
{
_writemsg("[" + filename + "]: The function '" + funcname + "' is never used", "unusedFunction");
std::list<ErrorLogger::ErrorMessage::FileLocation> loc;
ErrorLogger::ErrorMessage::FileLocation fileLoc;
fileLoc.file = filename;
fileLoc.line = 1;
loc.push_back(fileLoc);
reportErr(ErrorLogger::ErrorMessage(loc, "style", "The function '" + funcname + "' is never used", "unusedFunction"));
}
static bool unusedFunction(const Settings &s)
{
return s._checkCodingStyle || s._showAll;
@ -329,6 +335,5 @@ public:
private:
void _writemsg(const Tokenizer *tokenizer, const Token *tok, const char severity[], const std::string &msg, const std::string &id);
void _writemsg(const Tokenizer *tokenizer, const std::list<const Token *> &callstack, const char severity[], const std::string &msg, const std::string &id);
void _writemsg(const std::string &msg, const std::string &id);
};
#endif