Tokenizer: Added a few comments

This commit is contained in:
Daniel Marjamäki 2010-10-31 09:58:44 +01:00
parent 558899dc74
commit 6c19ea7b53
1 changed files with 7 additions and 2 deletions

View File

@ -4365,13 +4365,17 @@ void Tokenizer::simplifyDoWhileAddBraces()
void Tokenizer::simplifyCompoundAssignment()
{
// Simplify compound assignments:
// "a+=b" => "a = a + b"
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (Token::Match(tok, "; %var%"))
{
const Token *vartok = tok->next();
const Token * const vartok = tok->next();
const std::string str = tok->strAt(2);
std::string op;
// Is it a +=|-=|.. ?
std::string op; // operator used in assignment
if (str.size() == 2 && str[1] == '=' && str.find_first_of("+-*/%&|^")==0)
op = str.substr(0, 1);
else if (str=="<<=" || str==">>=")
@ -4379,6 +4383,7 @@ void Tokenizer::simplifyCompoundAssignment()
else
continue;
// modify the token list..
tok = tok->tokAt(2);
tok->str("=");
tok->insertToken(op);