improved the Tokenizer::setVarId to handle function parameters better

This commit is contained in:
Daniel Marjamäki 2009-03-21 21:58:39 +01:00
parent 6fc66d3e2c
commit 0a71771c6a
1 changed files with 7 additions and 7 deletions

View File

@ -617,10 +617,10 @@ void Tokenizer::setVarId()
unsigned int _varId = 0; unsigned int _varId = 0;
for (Token *tok = _tokens; tok; tok = tok->next()) for (Token *tok = _tokens; tok; tok = tok->next())
{ {
if (tok != _tokens && !Token::Match(tok, "[;{}(]")) if (tok != _tokens && !Token::Match(tok, "[,;{}(] %type%"))
continue; continue;
if (Token::Match(tok, "[;{}(] %type%")) if (Token::Match(tok, "[,;{}(] %type%"))
tok = tok->next(); tok = tok->next();
if (Token::Match(tok, "else|return")) if (Token::Match(tok, "else|return"))
@ -629,7 +629,7 @@ void Tokenizer::setVarId()
// Determine name of declared variable.. // Determine name of declared variable..
const char *varname = 0; const char *varname = 0;
Token *tok2 = tok->tokAt(1); Token *tok2 = tok->tokAt(1);
while (tok2 && ! Token::Match(tok2, "[;[=(]")) while (tok2)
{ {
if (tok2->isName()) if (tok2->isName())
varname = tok2->strAt(0); varname = tok2->strAt(0);
@ -639,7 +639,7 @@ void Tokenizer::setVarId()
} }
// Variable declaration found => Set variable ids // Variable declaration found => Set variable ids
if (Token::Match(tok2, "[;[=]") && varname) if (Token::Match(tok2, "[,);[=]") && varname)
{ {
++_varId; ++_varId;
int indentlevel = 0; int indentlevel = 0;
@ -1114,9 +1114,6 @@ void Tokenizer::simplifyTokenList()
// Simplify variable declarations // Simplify variable declarations
simplifyVarDecl(); simplifyVarDecl();
// In case variable declarations have been updated...
setVarId();
// Replace NULL with 0.. // Replace NULL with 0..
for (Token *tok = _tokens; tok; tok = tok->next()) for (Token *tok = _tokens; tok; tok = tok->next())
{ {
@ -1137,6 +1134,9 @@ void Tokenizer::simplifyTokenList()
simplifyIfAddBraces(); simplifyIfAddBraces();
simplifyFunctionParameters(); simplifyFunctionParameters();
// In case variable declarations have been updated...
setVarId();
elseif(); elseif();
for (Token *tok = _tokens; tok; tok = tok->next()) for (Token *tok = _tokens; tok; tok = tok->next())