Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress..

This commit is contained in:
Edoardo Prezioso 2012-01-30 15:08:01 +01:00
parent 9438d1c2d0
commit fa077ede94
1 changed files with 16 additions and 16 deletions

View File

@ -1129,11 +1129,11 @@ void Tokenizer::simplifyTypedef()
} }
// check for end or another // check for end or another
if (Token::Match(tok->tokAt(offset), ";|,")) if (Token::Match(tokOffset, ";|,"))
tok = tok->tokAt(offset); tok = tokOffset;
// or a function typedef // or a function typedef
else if (Token::simpleMatch(tok->tokAt(offset), "(")) { else if (tokOffset && tokOffset->str() == "(") {
// unhandled typedef, skip it and continue // unhandled typedef, skip it and continue
if (typeName->str() == "void") { if (typeName->str() == "void") {
unsupportedTypedef(typeDef); unsupportedTypedef(typeDef);
@ -1146,8 +1146,8 @@ void Tokenizer::simplifyTypedef()
// unhandled function pointer, skip it and continue // unhandled function pointer, skip it and continue
// TODO: handle such typedefs. See ticket #3314 // TODO: handle such typedefs. See ticket #3314
else if (Token::Match(tok->tokAt(offset), "( %type% ::") && else if (Token::Match(tokOffset, "( %type% ::") &&
Token::Match(tok->linkAt(offset)->tokAt(-3), ":: * %var% ) (")) { Token::Match(tokOffset->link()->tokAt(-3), ":: * %var% ) (")) {
unsupportedTypedef(typeDef); unsupportedTypedef(typeDef);
tok = deleteInvalidTypedef(typeDef); tok = deleteInvalidTypedef(typeDef);
if (tok == _tokens) if (tok == _tokens)
@ -1157,27 +1157,27 @@ void Tokenizer::simplifyTypedef()
} }
// function pointer // function pointer
else if (Token::Match(tok->tokAt(offset), "( * %var% ) (")) { else if (Token::Match(tokOffset, "( * %var% ) (")) {
// name token wasn't a name, it was part of the type // name token wasn't a name, it was part of the type
typeEnd = typeEnd->next(); typeEnd = typeEnd->next();
functionPtr = true; functionPtr = true;
funcStart = tok->tokAt(offset + 1); funcStart = tokOffset->next();
funcEnd = tok->tokAt(offset + 1); funcEnd = tokOffset->next();
typeName = tok->tokAt(offset + 2); typeName = tokOffset->tokAt(2);
argStart = tok->tokAt(offset + 4); argStart = tokOffset->tokAt(4);
argEnd = tok->linkAt(offset + 4); argEnd = tokOffset->linkAt(4);
tok = argEnd->next(); tok = argEnd->next();
} }
// function // function
else if (Token::Match(tok->linkAt(offset), ") const| ;|,")) { else if (Token::Match(tokOffset->link(), ") const| ;|,")) {
function = true; function = true;
if (tok->linkAt(offset)->next()->str() == "const") { if (tokOffset->link()->next()->str() == "const") {
specStart = tok->linkAt(offset)->next(); specStart = tokOffset->link()->next();
specEnd = specStart; specEnd = specStart;
} }
argStart = tok->tokAt(offset); argStart = tokOffset;
argEnd = tok->linkAt(offset); argEnd = tokOffset->link();
tok = argEnd->next(); tok = argEnd->next();
if (specStart) if (specStart)
tok = tok->next(); tok = tok->next();