Refactoring: %var1% -> %varid%

This commit is contained in:
Reijo Tomperi 2009-01-03 20:53:12 +00:00
parent 5d1d267624
commit fee4d77e7b
2 changed files with 5 additions and 4 deletions

View File

@ -680,8 +680,8 @@ void CheckOther::CheckCharVariable()
// Declaring the variable.. // Declaring the variable..
if ( Token::Match(tok, "[{};(,] char %var% [;=,)]") ) if ( Token::Match(tok, "[{};(,] char %var% [;=,)]") )
{ {
const char *varname[2] = {0}; // Set tok to point to the variable name
varname[0] = tok->strAt( 2); tok = tok->tokAt( 2 );
// Check usage of char variable.. // Check usage of char variable..
int indentlevel = 0; int indentlevel = 0;
@ -697,7 +697,7 @@ void CheckOther::CheckCharVariable()
break; break;
} }
if ((tok2->str() != ".") && Token::Match(tok2->next(), "%var% [ %var1% ]", varname)) if ((tok2->str() != ".") && Token::Match(tok2->next(), "%var% [ %varid% ]", 0, tok->varId()))
{ {
std::ostringstream errmsg; std::ostringstream errmsg;
errmsg << _tokenizer->fileLine(tok2->next()) << ": Warning - using char variable as array index"; errmsg << _tokenizer->fileLine(tok2->next()) << ": Warning - using char variable as array index";
@ -705,7 +705,7 @@ void CheckOther::CheckCharVariable()
break; break;
} }
if ( Token::Match(tok2, "%var% [&|] %var1%", varname) || Token::Match(tok2, "%var1% [&|]", varname) ) if ( Token::Match(tok2, "%var% [&|] %varid%", 0, tok->varId()) || Token::Match(tok2, "%varid% [&|]", 0, tok->varId()) )
{ {
std::ostringstream errmsg; std::ostringstream errmsg;
errmsg << _tokenizer->fileLine(tok2) << ": Warning - using char variable in bit operation"; errmsg << _tokenizer->fileLine(tok2) << ": Warning - using char variable in bit operation";

View File

@ -47,6 +47,7 @@ private:
Tokenizer tokenizer; Tokenizer tokenizer;
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.tokenize( istr, "test.cpp" ); tokenizer.tokenize( istr, "test.cpp" );
tokenizer.setVarId();
// Clear the error buffer.. // Clear the error buffer..
errout.str(""); errout.str("");