SymbolDatabase: reintroduce test, move symboldatabase cleanup code to SymbolDatabase destructor
This commit is contained in:
parent
0e4c508d7b
commit
df6855c216
|
@ -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)
|
bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const Token **funcStart, const Token **argStart)
|
||||||
{
|
{
|
||||||
if (tok->varId())
|
if (tok->varId())
|
||||||
|
|
|
@ -801,6 +801,7 @@ private:
|
||||||
class CPPCHECKLIB SymbolDatabase {
|
class CPPCHECKLIB SymbolDatabase {
|
||||||
public:
|
public:
|
||||||
SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
|
SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
|
||||||
|
~SymbolDatabase();
|
||||||
|
|
||||||
/** @brief Information about all namespaces/classes/structrues */
|
/** @brief Information about all namespaces/classes/structrues */
|
||||||
std::list<Scope> scopeList;
|
std::list<Scope> scopeList;
|
||||||
|
|
|
@ -10081,13 +10081,6 @@ void Tokenizer::createSymbolDatabase()
|
||||||
|
|
||||||
void Tokenizer::deleteSymbolDatabase()
|
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;
|
delete _symbolDatabase;
|
||||||
_symbolDatabase = 0;
|
_symbolDatabase = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,6 +223,8 @@ private:
|
||||||
TEST_CASE(isImplicitlyVirtual);
|
TEST_CASE(isImplicitlyVirtual);
|
||||||
|
|
||||||
TEST_CASE(isFunction); // UNKNOWN_MACRO(a,b) { .. }
|
TEST_CASE(isFunction); // UNKNOWN_MACRO(a,b) { .. }
|
||||||
|
|
||||||
|
TEST_CASE(findFunction1);
|
||||||
TEST_CASE(findFunction2); // mismatch: parameter passed by address => reference argument
|
TEST_CASE(findFunction2); // mismatch: parameter passed by address => reference argument
|
||||||
TEST_CASE(findFunction3);
|
TEST_CASE(findFunction3);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue