Spell checks
This commit is contained in:
parent
0e4cf7a2d6
commit
675e63b6a7
|
@ -1684,7 +1684,7 @@ void CheckBufferOverrun::checkSprintfCall(const Token *tok, const MathLib::bigin
|
||||||
// and skip to next token.
|
// and skip to next token.
|
||||||
parameters.push_back(0);
|
parameters.push_back(0);
|
||||||
|
|
||||||
// count parantheses for tok3
|
// count parentheses for tok3
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
for (const Token *tok3 = tok2->next(); tok3; tok3 = tok3->next())
|
for (const Token *tok3 = tok2->next(); tok3; tok3 = tok3->next())
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,7 +256,7 @@ void CheckNullPointer::nullPointerLinkedList()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// is there any dereferencing occurring in the for statement
|
// is there any dereferencing occurring in the for statement
|
||||||
// parlevel2 counts the parantheses when using tok2.
|
// parlevel2 counts the parentheses when using tok2.
|
||||||
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())
|
||||||
{
|
{
|
||||||
|
@ -594,7 +594,7 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
||||||
|
|
||||||
// If the if-body ends with a unknown macro then bailout
|
// If the if-body ends with a unknown macro then bailout
|
||||||
{
|
{
|
||||||
// goto the end paranthesis
|
// goto the end parenthesis
|
||||||
const Token *endpar = tok->next()->link();
|
const Token *endpar = tok->next()->link();
|
||||||
const Token *endbody = Token::simpleMatch(endpar, ") {") ? endpar->next()->link() : 0;
|
const Token *endbody = Token::simpleMatch(endpar, ") {") ? endpar->next()->link() : 0;
|
||||||
if (endbody &&
|
if (endbody &&
|
||||||
|
|
|
@ -500,7 +500,7 @@ void CheckStl::pushback()
|
||||||
if (pointerId == 0 || containerId == 0)
|
if (pointerId == 0 || containerId == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Count { , } and parantheses for tok2
|
// Count { , } and parentheses for tok2
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
bool invalidPointer = false;
|
bool invalidPointer = false;
|
||||||
for (const Token *tok2 = tok; indent >= 0 && tok2; tok2 = tok2->next())
|
for (const Token *tok2 = tok; indent >= 0 && tok2; tok2 = tok2->next())
|
||||||
|
@ -566,7 +566,7 @@ void CheckStl::pushback()
|
||||||
// the variable id for the vector
|
// the variable id for the vector
|
||||||
unsigned int vectorid = 0;
|
unsigned int vectorid = 0;
|
||||||
|
|
||||||
// count { , } and parantheses for tok2
|
// count { , } and parentheses for tok2
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
|
|
||||||
std::string invalidIterator;
|
std::string invalidIterator;
|
||||||
|
|
|
@ -185,8 +185,8 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Clean up preprocessor #if statements with Parantheses
|
// Clean up preprocessor #if statements with Parentheses
|
||||||
result = removeParantheses(result);
|
result = removeParentheses(result);
|
||||||
|
|
||||||
// Remove '#if 0' blocks
|
// Remove '#if 0' blocks
|
||||||
if (result.find("#if 0\n") != std::string::npos)
|
if (result.find("#if 0\n") != std::string::npos)
|
||||||
|
@ -654,7 +654,7 @@ std::string Preprocessor::removeIf0(const std::string &code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Preprocessor::removeParantheses(const std::string &str)
|
std::string Preprocessor::removeParentheses(const std::string &str)
|
||||||
{
|
{
|
||||||
if (str.find("\n#if") == std::string::npos && str.compare(0, 3, "#if") != 0)
|
if (str.find("\n#if") == std::string::npos && str.compare(0, 3, "#if") != 0)
|
||||||
return str;
|
return str;
|
||||||
|
@ -680,7 +680,7 @@ std::string Preprocessor::removeParantheses(const std::string &str)
|
||||||
while ((pos = line.find(") ", pos)) != std::string::npos)
|
while ((pos = line.find(") ", pos)) != std::string::npos)
|
||||||
line.erase(pos + 1, 1);
|
line.erase(pos + 1, 1);
|
||||||
|
|
||||||
// Remove inner paranthesis "((..))"..
|
// Remove inner parenthesis "((..))"..
|
||||||
pos = 0;
|
pos = 0;
|
||||||
while ((pos = line.find("((", pos)) != std::string::npos)
|
while ((pos = line.find("((", pos)) != std::string::npos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,7 +156,7 @@ protected:
|
||||||
* @param str Code processed by read().
|
* @param str Code processed by read().
|
||||||
* @return code with reduced parentheses
|
* @return code with reduced parentheses
|
||||||
*/
|
*/
|
||||||
static std::string removeParantheses(const std::string &str);
|
static std::string removeParentheses(const std::string &str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clean up #-preprocessor lines (only)
|
* clean up #-preprocessor lines (only)
|
||||||
|
|
|
@ -2425,7 +2425,7 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
simplifyVariableMultipleAssign();
|
simplifyVariableMultipleAssign();
|
||||||
|
|
||||||
// Remove redundant parentheses
|
// Remove redundant parentheses
|
||||||
simplifyRedundantParanthesis();
|
simplifyRedundantParenthesis();
|
||||||
|
|
||||||
// Handle templates..
|
// Handle templates..
|
||||||
simplifyTemplates();
|
simplifyTemplates();
|
||||||
|
@ -3020,7 +3020,7 @@ void Tokenizer::simplifyTemplatesInstantiate(const Token *tok,
|
||||||
std::string s1(name + " < ");
|
std::string s1(name + " < ");
|
||||||
for (const Token *tok3 = tok2->tokAt(2); tok3 && tok3->str() != ">"; tok3 = tok3->next())
|
for (const Token *tok3 = tok2->tokAt(2); tok3 && tok3->str() != ">"; tok3 = tok3->next())
|
||||||
{
|
{
|
||||||
// #2648 - unhandled paranthesis => bail out
|
// #2648 - unhandled parenthesis => bail out
|
||||||
if (tok3->str() == "(")
|
if (tok3->str() == "(")
|
||||||
{
|
{
|
||||||
s.clear();
|
s.clear();
|
||||||
|
@ -3705,7 +3705,7 @@ void Tokenizer::setVarId()
|
||||||
--indentlevel;
|
--indentlevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip parantheses..
|
// skip parentheses..
|
||||||
else if (tok2->str() == "(")
|
else if (tok2->str() == "(")
|
||||||
tok2 = tok2->link();
|
tok2 = tok2->link();
|
||||||
|
|
||||||
|
@ -4462,7 +4462,7 @@ bool Tokenizer::simplifyTokenList()
|
||||||
elseif();
|
elseif();
|
||||||
simplifyErrNoInWhile();
|
simplifyErrNoInWhile();
|
||||||
simplifyIfAssign();
|
simplifyIfAssign();
|
||||||
simplifyRedundantParanthesis();
|
simplifyRedundantParenthesis();
|
||||||
simplifyIfNot();
|
simplifyIfNot();
|
||||||
simplifyIfNotNull();
|
simplifyIfNotNull();
|
||||||
simplifyIfSameInnerCondition();
|
simplifyIfSameInnerCondition();
|
||||||
|
@ -4492,7 +4492,7 @@ bool Tokenizer::simplifyTokenList()
|
||||||
modified |= simplifyFunctionReturn();
|
modified |= simplifyFunctionReturn();
|
||||||
modified |= simplifyKnownVariables();
|
modified |= simplifyKnownVariables();
|
||||||
modified |= removeReduntantConditions();
|
modified |= removeReduntantConditions();
|
||||||
modified |= simplifyRedundantParanthesis();
|
modified |= simplifyRedundantParenthesis();
|
||||||
modified |= simplifyQuestionMark();
|
modified |= simplifyQuestionMark();
|
||||||
modified |= simplifyCalculations();
|
modified |= simplifyCalculations();
|
||||||
}
|
}
|
||||||
|
@ -7093,7 +7093,7 @@ void Tokenizer::elseif()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Tokenizer::simplifyRedundantParanthesis()
|
bool Tokenizer::simplifyRedundantParenthesis()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
|
@ -9378,7 +9378,7 @@ void Tokenizer::simplifyBuiltinExpect()
|
||||||
{
|
{
|
||||||
if (Token::simpleMatch(tok->next(), "__builtin_expect ("))
|
if (Token::simpleMatch(tok->next(), "__builtin_expect ("))
|
||||||
{
|
{
|
||||||
// Count parantheses for tok2
|
// Count parentheses for tok2
|
||||||
unsigned int parlevel = 0;
|
unsigned int parlevel = 0;
|
||||||
for (Token *tok2 = tok->next(); tok2; tok2 = tok2->next())
|
for (Token *tok2 = tok->next(); tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
|
|
|
@ -381,7 +381,7 @@ public:
|
||||||
* @return true if modifications to token-list are done.
|
* @return true if modifications to token-list are done.
|
||||||
* false if no modifications are done.
|
* false if no modifications are done.
|
||||||
*/
|
*/
|
||||||
bool simplifyRedundantParanthesis();
|
bool simplifyRedundantParenthesis();
|
||||||
|
|
||||||
/** Simplify references */
|
/** Simplify references */
|
||||||
void simplifyReference();
|
void simplifyReference();
|
||||||
|
|
|
@ -50,8 +50,8 @@ private:
|
||||||
TEST_CASE(combine_strings);
|
TEST_CASE(combine_strings);
|
||||||
TEST_CASE(double_plus);
|
TEST_CASE(double_plus);
|
||||||
TEST_CASE(redundant_plus);
|
TEST_CASE(redundant_plus);
|
||||||
TEST_CASE(parantheses1);
|
TEST_CASE(parentheses1);
|
||||||
TEST_CASE(paranthesesVar); // Remove redundant parentheses around variable .. "( %var% )"
|
TEST_CASE(parenthesesVar); // Remove redundant parentheses around variable .. "( %var% )"
|
||||||
TEST_CASE(declareVar);
|
TEST_CASE(declareVar);
|
||||||
|
|
||||||
TEST_CASE(declareArray);
|
TEST_CASE(declareArray);
|
||||||
|
@ -642,13 +642,13 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void parantheses1()
|
void parentheses1()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("<= 110 ;", tok("<= (10+100);"));
|
ASSERT_EQUALS("<= 110 ;", tok("<= (10+100);"));
|
||||||
ASSERT_EQUALS("while ( x ( ) == -1 ) { }", tok("while((x()) == -1){ }"));
|
ASSERT_EQUALS("while ( x ( ) == -1 ) { }", tok("while((x()) == -1){ }"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void paranthesesVar()
|
void parenthesesVar()
|
||||||
{
|
{
|
||||||
// remove parentheses..
|
// remove parentheses..
|
||||||
ASSERT_EQUALS("= p ;", tok("= (p);"));
|
ASSERT_EQUALS("= p ;", tok("= (p);"));
|
||||||
|
|
|
@ -209,17 +209,17 @@ private:
|
||||||
|
|
||||||
TEST_CASE(simplify_function_parameters);
|
TEST_CASE(simplify_function_parameters);
|
||||||
|
|
||||||
TEST_CASE(removeParantheses1); // Ticket #61
|
TEST_CASE(removeParentheses1); // Ticket #61
|
||||||
TEST_CASE(removeParantheses2);
|
TEST_CASE(removeParentheses2);
|
||||||
TEST_CASE(removeParantheses3);
|
TEST_CASE(removeParentheses3);
|
||||||
TEST_CASE(removeParantheses4); // Ticket #390
|
TEST_CASE(removeParentheses4); // Ticket #390
|
||||||
TEST_CASE(removeParantheses5); // Ticket #392
|
TEST_CASE(removeParentheses5); // Ticket #392
|
||||||
TEST_CASE(removeParantheses6);
|
TEST_CASE(removeParentheses6);
|
||||||
TEST_CASE(removeParantheses7);
|
TEST_CASE(removeParentheses7);
|
||||||
TEST_CASE(removeParantheses8); // Ticket #1865
|
TEST_CASE(removeParentheses8); // Ticket #1865
|
||||||
TEST_CASE(removeParantheses9); // Ticket #1962
|
TEST_CASE(removeParentheses9); // Ticket #1962
|
||||||
TEST_CASE(removeParantheses10); // Ticket #2320
|
TEST_CASE(removeParentheses10); // Ticket #2320
|
||||||
TEST_CASE(removeParantheses11); // Ticket #2505
|
TEST_CASE(removeParentheses11); // Ticket #2505
|
||||||
|
|
||||||
TEST_CASE(tokenize_double);
|
TEST_CASE(tokenize_double);
|
||||||
TEST_CASE(tokenize_strings);
|
TEST_CASE(tokenize_strings);
|
||||||
|
@ -3678,7 +3678,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
// Simplify "((..))" into "(..)"
|
// Simplify "((..))" into "(..)"
|
||||||
void removeParantheses1()
|
void removeParentheses1()
|
||||||
{
|
{
|
||||||
const char code[] = "void foo()\n"
|
const char code[] = "void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -3702,7 +3702,7 @@ private:
|
||||||
ASSERT_EQUALS(" void foo ( ) { free ( p ) ; }", ostr.str());
|
ASSERT_EQUALS(" void foo ( ) { free ( p ) ; }", ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeParantheses2()
|
void removeParentheses2()
|
||||||
{
|
{
|
||||||
const char code[] = "void foo()\n"
|
const char code[] = "void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -3727,7 +3727,7 @@ private:
|
||||||
ASSERT_EQUALS(" void foo ( ) { if ( ! s ) { return ; } }", ostr.str());
|
ASSERT_EQUALS(" void foo ( ) { if ( ! s ) { return ; } }", ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeParantheses3()
|
void removeParentheses3()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
const char code[] = "void foo()\n"
|
const char code[] = "void foo()\n"
|
||||||
|
@ -3800,7 +3800,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simplify "( function (..))" into "function (..)"
|
// Simplify "( function (..))" into "function (..)"
|
||||||
void removeParantheses4()
|
void removeParentheses4()
|
||||||
{
|
{
|
||||||
const char code[] = "void foo()\n"
|
const char code[] = "void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -3824,7 +3824,7 @@ private:
|
||||||
ASSERT_EQUALS(" void foo ( ) { free ( p ) ; }", ostr.str());
|
ASSERT_EQUALS(" void foo ( ) { free ( p ) ; }", ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeParantheses5()
|
void removeParentheses5()
|
||||||
{
|
{
|
||||||
// Simplify "( delete x )" into "delete x"
|
// Simplify "( delete x )" into "delete x"
|
||||||
{
|
{
|
||||||
|
@ -3876,7 +3876,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// "!(abc.a)" => "!abc.a"
|
// "!(abc.a)" => "!abc.a"
|
||||||
void removeParantheses6()
|
void removeParentheses6()
|
||||||
{
|
{
|
||||||
const char code[] = "(!(abc.a))";
|
const char code[] = "(!(abc.a))";
|
||||||
|
|
||||||
|
@ -3897,7 +3897,7 @@ private:
|
||||||
ASSERT_EQUALS(" ( ! abc . a )", ostr.str());
|
ASSERT_EQUALS(" ( ! abc . a )", ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeParantheses7()
|
void removeParentheses7()
|
||||||
{
|
{
|
||||||
const char code[] = ";char *p; (delete(p), (p)=0);";
|
const char code[] = ";char *p; (delete(p), (p)=0);";
|
||||||
|
|
||||||
|
@ -3918,7 +3918,7 @@ private:
|
||||||
ASSERT_EQUALS(" ; char * p ; delete p ; ( p ) = 0 ;", ostr.str());
|
ASSERT_EQUALS(" ; char * p ; delete p ; ( p ) = 0 ;", ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeParantheses8()
|
void removeParentheses8()
|
||||||
{
|
{
|
||||||
const char code[] = "struct foo {\n"
|
const char code[] = "struct foo {\n"
|
||||||
" void operator delete(void *obj, size_t sz);\n"
|
" void operator delete(void *obj, size_t sz);\n"
|
||||||
|
@ -3932,17 +3932,17 @@ private:
|
||||||
ASSERT_EQUALS(expected, actual);
|
ASSERT_EQUALS(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeParantheses9()
|
void removeParentheses9()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("void delete ( double num ) ;", tokenizeAndStringify("void delete(double num);", false));
|
ASSERT_EQUALS("void delete ( double num ) ;", tokenizeAndStringify("void delete(double num);", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeParantheses10()
|
void removeParentheses10()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("p = buf + 8 ;", tokenizeAndStringify("p = (buf + 8);", false));
|
ASSERT_EQUALS("p = buf + 8 ;", tokenizeAndStringify("p = (buf + 8);", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeParantheses11()
|
void removeParentheses11()
|
||||||
{
|
{
|
||||||
// #2502
|
// #2502
|
||||||
ASSERT_EQUALS("{ } x ( ) ;", tokenizeAndStringify("{}(x());", false));
|
ASSERT_EQUALS("{ } x ( ) ;", tokenizeAndStringify("{}(x());", false));
|
||||||
|
|
Loading…
Reference in New Issue