speed up checks by caching commonly looked up stuff in the symbol database (checkexceptionsafety)
This commit is contained in:
parent
cf7996e299
commit
3064b48156
|
@ -36,12 +36,15 @@ void CheckExceptionSafety::destructors()
|
|||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
// Perform check..
|
||||
for (std::list<Scope>::const_iterator i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i) {
|
||||
for (std::list<Function>::const_iterator j = i->functionList.begin(); j != i->functionList.end(); ++j) {
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
const Function * j = scope->function;
|
||||
if (j) {
|
||||
// only looking for destructors
|
||||
if (j->type == Function::eDestructor && j->functionScope) {
|
||||
if (j->type == Function::eDestructor) {
|
||||
// Inspect this destructor..
|
||||
for (const Token *tok = j->functionScope->classStart->next(); tok != j->functionScope->classEnd; tok = tok->next()) {
|
||||
for (const Token *tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||
// Skip try blocks
|
||||
if (Token::simpleMatch(tok, "try {")) {
|
||||
tok = tok->next()->link();
|
||||
|
@ -70,7 +73,10 @@ void CheckExceptionSafety::deallocThrow()
|
|||
|
||||
// Deallocate a global/member pointer and then throw exception
|
||||
// the pointer will be a dead pointer
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
for (const Token *tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||
// only looking for delete now
|
||||
if (tok->str() != "delete")
|
||||
continue;
|
||||
|
@ -118,6 +124,7 @@ void CheckExceptionSafety::deallocThrow()
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue