Fix up extra whitespaces in match patterns

Detected by new internal check.
This commit is contained in:
Thomas Jarosch 2014-12-30 14:53:41 +01:00
parent 17b47f1ce0
commit 69b31a0743
6 changed files with 7 additions and 7 deletions

View File

@ -925,7 +925,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
const Token *tok2 = tok->next()->link()->next();
for (; tok2; tok2 = tok2->next()) {
if (tok2->varId() == tok->tokAt(2)->varId()) {
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId())) {
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId())) {
terminateStrncpyError(tok, tok->strAt(2));
}

View File

@ -2531,7 +2531,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable * const var
// Struct member is allocated => check if it is also properly deallocated..
else if (Token::Match(tok2->previous(), "[;{}] %varid% . %var% = malloc|strdup|kmalloc (", variable->declarationId())
|| Token::Match(tok2->previous(), "[;{}] %varid% . %var% = new ", variable->declarationId())
|| Token::Match(tok2->previous(), "[;{}] %varid% . %var% = new", variable->declarationId())
|| Token::Match(tok2->previous(), "[;{}] %varid% . %var% = fopen (", variable->declarationId())) {
const unsigned int structid(variable->declarationId());
const unsigned int structmemberid(tok2->tokAt(2)->varId());

View File

@ -1327,8 +1327,8 @@ void CheckStl::checkAutoPointer()
autoPointerError(tok->tokAt(2));
}
}
} else if ((Token::Match(tok, "%var% = new %type% ") && hasArrayEnd(tok)) ||
(Token::Match(tok, "%var% . reset ( new %type% ") && hasArrayEndParen(tok))) {
} else if ((Token::Match(tok, "%var% = new %type%") && hasArrayEnd(tok)) ||
(Token::Match(tok, "%var% . reset ( new %type%") && hasArrayEndParen(tok))) {
std::set<unsigned int>::const_iterator iter = autoPtrVarId.find(tok->varId());
if (iter != autoPtrVarId.end()) {
autoPointerArrayError(tok);

View File

@ -51,7 +51,7 @@ void CheckString::checkAlwaysTrueOrFalseStringCompare()
if (str1 == str2)
alwaysTrueStringVariableCompareError(tok, str1, str2);
tok = tok->tokAt(5);
} else if (Token::Match(tok->tokAt(2), "%var% . c_str ( ) , %var% . c_str ( )")) {
} else if (Token::Match(tok->tokAt(2), "%var% . c_str ( ) , %var% . c_str ( )")) {
const std::string &str1 = tok->strAt(2);
const std::string &str2 = tok->strAt(8);
if (str1 == str2)

View File

@ -1362,7 +1362,7 @@ void Variable::evaluate()
// type var = {x}
// type var = x; gets simplified to: type var ; var = x ;
Token const * declEnd = declEndToken();
if ((Token::Match(declEnd, "; %var% = ") && declEnd->strAt(1) == _name->str()) ||
if ((Token::Match(declEnd, "; %var% =") && declEnd->strAt(1) == _name->str()) ||
Token::Match(declEnd, "=|{"))
setFlag(fHasDefault, true);
}

View File

@ -2500,7 +2500,7 @@ static void setVarIdClassFunction(const std::string &classname,
continue;
if (Token::Match(tok2->tokAt(-4), "%var% :: %var% ::")) // Currently unsupported
continue;
if (Token::Match(tok2->tokAt(-2), "!!this . "))
if (Token::Match(tok2->tokAt(-2), "!!this ."))
continue;
const std::map<std::string,unsigned int>::const_iterator it = varlist.find(tok2->str());