Fixed several bugs from previous commits and added check code that will print errors if varid is 0 when %varid% is given in Match().
This commit is contained in:
parent
3dd3bad0ec
commit
21eaadbe31
|
@ -352,7 +352,7 @@ void CheckClass::constructors()
|
|||
isPrivate = false;
|
||||
|
||||
// Is there a private constructor?
|
||||
else if ( isPrivate && Token::Match(tok, "%varid% (", classNameToken->varId()) )
|
||||
else if ( isPrivate && tok->next() && tok->str() == classNameToken->str() && tok->next()->str() == "(" )
|
||||
{
|
||||
hasPrivateConstructor = true;
|
||||
break;
|
||||
|
@ -370,9 +370,10 @@ void CheckClass::constructors()
|
|||
}
|
||||
|
||||
// Are there a class constructor?
|
||||
const Token *constructor_token = Token::findmatch( tok1, "%any% %varid% (", classNameToken->varId() );
|
||||
std::string tempPattern = "%any% " + classNameToken->str() + " (";
|
||||
const Token *constructor_token = Token::findmatch( tok1, tempPattern.c_str() );
|
||||
while ( Token::Match( constructor_token, "~" ) )
|
||||
constructor_token = Token::findmatch( constructor_token->next(), "%any% %varid% (", classNameToken->varId() );
|
||||
constructor_token = Token::findmatch( constructor_token->next(), tempPattern.c_str() );
|
||||
|
||||
// There are no constructor.
|
||||
if ( ! constructor_token )
|
||||
|
|
|
@ -690,7 +690,8 @@ void CheckOther::CheckCharVariable()
|
|||
break;
|
||||
}
|
||||
|
||||
if ((tok2->str() != ".") && Token::Match(tok2->next(), "%var% [ %varid% ]", tok->varId()))
|
||||
std::string temp = "%var% [ " + tok->str() + " ]";
|
||||
if ((tok2->str() != ".") && Token::Match(tok2->next(), temp.c_str()))
|
||||
{
|
||||
std::ostringstream errmsg;
|
||||
errmsg << _tokenizer->fileLine(tok2->next()) << ": Warning - using char variable as array index";
|
||||
|
@ -698,7 +699,9 @@ void CheckOther::CheckCharVariable()
|
|||
break;
|
||||
}
|
||||
|
||||
if ( Token::Match(tok2, "%var% [&|] %varid%", tok->varId()) || Token::Match(tok2, "%varid% [&|]", tok->varId()) )
|
||||
std::string tempFirst = "%var% [&|] " + tok->str();
|
||||
std::string tempSecond = tok->str() + " [&|]";
|
||||
if ( Token::Match(tok2, tempFirst.c_str()) || Token::Match(tok2, tempSecond.c_str()) )
|
||||
{
|
||||
std::ostringstream errmsg;
|
||||
errmsg << _tokenizer->fileLine(tok2) << ": Warning - using char variable in bit operation";
|
||||
|
|
|
@ -246,6 +246,11 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid, co
|
|||
|
||||
else if (strcmp(str,"%varid%")==0)
|
||||
{
|
||||
if( varid == 0 )
|
||||
{
|
||||
std::cout << "\n###### If you see this, there is a bug ###### Token::Match() - varid was 0" << std::endl;
|
||||
}
|
||||
|
||||
if ( tok->varId() != varid )
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue