Merge commit 'vBm/master'
This commit is contained in:
commit
166eabaef9
1
AUTHORS
1
AUTHORS
|
@ -12,6 +12,7 @@ Nicolas Le Cam
|
||||||
Reijo Tomperi
|
Reijo Tomperi
|
||||||
Robert Reif
|
Robert Reif
|
||||||
Slava Semushin
|
Slava Semushin
|
||||||
|
vBm
|
||||||
Vesa Pikki
|
Vesa Pikki
|
||||||
Zachary Blair
|
Zachary Blair
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class CmdLineParser
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* The constructor.
|
* The constructor.
|
||||||
* @param settings Settings instance that will be modified accoding to
|
* @param settings Settings instance that will be modified according to
|
||||||
* options user has given.
|
* options user has given.
|
||||||
*/
|
*/
|
||||||
CmdLineParser(Settings *settings);
|
CmdLineParser(Settings *settings);
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
* (message) - Error message
|
* (message) - Error message
|
||||||
* (severity) - Error severity
|
* (severity) - Error severity
|
||||||
*
|
*
|
||||||
* Example opening a file with Kate and make Kate scroll to the corret line:
|
* Example opening a file with Kate and make Kate scroll to the correct line:
|
||||||
* kate -l(line) (file)
|
* kate -l(line) (file)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
int GetApplicationCount() const;
|
int GetApplicationCount() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get spesific application's name
|
* @brief Get specific application's name
|
||||||
*
|
*
|
||||||
* @param index Index of the application whose name to get
|
* @param index Index of the application whose name to get
|
||||||
* @return Name of the application
|
* @return Name of the application
|
||||||
|
|
|
@ -83,7 +83,7 @@ unsigned CheckStatistics::GetCount(ShowTypes type) const
|
||||||
break;
|
break;
|
||||||
case SHOW_NONE:
|
case SHOW_NONE:
|
||||||
default:
|
default:
|
||||||
qDebug() << "Unknown error type - returning zero statistices.";
|
qDebug() << "Unknown error type - returning zero statistics.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
|
|
@ -71,7 +71,7 @@ protected:
|
||||||
* Whole purpose of these states is to allow stopping of the checking. When
|
* Whole purpose of these states is to allow stopping of the checking. When
|
||||||
* stopping we say for the thread (Stopping) that stop when current check
|
* stopping we say for the thread (Stopping) that stop when current check
|
||||||
* has been completed. Thread must be stopped cleanly, just terminating thread
|
* has been completed. Thread must be stopped cleanly, just terminating thread
|
||||||
* likely causes unpredictable side-effedts.
|
* likely causes unpredictable side-effects.
|
||||||
*/
|
*/
|
||||||
enum State
|
enum State
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Test if filename matches the filename extensions filtering.
|
* @brief Test if filename matches the filename extensions filtering.
|
||||||
* @param true if filename matches filterin.
|
* @param true if filename matches filtering.
|
||||||
*/
|
*/
|
||||||
bool FilterMatches(const QFileInfo &inf);
|
bool FilterMatches(const QFileInfo &inf);
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,7 @@ void MainWindow::CheckDirectory()
|
||||||
|
|
||||||
bool MainWindow::GetCheckProject()
|
bool MainWindow::GetCheckProject()
|
||||||
{
|
{
|
||||||
// We have succesfully loaded project earlier and use that project
|
// We have successfully loaded project earlier and use that project
|
||||||
if (mProject)
|
if (mProject)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ protected:
|
||||||
bool mErrorsFound;
|
bool mErrorsFound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Should we show a "No errors found dialog" everytime no errors were found?
|
* @brief Should we show a "No errors found dialog" every time no errors were found?
|
||||||
*/
|
*/
|
||||||
bool mShowNoErrorsMessage;
|
bool mShowNoErrorsMessage;
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
* @brief Start the threads to check the files
|
* @brief Start the threads to check the files
|
||||||
*
|
*
|
||||||
* @param settings Settings for checking
|
* @param settings Settings for checking
|
||||||
* @param recheck Should we reuse the files we checked earleir
|
* @param recheck Should we reuse the files we checked earlier
|
||||||
*/
|
*/
|
||||||
void Check(const Settings &settings, bool recheck);
|
void Check(const Settings &settings, bool recheck);
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Slot threads use to signal this class that a spesific file is checked
|
* @brief Slot threads use to signal this class that a specific file is checked
|
||||||
* @param file File taht is checked
|
* @param file File that is checked
|
||||||
*/
|
*/
|
||||||
void FileChecked(const QString &file);
|
void FileChecked(const QString &file);
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -49,7 +49,7 @@ TranslationHandler::TranslationHandler(QObject *parent) :
|
||||||
<< "cppcheck_ja"
|
<< "cppcheck_ja"
|
||||||
<< "cppcheck_sr";
|
<< "cppcheck_sr";
|
||||||
|
|
||||||
//Load english as a fallback language
|
//Load English as a fallback language
|
||||||
QTranslator *english = new QTranslator();
|
QTranslator *english = new QTranslator();
|
||||||
if (english->load("cppcheck_en"))
|
if (english->load("cppcheck_en"))
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ const QStringList TranslationHandler::GetFiles() const
|
||||||
|
|
||||||
bool TranslationHandler::SetLanguage(const int index, QString &error)
|
bool TranslationHandler::SetLanguage(const int index, QString &error)
|
||||||
{
|
{
|
||||||
//If english is the language
|
//If English is the language
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
//Just remove all extra translators
|
//Just remove all extra translators
|
||||||
|
@ -147,7 +147,7 @@ int TranslationHandler::SuggestLanguage() const
|
||||||
//And see if we can find it from our list of language files
|
//And see if we can find it from our list of language files
|
||||||
int index = mFiles.indexOf(file);
|
int index = mFiles.indexOf(file);
|
||||||
|
|
||||||
//If nothing found, return english
|
//If nothing found, return English
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -89,7 +89,7 @@ void XmlReport::WriteError(const ErrorItem &error)
|
||||||
/*
|
/*
|
||||||
Error example from the core program in xml
|
Error example from the core program in xml
|
||||||
<error file="gui/test.cpp" line="14" id="mismatchAllocDealloc" severity="error" msg="Mismatching allocation and deallocation: k"/>
|
<error file="gui/test.cpp" line="14" id="mismatchAllocDealloc" severity="error" msg="Mismatching allocation and deallocation: k"/>
|
||||||
The callstack seems to be ignored here aswell, instead last item of the stack is used
|
The callstack seems to be ignored here as well, instead last item of the stack is used
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mXmlWriter->writeStartElement(ErrorElementName);
|
mXmlWriter->writeStartElement(ErrorElementName);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
cppcheck-htmlreport
|
cppcheck-htmlreport
|
||||||
|
|
||||||
This is a little utility to generate a html report of a xml file produced by
|
This is a little utility to generate a html report of a XML file produced by
|
||||||
cppcheck.
|
cppcheck.
|
||||||
|
|
||||||
The utility is implemented in python and require the pygments module to be
|
The utility is implemented in Python and require the pygments module to be
|
||||||
able to generate syntax highlighted source code.
|
able to generate syntax highlighted source code.
|
||||||
|
|
|
@ -753,7 +753,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
|
||||||
if (Token::Match(tok2->tokAt(4), "%var% =|+=|-=") && MathLib::toLongNumber(max_counter_value) <= size)
|
if (Token::Match(tok2->tokAt(4), "%var% =|+=|-=") && MathLib::toLongNumber(max_counter_value) <= size)
|
||||||
condition_out_of_bounds = false;
|
condition_out_of_bounds = false;
|
||||||
|
|
||||||
// Goto the end paranthesis of the for-statement: "for (x; y; z)" ..
|
// Goto the end parenthesis of the for-statement: "for (x; y; z)" ..
|
||||||
tok2 = tok->next()->link();
|
tok2 = tok->next()->link();
|
||||||
if (!tok2 || !tok2->tokAt(5))
|
if (!tok2 || !tok2->tokAt(5))
|
||||||
break;
|
break;
|
||||||
|
@ -922,7 +922,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
||||||
if (Token::Match(tok2->tokAt(4), "%var% =|+=|-=") && MathLib::toLongNumber(max_counter_value) <= (int)arrayInfo.num[0])
|
if (Token::Match(tok2->tokAt(4), "%var% =|+=|-=") && MathLib::toLongNumber(max_counter_value) <= (int)arrayInfo.num[0])
|
||||||
condition_out_of_bounds = false;
|
condition_out_of_bounds = false;
|
||||||
|
|
||||||
// Goto the end paranthesis of the for-statement: "for (x; y; z)" ..
|
// Goto the end parenthesis of the for-statement: "for (x; y; z)" ..
|
||||||
tok2 = tok->next()->link();
|
tok2 = tok->next()->link();
|
||||||
if (!tok2 || !tok2->tokAt(5))
|
if (!tok2 || !tok2->tokAt(5))
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -211,7 +211,7 @@ void CheckClass::privateFunctions()
|
||||||
if (!info->isClassOrStruct())
|
if (!info->isClassOrStruct())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// dont check derived classes
|
// don’t check derived classes
|
||||||
if (!info->derivedFrom.empty())
|
if (!info->derivedFrom.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -1403,7 +1403,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
|
|
||||||
// Inside class function.. if the var is passed as a parameter then
|
// Inside class function.. if the var is passed as a parameter then
|
||||||
// just add a "::use"
|
// just add a "::use"
|
||||||
// The "::use" means that a member function was probably called but it wasn't analyzed further
|
// The "::use" means that a member function was probably called but it wasn't analysed further
|
||||||
else if (classmember)
|
else if (classmember)
|
||||||
{
|
{
|
||||||
if (noreturn.find(tok->str()) != noreturn.end())
|
if (noreturn.find(tok->str()) != noreturn.end())
|
||||||
|
@ -2225,7 +2225,7 @@ const Token *CheckMemoryLeakInFunction::findleak(const Token *tokens)
|
||||||
while (last->next())
|
while (last->next())
|
||||||
last = last->next();
|
last = last->next();
|
||||||
|
|
||||||
// not a leak if exit is called before the end of the funcion
|
// not a leak if exit is called before the end of the function
|
||||||
if (!Token::Match(last->tokAt(-2), "exit|callfunc ; }"))
|
if (!Token::Match(last->tokAt(-2), "exit|callfunc ; }"))
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,11 +216,11 @@ void CheckNullPointer::nullPointerLinkedList()
|
||||||
if (!Token::simpleMatch(tok1->next()->link(), ") {"))
|
if (!Token::simpleMatch(tok1->next()->link(), ") {"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// is there any dereferencing occuring in the for statement..
|
// is there any dereferencing occurring in the for statement..
|
||||||
unsigned int parlevel2 = 1;
|
unsigned int parlevel2 = 1;
|
||||||
for (const Token *tok2 = tok1->tokAt(2); tok2; tok2 = tok2->next())
|
for (const Token *tok2 = tok1->tokAt(2); tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
// Parantheses..
|
// Parentheses..
|
||||||
if (tok2->str() == "(")
|
if (tok2->str() == "(")
|
||||||
++parlevel2;
|
++parlevel2;
|
||||||
else if (tok2->str() == ")")
|
else if (tok2->str() == ")")
|
||||||
|
@ -230,7 +230,7 @@ void CheckNullPointer::nullPointerLinkedList()
|
||||||
--parlevel2;
|
--parlevel2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dereferencing a variable inside the "for" parantheses..
|
// Dereferencing a variable inside the "for" parentheses..
|
||||||
else if (Token::Match(tok2, "%var% . %var%"))
|
else if (Token::Match(tok2, "%var% . %var%"))
|
||||||
{
|
{
|
||||||
const unsigned int varid(tok2->varId());
|
const unsigned int varid(tok2->varId());
|
||||||
|
@ -532,7 +532,7 @@ void CheckNullPointer::nullPointer()
|
||||||
nullPointerByCheckAndDeRef();
|
nullPointerByCheckAndDeRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Derefencing null constant (simplified token list) */
|
/** Dereferencing null constant (simplified token list) */
|
||||||
void CheckNullPointer::nullConstantDereference()
|
void CheckNullPointer::nullConstantDereference()
|
||||||
{
|
{
|
||||||
// this is kept at 0 for all scopes that are not executing
|
// this is kept at 0 for all scopes that are not executing
|
||||||
|
|
|
@ -1041,7 +1041,7 @@ static int doAssignment(Variables &variables, const Token *tok, bool dereference
|
||||||
if (scope == var1->_scope)
|
if (scope == var1->_scope)
|
||||||
replace = true;
|
replace = true;
|
||||||
|
|
||||||
// not in same scope as decelaration
|
// not in same scope as declaration
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::set<Scope *>::iterator assignment;
|
std::set<Scope *>::iterator assignment;
|
||||||
|
@ -1070,7 +1070,7 @@ static int doAssignment(Variables &variables, const Token *tok, bool dereference
|
||||||
// assignment in this scope
|
// assignment in this scope
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// replace when only one other assingnment
|
// replace when only one other assignment
|
||||||
if (var1->_assignments.size() == 1)
|
if (var1->_assignments.size() == 1)
|
||||||
replace = true;
|
replace = true;
|
||||||
|
|
||||||
|
@ -1107,7 +1107,7 @@ static int doAssignment(Variables &variables, const Token *tok, bool dereference
|
||||||
{
|
{
|
||||||
if (var1->_type == Variables::pointer && !dereference)
|
if (var1->_type == Variables::pointer && !dereference)
|
||||||
{
|
{
|
||||||
// check if variable decelaration is in this scope
|
// check if variable declaration is in this scope
|
||||||
if (var1->_scope == scope)
|
if (var1->_scope == scope)
|
||||||
variables.clearAliases(varid1);
|
variables.clearAliases(varid1);
|
||||||
else
|
else
|
||||||
|
|
|
@ -115,7 +115,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// funcname ( => Assert that the end paranthesis isn't followed by {
|
// funcname ( => Assert that the end parenthesis isn't followed by {
|
||||||
if (Token::Match(funcname, "%var% ("))
|
if (Token::Match(funcname, "%var% ("))
|
||||||
{
|
{
|
||||||
int parlevel = 0;
|
int parlevel = 0;
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Call all "getErrorMessages" in all registered Check classes.
|
* @brief Call all "getErrorMessages" in all registered Check classes.
|
||||||
* Also print out xml header and footer.
|
* Also print out XML header and footer.
|
||||||
*/
|
*/
|
||||||
void getErrorMessages();
|
void getErrorMessages();
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Format the error message in XML format
|
* Format the error message in XML format
|
||||||
* @param verbose use verbose message
|
* @param verbose use verbose message
|
||||||
* @param ver xml version
|
* @param ver XML version
|
||||||
*/
|
*/
|
||||||
std::string toXML(bool verbose, int ver) const;
|
std::string toXML(bool verbose, int ver) const;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Replace all occurances of searchFor with replaceWith in the
|
* Replace all occurrences of searchFor with replaceWith in the
|
||||||
* given source.
|
* given source.
|
||||||
* @param source The string to modify
|
* @param source The string to modify
|
||||||
* @param searchFor What should be searched for
|
* @param searchFor What should be searched for
|
||||||
|
|
|
@ -225,7 +225,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
||||||
{
|
{
|
||||||
std::ostringstream errmsg;
|
std::ostringstream errmsg;
|
||||||
errmsg << "The code contains characters that are unhandled. "
|
errmsg << "The code contains characters that are unhandled. "
|
||||||
<< "Neither unicode nor extended ascii are supported. "
|
<< "Neither unicode nor extended ASCII are supported. "
|
||||||
<< "(line=" << lineno << ", character code=" << std::hex << (int(ch) & 0xff) << ")";
|
<< "(line=" << lineno << ", character code=" << std::hex << (int(ch) & 0xff) << ")";
|
||||||
writeError(filename, lineno, _errorLogger, "syntaxError", errmsg.str());
|
writeError(filename, lineno, _errorLogger, "syntaxError", errmsg.str());
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1546,7 @@ void Preprocessor::handleIncludes(std::string &code,
|
||||||
(headerType == SystemHeader && systemIncludes.find(tempFile) != systemIncludes.end()))
|
(headerType == SystemHeader && systemIncludes.find(tempFile) != systemIncludes.end()))
|
||||||
{
|
{
|
||||||
// We have processed this file already once, skip
|
// We have processed this file already once, skip
|
||||||
// it this time to avoid ethernal loop.
|
// it this time to avoid eternal loop.
|
||||||
fin.close();
|
fin.close();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1645,7 +1645,7 @@ static void skipstring(const std::string &line, std::string::size_type &pos)
|
||||||
* @param pos in: Position to the '('. out: Position to the ')'
|
* @param pos in: Position to the '('. out: Position to the ')'
|
||||||
* @param params out: The extracted parameters
|
* @param params out: The extracted parameters
|
||||||
* @param numberOfNewlines out: number of newlines in the macro call
|
* @param numberOfNewlines out: number of newlines in the macro call
|
||||||
* @param endFound out: was the end paranthesis found?
|
* @param endFound out: was the end parenthesis found?
|
||||||
*/
|
*/
|
||||||
static void getparams(const std::string &line,
|
static void getparams(const std::string &line,
|
||||||
std::string::size_type &pos,
|
std::string::size_type &pos,
|
||||||
|
@ -1663,7 +1663,7 @@ static void getparams(const std::string &line,
|
||||||
if (line[pos] != '(')
|
if (line[pos] != '(')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// parantheses level
|
// parentheses level
|
||||||
int parlevel = 0;
|
int parlevel = 0;
|
||||||
|
|
||||||
// current parameter data
|
// current parameter data
|
||||||
|
@ -1672,7 +1672,7 @@ static void getparams(const std::string &line,
|
||||||
// scan for parameters..
|
// scan for parameters..
|
||||||
for (; pos < line.length(); ++pos)
|
for (; pos < line.length(); ++pos)
|
||||||
{
|
{
|
||||||
// increase paranthesis level
|
// increase parenthesis level
|
||||||
if (line[pos] == '(')
|
if (line[pos] == '(')
|
||||||
{
|
{
|
||||||
++parlevel;
|
++parlevel;
|
||||||
|
@ -1680,7 +1680,7 @@ static void getparams(const std::string &line,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// decrease paranthesis level
|
// decrease parenthesis level
|
||||||
else if (line[pos] == ')')
|
else if (line[pos] == ')')
|
||||||
{
|
{
|
||||||
--parlevel;
|
--parlevel;
|
||||||
|
@ -1759,7 +1759,7 @@ private:
|
||||||
/** prefix that is used by cppcheck to separate macro parameters. Always "__cppcheck__" */
|
/** prefix that is used by cppcheck to separate macro parameters. Always "__cppcheck__" */
|
||||||
const std::string _prefix;
|
const std::string _prefix;
|
||||||
|
|
||||||
/** The macro has parantheses but no parameters.. "AAA()" */
|
/** The macro has parentheses but no parameters.. "AAA()" */
|
||||||
bool _nopar;
|
bool _nopar;
|
||||||
|
|
||||||
/** disabled assignment operator */
|
/** disabled assignment operator */
|
||||||
|
@ -1892,7 +1892,7 @@ public:
|
||||||
return _variadic;
|
return _variadic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check if this macro has parantheses but no parameters */
|
/** Check if this macro has parentheses but no parameters */
|
||||||
bool nopar() const
|
bool nopar() const
|
||||||
{
|
{
|
||||||
return _nopar;
|
return _nopar;
|
||||||
|
@ -2301,10 +2301,10 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
|
||||||
// number of newlines within macro use
|
// number of newlines within macro use
|
||||||
unsigned int numberOfNewlines = 0;
|
unsigned int numberOfNewlines = 0;
|
||||||
|
|
||||||
// if the macro has parantheses, get parameters
|
// if the macro has parentheses, get parameters
|
||||||
if (macro->variadic() || macro->nopar() || macro->params().size())
|
if (macro->variadic() || macro->nopar() || macro->params().size())
|
||||||
{
|
{
|
||||||
// is the end paranthesis found?
|
// is the end parenthesis found?
|
||||||
bool endFound = false;
|
bool endFound = false;
|
||||||
|
|
||||||
getparams(line,pos2,params,numberOfNewlines,endFound);
|
getparams(line,pos2,params,numberOfNewlines,endFound);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
* @param srcCodeStream The (file/string) stream to read from.
|
* @param srcCodeStream The (file/string) stream to read from.
|
||||||
* @param processedFile Give reference to empty string as a parameter,
|
* @param processedFile Give reference to empty string as a parameter,
|
||||||
* function will fill processed file here. Use this also as a filedata parameter
|
* function will fill processed file here. Use this also as a filedata parameter
|
||||||
* to getcode() if you recieved more than once configurations.
|
* to getcode() if you received more than once configurations.
|
||||||
* @param resultConfigurations List of configurations. Pass these one by one
|
* @param resultConfigurations List of configurations. Pass these one by one
|
||||||
* to getcode() with processedFile.
|
* to getcode() with processedFile.
|
||||||
* @param filename The name of the file to check e.g. "src/main.cpp"
|
* @param filename The name of the file to check e.g. "src/main.cpp"
|
||||||
|
@ -147,9 +147,9 @@ protected:
|
||||||
std::string removeComments(const std::string &str, const std::string &filename, Settings *settings);
|
std::string removeComments(const std::string &str, const std::string &filename, Settings *settings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove redundant parantheses from preprocessor commands. This should only be called from read().
|
* Remove redundant parentheses from preprocessor commands. This should only be called from read().
|
||||||
* @param str Code processed by read().
|
* @param str Code processed by read().
|
||||||
* @return code with reduced parantheses
|
* @return code with reduced parentheses
|
||||||
*/
|
*/
|
||||||
static std::string removeParantheses(const std::string &str);
|
static std::string removeParantheses(const std::string &str);
|
||||||
|
|
||||||
|
|
|
@ -84,10 +84,10 @@ public:
|
||||||
/** @brief Force checking the files with "too many" configurations (--force). */
|
/** @brief Force checking the files with "too many" configurations (--force). */
|
||||||
bool _force;
|
bool _force;
|
||||||
|
|
||||||
/** @brief write xml results (--xml) */
|
/** @brief write XML results (--xml) */
|
||||||
bool _xml;
|
bool _xml;
|
||||||
|
|
||||||
/** @brief xml version (--xmlver=..) */
|
/** @brief XML version (--xmlver=..) */
|
||||||
int _xml_version;
|
int _xml_version;
|
||||||
|
|
||||||
/** @brief How many processes/threads should do checking at the same
|
/** @brief How many processes/threads should do checking at the same
|
||||||
|
@ -174,7 +174,7 @@ public:
|
||||||
/** @brief defines given by the user */
|
/** @brief defines given by the user */
|
||||||
std::string userDefines;
|
std::string userDefines;
|
||||||
|
|
||||||
/** @brief Experimentat 2 pass checking of files */
|
/** @brief Experimental 2 pass checking of files */
|
||||||
bool test_2_pass;
|
bool test_2_pass;
|
||||||
|
|
||||||
/** @brief --report-progress */
|
/** @brief --report-progress */
|
||||||
|
|
|
@ -388,7 +388,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
if (func->type == SymbolDatabase::Func::Constructor)
|
if (func->type == SymbolDatabase::Func::Constructor)
|
||||||
{
|
{
|
||||||
// check for no arguments: func ( )
|
// check for no arguments: func ( )
|
||||||
/** @todo check for arguents with default values someday */
|
/** @todo check for arguments with default values someday */
|
||||||
if (func->argDef->next() == func->argDef->link())
|
if (func->argDef->next() == func->argDef->link())
|
||||||
{
|
{
|
||||||
hasDefaultConstructor = true;
|
hasDefaultConstructor = true;
|
||||||
|
@ -397,7 +397,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// User defined types with user defined defaut constructor doesn't need initialization.
|
// User defined types with user defined default constructor doesn't need initialization.
|
||||||
// We assume the default constructor initializes everything.
|
// We assume the default constructor initializes everything.
|
||||||
// Another check will figure out if the constructor actually initializes everything.
|
// Another check will figure out if the constructor actually initializes everything.
|
||||||
if (hasDefaultConstructor)
|
if (hasDefaultConstructor)
|
||||||
|
@ -960,7 +960,7 @@ void SymbolDatabase::SpaceInfo::getVarList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Borland C++: Skip all variables in the __published section.
|
// Borland C++: Skip all variables in the __published section.
|
||||||
// These are automaticly initialized.
|
// These are automatically initialized.
|
||||||
else if (tok->str() == "__published:")
|
else if (tok->str() == "__published:")
|
||||||
{
|
{
|
||||||
for (; tok; tok = tok->next())
|
for (; tok; tok = tok->next())
|
||||||
|
|
|
@ -250,12 +250,12 @@ void Tokenizer::createTokens(std::istream &code)
|
||||||
std::string CurrentToken;
|
std::string CurrentToken;
|
||||||
|
|
||||||
// lineNumbers holds line numbers for files in fileIndexes
|
// lineNumbers holds line numbers for files in fileIndexes
|
||||||
// every time an include file is complitely parsed, last item in the vector
|
// every time an include file is completely parsed, last item in the vector
|
||||||
// is removed and lineno is set to point to that value.
|
// is removed and lineno is set to point to that value.
|
||||||
std::vector<unsigned int> lineNumbers;
|
std::vector<unsigned int> lineNumbers;
|
||||||
|
|
||||||
// fileIndexes holds index for _files vector about currently parsed files
|
// fileIndexes holds index for _files vector about currently parsed files
|
||||||
// every time an include file is complitely parsed, last item in the vector
|
// every time an include file is completely parsed, last item in the vector
|
||||||
// is removed and FileIndex is set to point to that value.
|
// is removed and FileIndex is set to point to that value.
|
||||||
std::vector<unsigned int> fileIndexes;
|
std::vector<unsigned int> fileIndexes;
|
||||||
|
|
||||||
|
@ -1190,13 +1190,13 @@ void Tokenizer::simplifyTypedef()
|
||||||
|
|
||||||
if (simplifyType)
|
if (simplifyType)
|
||||||
{
|
{
|
||||||
// There are 2 catagories of typedef substitutions:
|
// There are 2 categories of typedef substitutions:
|
||||||
// 1. variable declarations that preserve the variable name like
|
// 1. variable declarations that preserve the variable name like
|
||||||
// global, local, and function parameters
|
// global, local, and function parameters
|
||||||
// 2. not variable declarations that have no name like derived
|
// 2. not variable declarations that have no name like derived
|
||||||
// classes, casts, operators, and template parameters
|
// classes, casts, operators, and template parameters
|
||||||
|
|
||||||
// try to determine which catagory this substitution is
|
// try to determine which category this substitution is
|
||||||
bool isDerived = false;
|
bool isDerived = false;
|
||||||
bool inCast = false;
|
bool inCast = false;
|
||||||
bool inTemplate = false;
|
bool inTemplate = false;
|
||||||
|
@ -2172,7 +2172,7 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
// Remove __builtin_expect, likely and unlikely
|
// Remove __builtin_expect, likely and unlikely
|
||||||
simplifyBuiltinExpect();
|
simplifyBuiltinExpect();
|
||||||
|
|
||||||
// colapse compound standard types into a single token
|
// collapse compound standard types into a single token
|
||||||
// unsigned long long int => long _isUnsigned=true,_isLong=true
|
// unsigned long long int => long _isUnsigned=true,_isLong=true
|
||||||
simplifyStdType();
|
simplifyStdType();
|
||||||
|
|
||||||
|
@ -2204,7 +2204,7 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
|
|
||||||
simplifyVariableMultipleAssign();
|
simplifyVariableMultipleAssign();
|
||||||
|
|
||||||
// Remove redundant parantheses
|
// Remove redundant parentheses
|
||||||
simplifyRedundantParanthesis();
|
simplifyRedundantParanthesis();
|
||||||
|
|
||||||
// Handle templates..
|
// Handle templates..
|
||||||
|
@ -3329,7 +3329,7 @@ void Tokenizer::setVarId()
|
||||||
// Found a class function..
|
// Found a class function..
|
||||||
if (Token::Match(tok2, funcpattern.c_str()))
|
if (Token::Match(tok2, funcpattern.c_str()))
|
||||||
{
|
{
|
||||||
// Goto the end paranthesis..
|
// Goto the end parenthesis..
|
||||||
tok2 = tok2->tokAt(3)->link();
|
tok2 = tok2->tokAt(3)->link();
|
||||||
if (!tok2)
|
if (!tok2)
|
||||||
break;
|
break;
|
||||||
|
@ -4049,7 +4049,7 @@ bool Tokenizer::simplifyTokenList()
|
||||||
modified |= simplifyCalculations();
|
modified |= simplifyCalculations();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove redundant parantheses in return..
|
// Remove redundant parentheses in return..
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
while (Token::simpleMatch(tok, "return ("))
|
while (Token::simpleMatch(tok, "return ("))
|
||||||
|
@ -5470,7 +5470,7 @@ void Tokenizer::simplifyIfAssign()
|
||||||
if (isNot)
|
if (isNot)
|
||||||
tok->next()->deleteNext();
|
tok->next()->deleteNext();
|
||||||
|
|
||||||
// Delete paranthesis.. and remember how many there are with
|
// Delete parenthesis.. and remember how many there are with
|
||||||
// their links.
|
// their links.
|
||||||
std::stack<Token *> braces;
|
std::stack<Token *> braces;
|
||||||
while (tok->next()->str() == "(")
|
while (tok->next()->str() == "(")
|
||||||
|
@ -6423,7 +6423,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
||||||
tok->link()->previous() == tok->next()->link())
|
tok->link()->previous() == tok->next()->link())
|
||||||
{
|
{
|
||||||
// We have "(( *something* ))", remove the inner
|
// We have "(( *something* ))", remove the inner
|
||||||
// paranthesis
|
// parenthesis
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
tok->link()->tokAt(-2)->deleteNext();
|
tok->link()->tokAt(-2)->deleteNext();
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -6433,7 +6433,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
||||||
tok->link()->previous() == tok->tokAt(2)->link())
|
tok->link()->previous() == tok->tokAt(2)->link())
|
||||||
{
|
{
|
||||||
// We have "( func ( *something* ))", remove the outer
|
// We have "( func ( *something* ))", remove the outer
|
||||||
// paranthesis
|
// parenthesis
|
||||||
tok->link()->deleteThis();
|
tok->link()->deleteThis();
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -6442,7 +6442,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
||||||
while (Token::Match(tok->previous(), "[;{] ( delete %var% ) ;"))
|
while (Token::Match(tok->previous(), "[;{] ( delete %var% ) ;"))
|
||||||
{
|
{
|
||||||
// We have "( delete var )", remove the outer
|
// We have "( delete var )", remove the outer
|
||||||
// paranthesis
|
// parenthesis
|
||||||
tok->tokAt(3)->deleteThis();
|
tok->tokAt(3)->deleteThis();
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -6451,7 +6451,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
||||||
while (Token::Match(tok->previous(), "[;{] ( delete [ ] %var% ) ;"))
|
while (Token::Match(tok->previous(), "[;{] ( delete [ ] %var% ) ;"))
|
||||||
{
|
{
|
||||||
// We have "( delete [] var )", remove the outer
|
// We have "( delete [] var )", remove the outer
|
||||||
// paranthesis
|
// parenthesis
|
||||||
tok->tokAt(5)->deleteThis();
|
tok->tokAt(5)->deleteThis();
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -6469,7 +6469,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
||||||
|
|
||||||
if (Token::Match(tok->previous(), "[(!*;{}] ( %var% )") && tok->next()->varId() != 0)
|
if (Token::Match(tok->previous(), "[(!*;{}] ( %var% )") && tok->next()->varId() != 0)
|
||||||
{
|
{
|
||||||
// We have "( var )", remove the paranthesis
|
// We have "( var )", remove the parenthesis
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -6478,7 +6478,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
||||||
|
|
||||||
if (Token::Match(tok->previous(), "[(!] ( %var% . %var% )"))
|
if (Token::Match(tok->previous(), "[(!] ( %var% . %var% )"))
|
||||||
{
|
{
|
||||||
// We have "( var . var )", remove the paranthesis
|
// We have "( var . var )", remove the parenthesis
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
|
@ -6539,11 +6539,11 @@ bool Tokenizer::simplifyCalculations()
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
// Remove parantheses around variable..
|
// Remove parentheses around variable..
|
||||||
// keep parantheses here: dynamic_cast<Fred *>(p);
|
// keep parentheses here: dynamic_cast<Fred *>(p);
|
||||||
// keep parantheses here: A operator * (int);
|
// keep parentheses here: A operator * (int);
|
||||||
// keep parantheses here: operator new [] (size_t);
|
// keep parentheses here: operator new [] (size_t);
|
||||||
// keep parantheses here: Functor()(a ... )
|
// keep parentheses here: Functor()(a ... )
|
||||||
if (Token::Match(tok->next(), "( %var% ) [;),+-*/><]]") &&
|
if (Token::Match(tok->next(), "( %var% ) [;),+-*/><]]") &&
|
||||||
!tok->isName() &&
|
!tok->isName() &&
|
||||||
tok->str() != ">" &&
|
tok->str() != ">" &&
|
||||||
|
@ -6601,7 +6601,7 @@ bool Tokenizer::simplifyCalculations()
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove parantheses around number..
|
// Remove parentheses around number..
|
||||||
if (Token::Match(tok->tokAt(-2), "%any% ( %num% )") && !tok->tokAt(-2)->isName())
|
if (Token::Match(tok->tokAt(-2), "%any% ( %num% )") && !tok->tokAt(-2)->isName())
|
||||||
{
|
{
|
||||||
tok = tok->previous();
|
tok = tok->previous();
|
||||||
|
|
|
@ -175,7 +175,7 @@ public:
|
||||||
Token * initVar(Token * tok);
|
Token * initVar(Token * tok);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Colapse compound standard types into a single token.
|
* Collapse compound standard types into a single token.
|
||||||
* unsigned long long int => long _isUnsigned=true,_isLong=true
|
* unsigned long long int => long _isUnsigned=true,_isLong=true
|
||||||
*/
|
*/
|
||||||
void simplifyStdType();
|
void simplifyStdType();
|
||||||
|
@ -201,7 +201,7 @@ public:
|
||||||
void simplifyIfAssign();
|
void simplifyIfAssign();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplify multiple assignmetns.
|
* Simplify multiple assignments.
|
||||||
* Example: "a = b = c = 0;" => "a = 0; b = 0; c = 0;"
|
* Example: "a = b = c = 0;" => "a = 0; b = 0; c = 0;"
|
||||||
*/
|
*/
|
||||||
void simplifyVariableMultipleAssign();
|
void simplifyVariableMultipleAssign();
|
||||||
|
@ -294,7 +294,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool simplifyConditions();
|
bool simplifyConditions();
|
||||||
|
|
||||||
/** Remove reduntant code, e.g. if( false ) { int a; } should be
|
/** Remove redundant code, e.g. if( false ) { int a; } should be
|
||||||
* removed, because it is never executed.
|
* removed, because it is never executed.
|
||||||
* @return true if something is modified
|
* @return true if something is modified
|
||||||
* false if nothing is done.
|
* false if nothing is done.
|
||||||
|
@ -322,7 +322,7 @@ public:
|
||||||
void simplifyStructDecl();
|
void simplifyStructDecl();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove redundant paranthesis:
|
* Remove redundant parenthesis:
|
||||||
* - "((x))" => "(x)"
|
* - "((x))" => "(x)"
|
||||||
* - "(function())" => "function()"
|
* - "(function())" => "function()"
|
||||||
* - "(delete x)" => "delete x"
|
* - "(delete x)" => "delete x"
|
||||||
|
|
|
@ -294,7 +294,7 @@ files, this is not needed.</para>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--xml</option></term>
|
<term><option>--xml</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Write results in xml to error stream</para>
|
<para>Write results in XML to error stream</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Cppcheck should work on any platform that has sufficient cpu and
|
<para>Cppcheck should work on any platform that has sufficient CPU and
|
||||||
memory.</para>
|
memory.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
@ -77,12 +77,12 @@
|
||||||
<section>
|
<section>
|
||||||
<title>Checking all files in a folder</title>
|
<title>Checking all files in a folder</title>
|
||||||
|
|
||||||
<para>Normally a program has many sourcefiles. And you want to check
|
<para>Normally a program has many source files. And you want to check
|
||||||
them all. Cppcheck can check all sourcefiles in a directory:</para>
|
them all. Cppcheck can check all source files in a directory:</para>
|
||||||
|
|
||||||
<programlisting>cppcheck path</programlisting>
|
<programlisting>cppcheck path</programlisting>
|
||||||
|
|
||||||
<para>If "path" is a folder then cppcheck will check all sourcefiles in
|
<para>If "path" is a folder then cppcheck will check all source files in
|
||||||
this folder.</para>
|
this folder.</para>
|
||||||
|
|
||||||
<programlisting>Checking path/file1.cpp...
|
<programlisting>Checking path/file1.cpp...
|
||||||
|
@ -264,7 +264,7 @@ Checking path/file2.cpp...
|
||||||
|
|
||||||
<programlisting>cppcheck --xml file1.cpp</programlisting>
|
<programlisting>cppcheck --xml file1.cpp</programlisting>
|
||||||
|
|
||||||
<para>The xml format is:</para>
|
<para>The XML format is:</para>
|
||||||
|
|
||||||
<programlisting><?xml version="1.0"?>
|
<programlisting><?xml version="1.0"?>
|
||||||
<results>
|
<results>
|
||||||
|
@ -372,7 +372,7 @@ gui/test.cpp,16,error,mismatchAllocDealloc,Mismatching allocation and deallocati
|
||||||
|
|
||||||
<para>The <literal>error id</literal> is the id that you want to suppress.
|
<para>The <literal>error id</literal> is the id that you want to suppress.
|
||||||
The easiest way to get it is to use the <literal>--xml</literal> command
|
The easiest way to get it is to use the <literal>--xml</literal> command
|
||||||
line flag. Copy and paste the <literal>id</literal> string from the xml
|
line flag. Copy and paste the <literal>id</literal> string from the XML
|
||||||
output.</para>
|
output.</para>
|
||||||
|
|
||||||
<para>Here is an example:</para>
|
<para>Here is an example:</para>
|
||||||
|
@ -396,7 +396,7 @@ uninitvar</programlisting>
|
||||||
some tweaking you can improve the checking.</para>
|
some tweaking you can improve the checking.</para>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Userdefined allocation/deallocation functions</title>
|
<title>User-defined allocation/deallocation functions</title>
|
||||||
|
|
||||||
<para><literal>Cppcheck</literal> understands many common allocation and
|
<para><literal>Cppcheck</literal> understands many common allocation and
|
||||||
deallocation functions. But not all.</para>
|
deallocation functions. But not all.</para>
|
||||||
|
@ -493,13 +493,13 @@ int a(int sz)
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
||||||
<chapter>
|
<chapter>
|
||||||
<title>Html report</title>
|
<title>HTML report</title>
|
||||||
|
|
||||||
<para>You can convert the xml output from cppcheck into a html report.
|
<para>You can convert the XML output from cppcheck into a HTML report.
|
||||||
You'll need python and the pygments module
|
You'll need Python and the pygments module
|
||||||
(<uri>http://pygments.org/</uri>) for this to work. In the Cppcheck source
|
(<uri>http://pygments.org/</uri>) for this to work. In the Cppcheck source
|
||||||
tree there is a folder "htmlreport" that contains a script that transforms
|
tree there is a folder "htmlreport" that contains a script that transforms
|
||||||
a Cppcheck xml file into html output.</para>
|
a Cppcheck XML file into HTML output.</para>
|
||||||
|
|
||||||
<para>This command generates the help screen:</para>
|
<para>This command generates the help screen:</para>
|
||||||
|
|
||||||
|
@ -550,7 +550,7 @@ htmlreport/cppcheck-htmlreport --file=err.xml --report-dir=test1 --source-dir=.<
|
||||||
<para>You can show/hide certain types of messages through the
|
<para>You can show/hide certain types of messages through the
|
||||||
<literal>View</literal> menu.</para>
|
<literal>View</literal> menu.</para>
|
||||||
|
|
||||||
<para>Results can be saved to an xml file that can later be opened. See
|
<para>Results can be saved to an XML file that can later be opened. See
|
||||||
<literal>Save results to file</literal> and <literal>Open
|
<literal>Save results to file</literal> and <literal>Open
|
||||||
XML</literal>.</para>
|
XML</literal>.</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -26,7 +26,7 @@ Compiling
|
||||||
|
|
||||||
qmake
|
qmake
|
||||||
=====
|
=====
|
||||||
You can use the gui/gui.pro file to build the gui.
|
You can use the gui/gui.pro file to build the GUI.
|
||||||
cd gui
|
cd gui
|
||||||
qmake
|
qmake
|
||||||
make
|
make
|
||||||
|
|
|
@ -18,7 +18,7 @@ tools, libraries or headers so you cannot compile 64-bit binaries without
|
||||||
Windows SDK.
|
Windows SDK.
|
||||||
|
|
||||||
To compile 64-bit binaries you need to start VS Express to 64-bit environment.
|
To compile 64-bit binaries you need to start VS Express to 64-bit environment.
|
||||||
(by default VS Express starts to 32-bit enviroment). To do this, open Windows
|
(by default VS Express starts to 32-bit environment). To do this, open Windows
|
||||||
SDK Command Prompt and switch to 64-bit environment with command:
|
SDK Command Prompt and switch to 64-bit environment with command:
|
||||||
> setenv /x64 /debug
|
> setenv /x64 /debug
|
||||||
|
|
||||||
|
|
|
@ -580,7 +580,7 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// this test needs an assignment test but doesnt have it
|
// this test needs an assignment test but doesn’t have it
|
||||||
checkOpertorEqToSelf(
|
checkOpertorEqToSelf(
|
||||||
"class A\n"
|
"class A\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -1816,7 +1816,7 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:11]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:11]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
|
||||||
|
|
||||||
// constructor in seperate namespace
|
// constructor in separate namespace
|
||||||
checkUninitVar("namespace Output\n"
|
checkUninitVar("namespace Output\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" class Foo\n"
|
" class Foo\n"
|
||||||
|
@ -1835,7 +1835,7 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:13]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:13]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
|
||||||
|
|
||||||
// constructor in different seperate namespace
|
// constructor in different separate namespace
|
||||||
checkUninitVar("namespace Output\n"
|
checkUninitVar("namespace Output\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" class Foo\n"
|
" class Foo\n"
|
||||||
|
@ -1854,7 +1854,7 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// constructor in different seperate namespace (won't compile)
|
// constructor in different separate namespace (won't compile)
|
||||||
checkUninitVar("namespace Output\n"
|
checkUninitVar("namespace Output\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" class Foo\n"
|
" class Foo\n"
|
||||||
|
@ -1873,7 +1873,7 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// constructor in nested seperate namespace
|
// constructor in nested separate namespace
|
||||||
checkUninitVar("namespace A\n"
|
checkUninitVar("namespace A\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" namespace Output\n"
|
" namespace Output\n"
|
||||||
|
@ -1895,7 +1895,7 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:15]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:15]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
|
||||||
|
|
||||||
// constructor in nested different seperate namespace
|
// constructor in nested different separate namespace
|
||||||
checkUninitVar("namespace A\n"
|
checkUninitVar("namespace A\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" namespace Output\n"
|
" namespace Output\n"
|
||||||
|
@ -1917,7 +1917,7 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// constructor in nested different seperate namespace
|
// constructor in nested different separate namespace
|
||||||
checkUninitVar("namespace A\n"
|
checkUninitVar("namespace A\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" namespace Output\n"
|
" namespace Output\n"
|
||||||
|
@ -2467,7 +2467,7 @@ private:
|
||||||
ASSERT_EQUALS("[fred.h:6]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
|
ASSERT_EQUALS("[fred.h:6]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Borland C++: No FP for published pointers - they are automaticly initialized
|
// Borland C++: No FP for published pointers - they are automatically initialized
|
||||||
void uninitVarPublished()
|
void uninitVarPublished()
|
||||||
{
|
{
|
||||||
checkUninitVar("class Fred\n"
|
checkUninitVar("class Fred\n"
|
||||||
|
@ -3264,7 +3264,7 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (style) The function 'Fred::foo' can be const\n"
|
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (style) The function 'Fred::foo' can be const\n"
|
||||||
"[test.cpp:7] -> [test.cpp:4]: (style) The function 'Fred::foo' can be const\n", errout.str());
|
"[test.cpp:7] -> [test.cpp:4]: (style) The function 'Fred::foo' can be const\n", errout.str());
|
||||||
|
|
||||||
// check functions with different or missing paramater names
|
// check functions with different or missing parameter names
|
||||||
checkConst("class Fred {\n"
|
checkConst("class Fred {\n"
|
||||||
" std::string s;\n"
|
" std::string s;\n"
|
||||||
" void foo1(int, int);\n"
|
" void foo1(int, int);\n"
|
||||||
|
|
|
@ -189,7 +189,7 @@ private:
|
||||||
{
|
{
|
||||||
TiXmlDocument doc;
|
TiXmlDocument doc;
|
||||||
doc.Parse(xmlData);
|
doc.Parse(xmlData);
|
||||||
// parsing must be successfull
|
// parsing must be successful
|
||||||
ASSERT_EQUALS(false, doc.Error());
|
ASSERT_EQUALS(false, doc.Error());
|
||||||
// root element must be "results"
|
// root element must be "results"
|
||||||
TiXmlElement* root = doc.FirstChildElement();
|
TiXmlElement* root = doc.FirstChildElement();
|
||||||
|
|
|
@ -197,19 +197,19 @@ private:
|
||||||
ASSERT_EQUALS(false, MathLib::isInt("-1.E+1"));
|
ASSERT_EQUALS(false, MathLib::isInt("-1.E+1"));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt("+1.E-1"));
|
ASSERT_EQUALS(false, MathLib::isInt("+1.E-1"));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" 1.0E+1"));
|
ASSERT_EQUALS(false, MathLib::isInt(" 1.0E+1"));
|
||||||
// with whitspaces in front
|
// with whitespace in front
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" 1.0E-1"));
|
ASSERT_EQUALS(false, MathLib::isInt(" 1.0E-1"));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" -1.0E+1"));
|
ASSERT_EQUALS(false, MathLib::isInt(" -1.0E+1"));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" +1.0E-1"));
|
ASSERT_EQUALS(false, MathLib::isInt(" +1.0E-1"));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" -1.E+1"));
|
ASSERT_EQUALS(false, MathLib::isInt(" -1.E+1"));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" +1.E-1"));
|
ASSERT_EQUALS(false, MathLib::isInt(" +1.E-1"));
|
||||||
// with whitspaces in front and end
|
// with whitespace in front and end
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" 1.0E-1 "));
|
ASSERT_EQUALS(false, MathLib::isInt(" 1.0E-1 "));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" -1.0E+1 "));
|
ASSERT_EQUALS(false, MathLib::isInt(" -1.0E+1 "));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" +1.0E-1 "));
|
ASSERT_EQUALS(false, MathLib::isInt(" +1.0E-1 "));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" -1.E+1 "));
|
ASSERT_EQUALS(false, MathLib::isInt(" -1.E+1 "));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt(" +1.E-1 "));
|
ASSERT_EQUALS(false, MathLib::isInt(" +1.E-1 "));
|
||||||
// with whitspaces in front and end
|
// with whitespace in front and end
|
||||||
ASSERT_EQUALS(false, MathLib::isInt("1.0E-1 "));
|
ASSERT_EQUALS(false, MathLib::isInt("1.0E-1 "));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt("-1.0E+1 "));
|
ASSERT_EQUALS(false, MathLib::isInt("-1.0E+1 "));
|
||||||
ASSERT_EQUALS(false, MathLib::isInt("+1.0E-1 "));
|
ASSERT_EQUALS(false, MathLib::isInt("+1.0E-1 "));
|
||||||
|
|
|
@ -2022,7 +2022,7 @@ private:
|
||||||
Settings settings;
|
Settings settings;
|
||||||
Preprocessor preprocessor(&settings, this);
|
Preprocessor preprocessor(&settings, this);
|
||||||
preprocessor.read(istr, "test.cpp", 0);
|
preprocessor.read(istr, "test.cpp", 0);
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (error) The code contains characters that are unhandled. Neither unicode nor extended ascii are supported. (line=1, character code=c8)\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (error) The code contains characters that are unhandled. Neither Unicode nor extended ASCII are supported. (line=1, character code=c8)\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void unicodeInComment()
|
void unicodeInComment()
|
||||||
|
|
|
@ -51,7 +51,7 @@ private:
|
||||||
TEST_CASE(double_plus);
|
TEST_CASE(double_plus);
|
||||||
TEST_CASE(redundant_plus);
|
TEST_CASE(redundant_plus);
|
||||||
TEST_CASE(parantheses1);
|
TEST_CASE(parantheses1);
|
||||||
TEST_CASE(paranthesesVar); // Remove redundant parantheses around variable .. "( %var% )"
|
TEST_CASE(paranthesesVar); // Remove redundant parentheses around variable .. "( %var% )"
|
||||||
TEST_CASE(declareVar);
|
TEST_CASE(declareVar);
|
||||||
|
|
||||||
TEST_CASE(declareArray);
|
TEST_CASE(declareArray);
|
||||||
|
@ -607,7 +607,7 @@ private:
|
||||||
|
|
||||||
void paranthesesVar()
|
void paranthesesVar()
|
||||||
{
|
{
|
||||||
// remove parantheses..
|
// remove parentheses..
|
||||||
ASSERT_EQUALS("= p ;", tok("= (p);"));
|
ASSERT_EQUALS("= p ;", tok("= (p);"));
|
||||||
ASSERT_EQUALS("if ( a < p ) { }", tok("if(a<(p)){}"));
|
ASSERT_EQUALS("if ( a < p ) { }", tok("if(a<(p)){}"));
|
||||||
ASSERT_EQUALS("void f ( ) { int p ; if ( p == -1 ) { } }", tok("void f(){int p; if((p)==-1){}}"));
|
ASSERT_EQUALS("void f ( ) { int p ; if ( p == -1 ) { } }", tok("void f(){int p; if((p)==-1){}}"));
|
||||||
|
@ -622,7 +622,7 @@ private:
|
||||||
ASSERT_EQUALS("void f ( ) { int * p ; * p = 1 ; }", tok("void f(){int *p; *(p) = 1;}"));
|
ASSERT_EQUALS("void f ( ) { int * p ; * p = 1 ; }", tok("void f(){int *p; *(p) = 1;}"));
|
||||||
ASSERT_EQUALS("void f ( ) { int p ; if ( p ) { } p = 1 ; }", tok("void f(){int p; if ( p ) { } (p) = 1;}"));
|
ASSERT_EQUALS("void f ( ) { int p ; if ( p ) { } p = 1 ; }", tok("void f(){int p; if ( p ) { } (p) = 1;}"));
|
||||||
|
|
||||||
// keep parantheses..
|
// keep parentheses..
|
||||||
ASSERT_EQUALS("= a ;", tok("= (char)a;"));
|
ASSERT_EQUALS("= a ;", tok("= (char)a;"));
|
||||||
ASSERT_EQUALS("cast < char * > ( p )", tok("cast<char *>(p)"));
|
ASSERT_EQUALS("cast < char * > ( p )", tok("cast<char *>(p)"));
|
||||||
ASSERT_EQUALS("return ( a + b ) * c ;", tok("return (a+b)*c;"));
|
ASSERT_EQUALS("return ( a + b ) * c ;", tok("return (a+b)*c;"));
|
||||||
|
@ -2842,7 +2842,7 @@ private:
|
||||||
ASSERT_EQUALS("\"\\\\x61\"", tok("\"\\\\x61\""));
|
ASSERT_EQUALS("\"\\\\x61\"", tok("\"\\\\x61\""));
|
||||||
|
|
||||||
// These tests can fail, if other characters are handled
|
// These tests can fail, if other characters are handled
|
||||||
// more correctly. But fow now all non null characters should
|
// more correctly. But for now all non null characters should
|
||||||
// become 'a'
|
// become 'a'
|
||||||
ASSERT_EQUALS("\"a\"", tok("\"\\x62\""));
|
ASSERT_EQUALS("\"a\"", tok("\"\\x62\""));
|
||||||
ASSERT_EQUALS("\"a\"", tok("\"\\177\""));
|
ASSERT_EQUALS("\"a\"", tok("\"\\177\""));
|
||||||
|
|
|
@ -51,7 +51,7 @@ protected:
|
||||||
void assertEquals(const char *filename, int linenr, const std::string &expected, const std::string &actual, const std::string &msg = "");
|
void assertEquals(const char *filename, int linenr, const std::string &expected, const std::string &actual, const std::string &msg = "");
|
||||||
|
|
||||||
// the vars expected and actual need to be of type double, in order to avoid overflow of unsigned int
|
// the vars expected and actual need to be of type double, in order to avoid overflow of unsigned int
|
||||||
// e.g: ASSERT_EQUALS(-100.0, MathLib::toDoubleNumber("-1.0E+2")); whould not work without this.
|
// e.g: ASSERT_EQUALS(-100.0, MathLib::toDoubleNumber("-1.0E+2")); would not work without this.
|
||||||
void assertEquals(const char *filename, int linenr, double expected, double actual, const std::string &msg="");
|
void assertEquals(const char *filename, int linenr, double expected, double actual, const std::string &msg="");
|
||||||
|
|
||||||
void todoAssertEquals(const char *filename, int linenr, const std::string &expected, const std::string &actual);
|
void todoAssertEquals(const char *filename, int linenr, const std::string &expected, const std::string &actual);
|
||||||
|
|
|
@ -509,7 +509,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Dont remove "(int *)"..
|
// Don’t remove "(int *)"..
|
||||||
void removeCast1()
|
void removeCast1()
|
||||||
{
|
{
|
||||||
const char code[] = "int *f(int *);";
|
const char code[] = "int *f(int *);";
|
||||||
|
|
Loading…
Reference in New Issue