Refactorization: Simplifications in symboldatabase

This commit is contained in:
PKEuS 2014-04-01 10:13:00 +02:00
parent 830249d72e
commit 5953f02654
1 changed files with 15 additions and 14 deletions

View File

@ -960,14 +960,13 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
{
// function returning function pointer? '... ( ... %var% ( ... ))( ... ) {'
if (tok->str() == "(" &&
tok->link()->previous()->str() == ")" &&
tok->link()->next() &&
tok->link()->next()->str() == "(" &&
tok->link()->next()->link()->next() &&
Token::Match(tok->link()->next()->link()->next(), "{|;|const|=")) {
*funcStart = tok->link()->previous()->link()->previous();
*argStart = tok->link()->previous()->link();
return true;
tok->link()->previous()->str() == ")") {
const Token* tok2 = tok->link()->next();
if (tok2 && tok2->str() == "(" && Token::Match(tok2->link()->next(), "{|;|const|=")) {
*funcStart = tok->link()->previous()->link()->previous();
*argStart = tok->link()->previous()->link();
return true;
}
}
// regular function?
@ -988,12 +987,14 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
}
// template constructor?
else if (Token::Match(tok, "%var% <") && Token::simpleMatch(tok->next()->link(), "> (") &&
(Token::Match(tok->next()->link()->next()->link(), ") const| ;|{|=") ||
Token::Match(tok->next()->link()->next()->link(), ") : ::| %var% (|::|<|{"))) {
*funcStart = tok;
*argStart = tok->next()->link()->next();
return true;
else if (Token::Match(tok, "%var% <") && Token::simpleMatch(tok->next()->link(), "> (")) {
const Token* tok2 = tok->next()->link()->next()->link();
if (Token::Match(tok2, ") const| ;|{|=") ||
Token::Match(tok2, ") : ::| %var% (|::|<|{")) {
*funcStart = tok;
*argStart = tok2->link();
return true;
}
}
return false;