From be2a10bfb618aab5fab2ff7e52bd3a551c3b32d2 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sun, 4 Jan 2009 14:46:52 +0000 Subject: [PATCH] Refactoring var1 -> varid --- checkother.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/checkother.cpp b/checkother.cpp index 6d30a6671..801877812 100644 --- a/checkother.cpp +++ b/checkother.cpp @@ -625,28 +625,25 @@ void CheckOther::CheckStructMemberUsage() if (structname && Token::Match(tok, "[{;]")) { - const char *varname = 0; + const Token *variableToken = 0; if (Token::Match(tok->next(), "%type% %var% [;[]")) - varname = tok->strAt( 2 ); + variableToken = tok->tokAt( 2 ); else if (Token::Match(tok->next(), "%type% %type% %var% [;[]")) - varname = tok->strAt( 2 ); + variableToken = tok->tokAt( 2 ); else if (Token::Match(tok->next(), "%type% * %var% [;[]")) - varname = tok->strAt( 3 ); + variableToken = tok->tokAt( 3 ); else if (Token::Match(tok->next(), "%type% %type% * %var% [;[]")) - varname = tok->strAt( 4 ); + variableToken = tok->tokAt( 4 ); else continue; - const char *varnames[2]; - varnames[0] = varname; - varnames[1] = 0; bool used = false; for ( const Token *tok2 = _tokenizer->tokens(); tok2; tok2 = tok2->next() ) { if ( tok->fileIndex() != 0 ) continue; - if (Token::Match(tok2, ". %var1%", 0, varnames)) + if (Token::Match(tok2, ". %varid%", variableToken->varId() )) { if ( Token::simpleMatch(tok2->tokAt(2), "=") ) continue; @@ -658,7 +655,7 @@ void CheckOther::CheckStructMemberUsage() if ( ! used ) { std::ostringstream errmsg; - errmsg << _tokenizer->fileLine(tok) << ": struct member '" << structname << "::" << varname << "' is never read"; + errmsg << _tokenizer->fileLine(tok) << ": struct member '" << structname << "::" << variableToken->str() << "' is never read"; _errorLogger->reportErr(errmsg.str()); } }