speed up check64bit by caching commonly looked up stuff in the symbol database (#4266)

This commit is contained in:
Robert Reif 2012-10-12 06:12:21 +02:00 committed by Daniel Marjamäki
parent 1e4b080737
commit 0c731cfa9b
1 changed files with 21 additions and 16 deletions

View File

@ -50,8 +50,10 @@ void Check64BitPortability::pointerassignment()
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
// Check return values
for (std::list<Scope>::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
if (scope->type != Scope::eFunction || scope->function == 0 || !scope->function->hasBody) // We only look for functions with a body
const std::size_t functions = symbolDatabase->functionScopes.size();
for (std::size_t i = 0; i < functions; ++i) {
const Scope * scope = symbolDatabase->functionScopes[i];
if (scope->function == 0 || !scope->function->hasBody) // We only look for functions with a body
continue;
bool retPointer = false;
@ -62,7 +64,7 @@ void Check64BitPortability::pointerassignment()
else
continue;
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
if (Token::Match(tok, "return %var% [;+]")) {
const Variable *var = symbolDatabase->getVariableFromVarId(tok->next()->varId());
if (retPointer && isint(var))
@ -74,7 +76,9 @@ void Check64BitPortability::pointerassignment()
}
// Check assignements
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
for (std::size_t i = 0; i < functions; ++i) {
const Scope * scope = symbolDatabase->functionScopes[i];
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
if (Token::Match(tok, "[;{}] %var% = %var% [;+]")) {
const Variable *var1(symbolDatabase->getVariableFromVarId(tok->next()->varId()));
@ -93,6 +97,7 @@ void Check64BitPortability::pointerassignment()
}
}
}
}
}
void Check64BitPortability::assignmentAddressToIntegerError(const Token *tok)