Symbol database: faster implementation. Ticket: #4494

This commit is contained in:
Robert Reif 2013-02-20 07:46:06 +01:00 committed by Daniel Marjamäki
parent 71b66209b7
commit 21bf5173e5
1 changed files with 15 additions and 20 deletions

View File

@ -892,28 +892,23 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
}
// fill in missing variables if possible
for (std::size_t i = 1; i <= _tokenizer->varIdCount(); i++) {
// check each missing variable
if (_variableList[i] == 0) {
// find the token with this varid
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
if (tok->varId() == i) {
// check if it is a member variable
const Token *tok1 = tok->tokAt(-2);
if (tok1 && Token::Match(tok1, "%var% .") && tok1->varId()) {
// check if this varid has a variable
const Variable *var = getVariableFromVarId(tok1->varId());
if (var && var->type()) {
// find the member variable of this variable
const Variable *var1 = var->type()->getVariable(tok->str());
if (var1) {
// add this variable to the look up table
_variableList[i] = var1;
}
const std::size_t functions = functionScopes.size();
for (std::size_t i = 0; i < functions; ++i) {
const Scope *func = functionScopes[i];
for (const Token *tok = func->classStart->next(); tok != func->classEnd; tok = tok->next()) {
// check for member variable
if (tok && tok->varId() && tok->next() && tok->next()->str() == ".") {
const Token *tok1 = tok->tokAt(2);
if (tok1 && tok1->varId() && _variableList[tok1->varId()] == 0) {
const Variable *var = _variableList[tok->varId()];
if (var && var->type()) {
// find the member variable of this variable
const Variable *var1 = var->type()->getVariable(tok1->str());
if (var1) {
// add this variable to the look up table
_variableList[tok1->varId()] = var1;
}
}
// found varid so stop searching
break;
}
}
}