Fix #1322 (Add cppcheckError and unusedFunction to --errorlist, give out internal errors in xml)
http://sourceforge.net/apps/trac/cppcheck/ticket/1322
This commit is contained in:
parent
f5b1a4db36
commit
6db663f6de
|
@ -196,5 +196,7 @@ void CheckUnusedFunctions::check()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CheckUnusedFunctions::unusedFunctionError(const Token *tok)
|
||||
{
|
||||
reportError(tok, Severity::style, "unusedFunction", "The function 'funcName' is never used");
|
||||
}
|
||||
|
|
|
@ -22,13 +22,14 @@
|
|||
#define checkunusedfunctionsH
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "check.h"
|
||||
#include "tokenize.h"
|
||||
#include "errorlogger.h"
|
||||
|
||||
/// @addtogroup Checks
|
||||
/// @{
|
||||
|
||||
class CheckUnusedFunctions
|
||||
class CheckUnusedFunctions: public Check
|
||||
{
|
||||
public:
|
||||
CheckUnusedFunctions(ErrorLogger *errorLogger = 0);
|
||||
|
@ -50,6 +51,35 @@ public:
|
|||
void check();
|
||||
|
||||
private:
|
||||
|
||||
void getErrorMessages()
|
||||
{
|
||||
unusedFunctionError(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy implementation, just to provide error for --errorlist
|
||||
*/
|
||||
void unusedFunctionError(const Token *tok);
|
||||
|
||||
/**
|
||||
* Dummy implementation, just to provide error for --errorlist
|
||||
*/
|
||||
void runSimplifiedChecks(const Tokenizer */*tokenizer*/, const Settings */*settings*/, ErrorLogger */*errorLogger*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string name() const
|
||||
{
|
||||
return "Unused functions";
|
||||
}
|
||||
|
||||
std::string classInfo() const
|
||||
{
|
||||
return "Check for functions that are never called\n";
|
||||
}
|
||||
|
||||
ErrorLogger *_errorLogger;
|
||||
|
||||
|
||||
|
|
|
@ -333,8 +333,7 @@ void CppCheck::parseFromArgs(int argc, const char* const argv[])
|
|||
doc << "===" << (*it)->name() << "===\n"
|
||||
<< (*it)->classInfo() << "\n\n";
|
||||
}
|
||||
doc << "===" << "Unused functions" << "===\n"
|
||||
<< "Check for functions that are never called\n";
|
||||
|
||||
std::string doc2(doc.str());
|
||||
while (doc2.find("\n\n\n") != std::string::npos)
|
||||
doc2.erase(doc2.find("\n\n\n"), 1);
|
||||
|
|
|
@ -6304,6 +6304,8 @@ void Tokenizer::cppcheckError(const Token *tok) const
|
|||
|
||||
if (_errorLogger)
|
||||
_errorLogger->reportErr(errmsg);
|
||||
else
|
||||
Check::reportError(errmsg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6783,6 +6785,7 @@ void Tokenizer::simplifyConst()
|
|||
void Tokenizer::getErrorMessages()
|
||||
{
|
||||
syntaxError(0, ' ');
|
||||
cppcheckError(0);
|
||||
}
|
||||
|
||||
/** find pattern */
|
||||
|
|
Loading…
Reference in New Issue