Refactoring: Removed redundant checks
This commit is contained in:
parent
4cd3e8fdc0
commit
26e167fd5b
|
@ -450,7 +450,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
|
||||||
{
|
{
|
||||||
// check for an end of definition
|
// check for an end of definition
|
||||||
const Token * tok = *tokPtr;
|
const Token * tok = *tokPtr;
|
||||||
if (tok && tok->next() && Token::Match(tok->next(), ";|,|[|=|)|>|(|{"))
|
if (tok && Token::Match(tok->next(), ";|,|[|=|)|>|(|{"))
|
||||||
{
|
{
|
||||||
const Token * end = tok->next();
|
const Token * end = tok->next();
|
||||||
|
|
||||||
|
@ -761,10 +761,10 @@ void Tokenizer::simplifyTypedef()
|
||||||
bool atEnd = false;
|
bool atEnd = false;
|
||||||
while (!atEnd)
|
while (!atEnd)
|
||||||
{
|
{
|
||||||
if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "::"))
|
if (Token::Match(tok->tokAt(offset), "::"))
|
||||||
typeEnd = tok->tokAt(offset++);
|
typeEnd = tok->tokAt(offset++);
|
||||||
|
|
||||||
if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "%type%") &&
|
if (Token::Match(tok->tokAt(offset), "%type%") &&
|
||||||
tok->tokAt(offset + 1) && !Token::Match(tok->tokAt(offset + 1), "[|;|,|("))
|
tok->tokAt(offset + 1) && !Token::Match(tok->tokAt(offset + 1), "[|;|,|("))
|
||||||
typeEnd = tok->tokAt(offset++);
|
typeEnd = tok->tokAt(offset++);
|
||||||
else if (Token::Match(tok->tokAt(offset), "const ("))
|
else if (Token::Match(tok->tokAt(offset), "const ("))
|
||||||
|
@ -807,7 +807,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
paren--;
|
paren--;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (typeEnd && typeEnd->next() && Token::Match(typeEnd->next(), ":: %type%"))
|
while (typeEnd && Token::Match(typeEnd->next(), ":: %type%"))
|
||||||
typeEnd = typeEnd->tokAt(2);
|
typeEnd = typeEnd->tokAt(2);
|
||||||
|
|
||||||
if (!typeEnd)
|
if (!typeEnd)
|
||||||
|
@ -824,10 +824,10 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for pointers and references
|
// check for pointers and references
|
||||||
while (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "*|&"))
|
while (Token::Match(tok->tokAt(offset), "*|&"))
|
||||||
pointers.push_back(tok->tokAt(offset++)->str());
|
pointers.push_back(tok->tokAt(offset++)->str());
|
||||||
|
|
||||||
if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "%type%"))
|
if (Token::Match(tok->tokAt(offset), "%type%"))
|
||||||
{
|
{
|
||||||
// found the type name
|
// found the type name
|
||||||
typeName = tok->tokAt(offset++);
|
typeName = tok->tokAt(offset++);
|
||||||
|
@ -857,11 +857,11 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for end or another
|
// check for end or another
|
||||||
if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), ";|,"))
|
if (Token::Match(tok->tokAt(offset), ";|,"))
|
||||||
tok = tok->tokAt(offset);
|
tok = tok->tokAt(offset);
|
||||||
|
|
||||||
// or a function typedef
|
// or a function typedef
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "("))
|
else if (Token::Match(tok->tokAt(offset), "("))
|
||||||
{
|
{
|
||||||
function = true;
|
function = true;
|
||||||
if (tok->tokAt(offset)->link()->next())
|
if (tok->tokAt(offset)->link()->next())
|
||||||
|
@ -883,7 +883,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( *|&| const|volatile| const|volatile| %type% ) ("))
|
else if (Token::Match(tok->tokAt(offset), "( *|&| const|volatile| const|volatile| %type% ) ("))
|
||||||
{
|
{
|
||||||
functionPtr = tok->tokAt(offset + 1)->str() == "*";
|
functionPtr = tok->tokAt(offset + 1)->str() == "*";
|
||||||
functionRef = tok->tokAt(offset + 1)->str() == "&";
|
functionRef = tok->tokAt(offset + 1)->str() == "&";
|
||||||
|
@ -927,7 +927,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
tok = specEnd->next();
|
tok = specEnd->next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( ::| %var% :: *|&| const|volatile| const|volatile| %type% ) ("))
|
else if (Token::Match(tok->tokAt(offset), "( ::| %var% :: *|&| const|volatile| const|volatile| %type% ) ("))
|
||||||
{
|
{
|
||||||
namespaceStart = tok->tokAt(offset + 1);
|
namespaceStart = tok->tokAt(offset + 1);
|
||||||
if (tok->tokAt(offset + 1)->str() == "::")
|
if (tok->tokAt(offset + 1)->str() == "::")
|
||||||
|
@ -975,7 +975,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
tok = specEnd->next();
|
tok = specEnd->next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( %type% ("))
|
else if (Token::Match(tok->tokAt(offset), "( %type% ("))
|
||||||
{
|
{
|
||||||
function = true;
|
function = true;
|
||||||
if (tok->tokAt(offset)->link()->next())
|
if (tok->tokAt(offset)->link()->next())
|
||||||
|
@ -993,7 +993,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// pointer to function returning pointer to function
|
// pointer to function returning pointer to function
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( * ( * %type% ) ("))
|
else if (Token::Match(tok->tokAt(offset), "( * ( * %type% ) ("))
|
||||||
{
|
{
|
||||||
functionPtrRetFuncPtr = true;
|
functionPtrRetFuncPtr = true;
|
||||||
|
|
||||||
|
@ -1008,7 +1008,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// function returning pointer to function
|
// function returning pointer to function
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( * %type% (") &&
|
else if (Token::Match(tok->tokAt(offset), "( * %type% (") &&
|
||||||
Token::Match(tok->tokAt(offset + 3)->link(), ") ) ("))
|
Token::Match(tok->tokAt(offset + 3)->link(), ") ) ("))
|
||||||
{
|
{
|
||||||
functionRetFuncPtr = true;
|
functionRetFuncPtr = true;
|
||||||
|
@ -1022,7 +1022,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
|
|
||||||
tok = argFuncRetEnd->next();
|
tok = argFuncRetEnd->next();
|
||||||
}
|
}
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( * ( %type% ) ("))
|
else if (Token::Match(tok->tokAt(offset), "( * ( %type% ) ("))
|
||||||
{
|
{
|
||||||
functionRetFuncPtr = true;
|
functionRetFuncPtr = true;
|
||||||
|
|
||||||
|
@ -1037,7 +1037,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// pointer/reference to array
|
// pointer/reference to array
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( *|& %type% ) ["))
|
else if (Token::Match(tok->tokAt(offset), "( *|& %type% ) ["))
|
||||||
{
|
{
|
||||||
ptrToArray = (tok->tokAt(offset + 1)->str() == "*");
|
ptrToArray = (tok->tokAt(offset + 1)->str() == "*");
|
||||||
refToArray = (tok->tokAt(offset + 1)->str() == "&");
|
refToArray = (tok->tokAt(offset + 1)->str() == "&");
|
||||||
|
@ -1048,7 +1048,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// pointer to class member
|
// pointer to class member
|
||||||
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( %type% :: * %type% ) ;"))
|
else if (Token::Match(tok->tokAt(offset), "( %type% :: * %type% ) ;"))
|
||||||
{
|
{
|
||||||
namespaceStart = tok->tokAt(offset + 1);
|
namespaceStart = tok->tokAt(offset + 1);
|
||||||
namespaceEnd = tok->tokAt(offset + 2);
|
namespaceEnd = tok->tokAt(offset + 2);
|
||||||
|
@ -1513,10 +1513,10 @@ void Tokenizer::simplifyTypedef()
|
||||||
offset = 1;
|
offset = 1;
|
||||||
pointers.clear();
|
pointers.clear();
|
||||||
|
|
||||||
while (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "*|&"))
|
while (Token::Match(tok->tokAt(offset), "*|&"))
|
||||||
pointers.push_back(tok->tokAt(offset++)->str());
|
pointers.push_back(tok->tokAt(offset++)->str());
|
||||||
|
|
||||||
if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "%type%"))
|
if (Token::Match(tok->tokAt(offset), "%type%"))
|
||||||
{
|
{
|
||||||
typeName = tok->tokAt(offset++);
|
typeName = tok->tokAt(offset++);
|
||||||
|
|
||||||
|
@ -1543,7 +1543,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
arrayEnd = tok->tokAt(offset++);
|
arrayEnd = tok->tokAt(offset++);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), ";|,"))
|
if (Token::Match(tok->tokAt(offset), ";|,"))
|
||||||
tok = tok->tokAt(offset);
|
tok = tok->tokAt(offset);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -6177,7 +6177,7 @@ bool Tokenizer::duplicateDefinition(Token ** tokPtr, const Token * name)
|
||||||
{
|
{
|
||||||
// check for an end of definition
|
// check for an end of definition
|
||||||
const Token * tok = *tokPtr;
|
const Token * tok = *tokPtr;
|
||||||
if (tok && tok->next() && Token::Match(tok->next(), ";|,|[|=|)|>"))
|
if (tok && Token::Match(tok->next(), ";|,|[|=|)|>"))
|
||||||
{
|
{
|
||||||
const Token * end = tok->next();
|
const Token * end = tok->next();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue