SymbolDatabase::createSymbolDatabaseFindAllScopes(): hoist _tokenizer->isC(PP) dereference out of loop.
This commit is contained in:
parent
e187fdb696
commit
558a2f0cc7
|
@ -82,6 +82,9 @@ static const Token* skipScopeIdentifiers(const Token* tok)
|
||||||
|
|
||||||
void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
{
|
{
|
||||||
|
const bool isCPP = _tokenizer->isCPP();
|
||||||
|
const bool isC = _tokenizer->isC();
|
||||||
|
|
||||||
// create global scope
|
// create global scope
|
||||||
scopeList.emplace_back(this, nullptr, nullptr);
|
scopeList.emplace_back(this, nullptr, nullptr);
|
||||||
|
|
||||||
|
@ -99,16 +102,16 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
"SymbolDatabase",
|
"SymbolDatabase",
|
||||||
tok->progressValue());
|
tok->progressValue());
|
||||||
// Locate next class
|
// Locate next class
|
||||||
if ((_tokenizer->isCPP() && ((Token::Match(tok, "class|struct|union|namespace ::| %name% {|:|::|<") &&
|
if ((isCPP && ((Token::Match(tok, "class|struct|union|namespace ::| %name% {|:|::|<") &&
|
||||||
!Token::Match(tok->previous(), "new|friend|const|enum|typedef|mutable|volatile|)|(|<")) ||
|
!Token::Match(tok->previous(), "new|friend|const|enum|typedef|mutable|volatile|)|(|<")) ||
|
||||||
(Token::Match(tok, "enum class| %name% {") ||
|
(Token::Match(tok, "enum class| %name% {") ||
|
||||||
Token::Match(tok, "enum class| %name% : %name% {"))))
|
Token::Match(tok, "enum class| %name% : %name% {"))))
|
||||||
|| (_tokenizer->isC() && Token::Match(tok, "struct|union|enum %name% {"))) {
|
|| (isC && Token::Match(tok, "struct|union|enum %name% {"))) {
|
||||||
const Token *tok2 = tok->tokAt(2);
|
const Token *tok2 = tok->tokAt(2);
|
||||||
|
|
||||||
if (tok->strAt(1) == "::")
|
if (tok->strAt(1) == "::")
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
else if (_tokenizer->isCPP() && tok->strAt(1) == "class")
|
else if (isCPP && tok->strAt(1) == "class")
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
|
||||||
while (Token::Match(tok2, ":: %name%"))
|
while (Token::Match(tok2, ":: %name%"))
|
||||||
|
@ -124,7 +127,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip over final
|
// skip over final
|
||||||
if (_tokenizer->isCPP() && Token::simpleMatch(tok2, "final"))
|
if (isCPP && Token::simpleMatch(tok2, "final"))
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
|
||||||
// make sure we have valid code
|
// make sure we have valid code
|
||||||
|
@ -192,7 +195,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// definition may be different than declaration
|
// definition may be different than declaration
|
||||||
if (_tokenizer->isCPP() && tok->str() == "class") {
|
if (isCPP && tok->str() == "class") {
|
||||||
access[new_scope] = Private;
|
access[new_scope] = Private;
|
||||||
new_scope->type = Scope::eClass;
|
new_scope->type = Scope::eClass;
|
||||||
} else if (tok->str() == "struct") {
|
} else if (tok->str() == "struct") {
|
||||||
|
@ -269,7 +272,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Namespace and unknown macro (#3854)
|
// Namespace and unknown macro (#3854)
|
||||||
else if (_tokenizer->isCPP() &&
|
else if (isCPP &&
|
||||||
Token::Match(tok, "namespace %name% %type% (") &&
|
Token::Match(tok, "namespace %name% %type% (") &&
|
||||||
tok->tokAt(2)->isUpperCaseName() &&
|
tok->tokAt(2)->isUpperCaseName() &&
|
||||||
Token::simpleMatch(tok->linkAt(3), ") {")) {
|
Token::simpleMatch(tok->linkAt(3), ") {")) {
|
||||||
|
@ -309,7 +312,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// using namespace
|
// using namespace
|
||||||
else if (_tokenizer->isCPP() && Token::Match(tok, "using namespace ::| %type% ;|::")) {
|
else if (isCPP && Token::Match(tok, "using namespace ::| %type% ;|::")) {
|
||||||
Scope::UsingInfo using_info;
|
Scope::UsingInfo using_info;
|
||||||
|
|
||||||
using_info.start = tok; // save location
|
using_info.start = tok; // save location
|
||||||
|
@ -329,7 +332,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// using type alias
|
// using type alias
|
||||||
else if (_tokenizer->isCPP() && Token::Match(tok, "using %name% =")) {
|
else if (isCPP && Token::Match(tok, "using %name% =")) {
|
||||||
if (tok->strAt(-1) != ">" && !findType(tok->next(), scope)) {
|
if (tok->strAt(-1) != ">" && !findType(tok->next(), scope)) {
|
||||||
// fill typeList..
|
// fill typeList..
|
||||||
typeList.emplace_back(tok, nullptr, scope);
|
typeList.emplace_back(tok, nullptr, scope);
|
||||||
|
@ -533,7 +536,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// friend class declaration?
|
// friend class declaration?
|
||||||
else if (_tokenizer->isCPP() && Token::Match(tok, "friend class| ::| %any% ;|::")) {
|
else if (isCPP && Token::Match(tok, "friend class| ::| %any% ;|::")) {
|
||||||
Type::FriendInfo friendInfo;
|
Type::FriendInfo friendInfo;
|
||||||
|
|
||||||
// save the name start
|
// save the name start
|
||||||
|
|
Loading…
Reference in New Issue