SymbolDatabase: reintroduce test, move symboldatabase cleanup code to SymbolDatabase destructor

This commit is contained in:
Robert Reif 2014-11-02 10:36:52 +01:00 committed by Daniel Marjamäki
parent 0e4c508d7b
commit df6855c216
4 changed files with 13 additions and 7 deletions

View File

@ -1185,6 +1185,16 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
}
}
SymbolDatabase::~SymbolDatabase()
{
// Clear scope, function, and variable pointers
for (const Token* tok = _tokenizer->list.front(); tok != _tokenizer->list.back(); tok = tok->next()) {
const_cast<Token *>(tok)->scope(0);
const_cast<Token *>(tok)->function(0);
const_cast<Token *>(tok)->variable(0);
}
}
bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const Token **funcStart, const Token **argStart)
{
if (tok->varId())

View File

@ -801,6 +801,7 @@ private:
class CPPCHECKLIB SymbolDatabase {
public:
SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
~SymbolDatabase();
/** @brief Information about all namespaces/classes/structrues */
std::list<Scope> scopeList;

View File

@ -10081,13 +10081,6 @@ void Tokenizer::createSymbolDatabase()
void Tokenizer::deleteSymbolDatabase()
{
// Clear scope, function, and variable pointers
for (Token* tok = list.front(); tok != list.back(); tok = tok->next()) {
tok->scope(0);
tok->function(0);
tok->variable(0);
}
delete _symbolDatabase;
_symbolDatabase = 0;
}

View File

@ -223,6 +223,8 @@ private:
TEST_CASE(isImplicitlyVirtual);
TEST_CASE(isFunction); // UNKNOWN_MACRO(a,b) { .. }
TEST_CASE(findFunction1);
TEST_CASE(findFunction2); // mismatch: parameter passed by address => reference argument
TEST_CASE(findFunction3);