speed up checkmemoryleak by caching commonly looked up stuff in the symbol database (#4266)
This commit is contained in:
parent
9bc2a62c1e
commit
d1fad4b762
|
@ -541,12 +541,10 @@ void CheckMemoryLeakInFunction::parse_noreturn()
|
|||
noreturn.insert("pthread_exit");
|
||||
}
|
||||
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
|
||||
// parse this function to check if it contains an "exit" call..
|
||||
bool isNoreturn = false;
|
||||
|
@ -2125,12 +2123,10 @@ static bool isNoArgument(const SymbolDatabase* symbolDatabase, unsigned int vari
|
|||
|
||||
void CheckMemoryLeakInFunction::checkReallocUsage()
|
||||
{
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
|
||||
// Search for the "var = realloc(var, 100" pattern within this function
|
||||
for (const Token *tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||
|
@ -2200,10 +2196,9 @@ void CheckMemoryLeakInFunction::check()
|
|||
parse_noreturn();
|
||||
|
||||
// Check locking/unlocking of global resources..
|
||||
for (std::list<Scope>::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
|
||||
checkScope(scope->classStart->next(), "", 0, scope->functionOf != NULL, 1);
|
||||
}
|
||||
|
@ -2270,11 +2265,10 @@ void CheckMemoryLeakInClass::check()
|
|||
{
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||
// only check classes and structures
|
||||
if (scope->isClassOrStruct()) {
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
for (std::size_t i = 0; i < classes; ++i) {
|
||||
const Scope * scope = symbolDatabase->classAndStructScopes[i];
|
||||
std::list<Variable>::const_iterator var;
|
||||
for (var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
||||
if (!var->isStatic() && var->isPointer()) {
|
||||
|
@ -2302,7 +2296,6 @@ void CheckMemoryLeakInClass::check()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2687,12 +2680,10 @@ void CheckMemoryLeakNoVar::check()
|
|||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
|
||||
// goto the "}" that ends the executable scope..
|
||||
const Token *tok = scope->classEnd;
|
||||
|
|
Loading…
Reference in New Issue