Symbol database: pulled out classes into global scope. ticket: #2468

This commit is contained in:
Robert Reif 2011-01-17 07:21:59 +01:00 committed by Daniel Marjamäki
parent 481907ef14
commit bf9528558e
9 changed files with 289 additions and 288 deletions

View File

@ -68,11 +68,11 @@ void CheckClass::constructors()
createSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check classes and structures
if (!info->isClassOrStruct())
@ -82,10 +82,10 @@ void CheckClass::constructors()
if (info->numConstructors == 0)
{
// If there is a private variable, there should be a constructor..
std::list<SymbolDatabase::Var>::const_iterator var;
std::list<Var>::const_iterator var;
for (var = info->varlist.begin(); var != info->varlist.end(); ++var)
{
if (var->access == SymbolDatabase::Private && !var->isClass && !var->isStatic)
if (var->access == Private && !var->isClass && !var->isStatic)
{
noConstructorError(info->classDef, info->className, info->classDef->str() == "struct");
break;
@ -93,14 +93,14 @@ void CheckClass::constructors()
}
}
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
std::vector<Usage> usage(info->varlist.size());
for (func = info->functionList.begin(); func != info->functionList.end(); ++func)
{
if (!func->hasBody || !(func->type == SymbolDatabase::Func::Constructor ||
func->type == SymbolDatabase::Func::CopyConstructor ||
func->type == SymbolDatabase::Func::OperatorEqual))
if (!func->hasBody || !(func->type == Func::Constructor ||
func->type == Func::CopyConstructor ||
func->type == Func::OperatorEqual))
continue;
// Mark all variables not used
@ -110,7 +110,7 @@ void CheckClass::constructors()
initializeVarList(*func, callstack, info, usage);
// Check if any variables are uninitialized
std::list<SymbolDatabase::Var>::const_iterator var;
std::list<Var>::const_iterator var;
unsigned int count = 0;
for (var = info->varlist.begin(); var != info->varlist.end(); ++var, ++count)
{
@ -121,7 +121,7 @@ void CheckClass::constructors()
continue;
// Check if this is a class constructor
if (var->isClass && func->type == SymbolDatabase::Func::Constructor)
if (var->isClass && func->type == Func::Constructor)
{
// Unknown type so assume it is initialized
if (!var->type)
@ -129,12 +129,12 @@ void CheckClass::constructors()
// Known type that doesn't need initialization or
// known type that has member variables of an unknown type
else if (var->type->needInitialization != SymbolDatabase::SpaceInfo::True)
else if (var->type->needInitialization != SpaceInfo::True)
continue;
}
// It's non-static and it's not initialized => error
if (func->type == SymbolDatabase::Func::OperatorEqual)
if (func->type == Func::OperatorEqual)
{
const Token *operStart = 0;
if (func->token->str() == "=")
@ -155,16 +155,16 @@ void CheckClass::constructors()
if (classNameUsed)
operatorEqVarError(func->token, info->className, var->token->str());
}
else if (func->access != SymbolDatabase::Private)
else if (func->access != Private)
uninitVarError(func->token, info->className, var->token->str());
}
}
}
}
void CheckClass::assignVar(const std::string &varname, const SymbolDatabase::SpaceInfo *info, std::vector<Usage> &usage)
void CheckClass::assignVar(const std::string &varname, const SpaceInfo *info, std::vector<Usage> &usage)
{
std::list<SymbolDatabase::Var>::const_iterator var;
std::list<Var>::const_iterator var;
unsigned int count = 0;
for (var = info->varlist.begin(); var != info->varlist.end(); ++var, ++count)
@ -177,9 +177,9 @@ void CheckClass::assignVar(const std::string &varname, const SymbolDatabase::Spa
}
}
void CheckClass::initVar(const std::string &varname, const SymbolDatabase::SpaceInfo *info, std::vector<Usage> &usage)
void CheckClass::initVar(const std::string &varname, const SpaceInfo *info, std::vector<Usage> &usage)
{
std::list<SymbolDatabase::Var>::const_iterator var;
std::list<Var>::const_iterator var;
unsigned int count = 0;
for (var = info->varlist.begin(); var != info->varlist.end(); ++var, ++count)
@ -207,17 +207,17 @@ void CheckClass::clearAllVar(std::vector<Usage> &usage)
}
}
bool CheckClass::isBaseClassFunc(const Token *tok, const SymbolDatabase::SpaceInfo *info)
bool CheckClass::isBaseClassFunc(const Token *tok, const SpaceInfo *info)
{
// Iterate through each base class...
for (size_t i = 0; i < info->derivedFrom.size(); ++i)
{
const SymbolDatabase::SpaceInfo *derivedFrom = info->derivedFrom[i].spaceInfo;
const SpaceInfo *derivedFrom = info->derivedFrom[i].spaceInfo;
// Check if base class exists in database
if (derivedFrom)
{
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
for (func = derivedFrom->functionList.begin(); func != derivedFrom->functionList.end(); ++func)
{
@ -234,7 +234,7 @@ bool CheckClass::isBaseClassFunc(const Token *tok, const SymbolDatabase::SpaceIn
return false;
}
void CheckClass::initializeVarList(const SymbolDatabase::Func &func, std::list<std::string> &callstack, const SymbolDatabase::SpaceInfo *info, std::vector<Usage> &usage)
void CheckClass::initializeVarList(const Func &func, std::list<std::string> &callstack, const SpaceInfo *info, std::vector<Usage> &usage)
{
bool Assign = false;
unsigned int indentlevel = 0;
@ -302,7 +302,7 @@ void CheckClass::initializeVarList(const SymbolDatabase::Func &func, std::list<s
// Calling member variable function?
if (Token::Match(ftok->next(), "%var% . %var% ("))
{
std::list<SymbolDatabase::Var>::const_iterator var;
std::list<Var>::const_iterator var;
for (var = info->varlist.begin(); var != info->varlist.end(); ++var)
{
if (var->token->varId() == ftok->next()->varId())
@ -359,10 +359,10 @@ void CheckClass::initializeVarList(const SymbolDatabase::Func &func, std::list<s
ftok->previous()->str() != "::")
{
// check if member function exists
std::list<SymbolDatabase::Func>::const_iterator it;
std::list<Func>::const_iterator it;
for (it = info->functionList.begin(); it != info->functionList.end(); ++it)
{
if (ftok->next()->str() == it->tokenDef->str() && it->type != SymbolDatabase::Func::Constructor)
if (ftok->next()->str() == it->tokenDef->str() && it->type != Func::Constructor)
break;
}
@ -412,10 +412,10 @@ void CheckClass::initializeVarList(const SymbolDatabase::Func &func, std::list<s
}
// check if member function
std::list<SymbolDatabase::Func>::const_iterator it;
std::list<Func>::const_iterator it;
for (it = info->functionList.begin(); it != info->functionList.end(); ++it)
{
if (ftok->str() == it->tokenDef->str() && it->type != SymbolDatabase::Func::Constructor)
if (ftok->str() == it->tokenDef->str() && it->type != Func::Constructor)
break;
}
@ -442,7 +442,7 @@ void CheckClass::initializeVarList(const SymbolDatabase::Func &func, std::list<s
else
{
// could be a base class virtual function, so we assume it initializes everything
if (func.type != SymbolDatabase::Func::Constructor && isBaseClassFunc(ftok, info))
if (func.type != Func::Constructor && isBaseClassFunc(ftok, info))
{
/** @todo False Negative: we should look at the base class functions to see if they
* call any derived class virtual functions that change the derived class state
@ -569,11 +569,11 @@ void CheckClass::privateFunctions()
createSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check classes and structures
if (!info->isClassOrStruct())
@ -588,13 +588,13 @@ void CheckClass::privateFunctions()
// check that the whole class implementation is seen
bool whole = true;
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
for (func = info->functionList.begin(); func != info->functionList.end(); ++func)
{
if (!func->hasBody)
{
// empty private copy constructors and assignment operators are OK
if ((func->type == SymbolDatabase::Func::CopyConstructor || func->type == SymbolDatabase::Func::OperatorEqual) && func->access == SymbolDatabase::Private)
if ((func->type == Func::CopyConstructor || func->type == Func::OperatorEqual) && func->access == Private)
continue;
whole = false;
@ -614,8 +614,8 @@ void CheckClass::privateFunctions()
for (func = info->functionList.begin(); func != info->functionList.end(); ++func)
{
// Get private functions..
if (func->type == SymbolDatabase::Func::Function &&
func->access == SymbolDatabase::Private && func->hasBody)
if (func->type == Func::Function &&
func->access == Private && func->hasBody)
FuncList.push_back(func->tokenDef);
}
}
@ -834,15 +834,15 @@ void CheckClass::operatorEq()
createSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
std::list<SymbolDatabase::Func>::const_iterator it;
std::list<Func>::const_iterator it;
for (it = (*i)->functionList.begin(); it != (*i)->functionList.end(); ++it)
{
if (it->type == SymbolDatabase::Func::OperatorEqual && it->access != SymbolDatabase::Private)
if (it->type == Func::OperatorEqual && it->access != Private)
{
if (it->token->strAt(-2) == "void")
operatorEqReturnError(it->token->tokAt(-2));
@ -861,7 +861,7 @@ void CheckClass::operatorEqReturnError(const Token *tok)
// operator= should return a reference to *this
//---------------------------------------------------------------------------
void CheckClass::checkReturnPtrThis(const SymbolDatabase::SpaceInfo *info, const SymbolDatabase::Func *func, const Token *tok, const Token *last)
void CheckClass::checkReturnPtrThis(const SpaceInfo *info, const Func *func, const Token *tok, const Token *last)
{
bool foundReturn = false;
@ -879,13 +879,13 @@ void CheckClass::checkReturnPtrThis(const SymbolDatabase::SpaceInfo *info, const
if (Token::Match(tok->tokAt(1), "%any% (") &&
tok->tokAt(2)->link()->next()->str() == ";")
{
std::list<SymbolDatabase::Func>::const_iterator it;
std::list<Func>::const_iterator it;
// check if it is a member function
for (it = info->functionList.begin(); it != info->functionList.end(); ++it)
{
// check for a regular function with the same name and a bofy
if (it->type == SymbolDatabase::Func::Function && it->hasBody &&
if (it->type == Func::Function && it->hasBody &&
it->token->str() == tok->next()->str())
{
// check for the proper return type
@ -918,20 +918,20 @@ void CheckClass::operatorEqRetRefThis()
createSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check classes and structures
if (info->isClassOrStruct())
{
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
for (func = info->functionList.begin(); func != info->functionList.end(); ++func)
{
if (func->type == SymbolDatabase::Func::OperatorEqual && func->hasBody)
if (func->type == Func::OperatorEqual && func->hasBody)
{
// make sure return signature is correct
if (Token::Match(func->tokenDef->tokAt(-4), ";|}|{|public:|protected:|private: %type% &") &&
@ -974,12 +974,12 @@ void CheckClass::operatorEqToSelf()
createSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
std::list<SymbolDatabase::Func>::const_iterator it;
const SpaceInfo *info = *i;
std::list<Func>::const_iterator it;
// skip classes with multiple inheritance
if (info->derivedFrom.size() > 1)
@ -987,7 +987,7 @@ void CheckClass::operatorEqToSelf()
for (it = info->functionList.begin(); it != info->functionList.end(); ++it)
{
if (it->type == SymbolDatabase::Func::OperatorEqual && it->hasBody)
if (it->type == Func::OperatorEqual && it->hasBody)
{
// make sure return signature is correct
if (Token::Match(it->tokenDef->tokAt(-4), ";|}|{|public:|protected:|private: %type% &") &&
@ -1151,18 +1151,18 @@ void CheckClass::virtualDestructor()
createSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// Skip base classes and namespaces
if (info->derivedFrom.empty())
continue;
// Find the destructor
const SymbolDatabase::Func *destructor = info->getDestructor();
const Func *destructor = info->getDestructor();
// Check for destructor with implementation
if (!destructor || !destructor->hasBody)
@ -1179,15 +1179,15 @@ void CheckClass::virtualDestructor()
for (unsigned int j = 0; j < info->derivedFrom.size(); ++j)
{
// Check if base class is public and exists in database
if (info->derivedFrom[j].access != SymbolDatabase::Private && info->derivedFrom[j].spaceInfo)
if (info->derivedFrom[j].access != Private && info->derivedFrom[j].spaceInfo)
{
const SymbolDatabase::SpaceInfo *spaceInfo = info->derivedFrom[j].spaceInfo;
const SpaceInfo *spaceInfo = info->derivedFrom[j].spaceInfo;
// Name of base class..
const std::string baseName = spaceInfo->className;
// Find the destructor declaration for the base class.
const SymbolDatabase::Func *base_destructor = spaceInfo->getDestructor();
const Func *base_destructor = spaceInfo->getDestructor();
const Token *base = 0;
if (base_destructor)
base = base_destructor->token;
@ -1211,7 +1211,7 @@ void CheckClass::virtualDestructor()
// Make sure that the destructor is public (protected or private
// would not compile if inheritance is used in a way that would
// cause the bug we are trying to find here.)
if (base_destructor->access == SymbolDatabase::Public)
if (base_destructor->access == Public)
virtualDestructorError(base, baseName, derivedClass->str());
}
}
@ -1270,22 +1270,22 @@ void CheckClass::checkConst()
createSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator it;
std::list<SpaceInfo *>::const_iterator it;
for (it = symbolDatabase->spaceInfoList.begin(); it != symbolDatabase->spaceInfoList.end(); ++it)
{
const SymbolDatabase::SpaceInfo *info = *it;
const SpaceInfo *info = *it;
// only check classes and structures
if (!info->isClassOrStruct())
continue;
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
for (func = info->functionList.begin(); func != info->functionList.end(); ++func)
{
// does the function have a body?
if (func->type == SymbolDatabase::Func::Function && func->hasBody && !func->isFriend && !func->isStatic && !func->isConst && !func->isVirtual)
if (func->type == Func::Function && func->hasBody && !func->isFriend && !func->isStatic && !func->isConst && !func->isVirtual)
{
// get last token of return type
const Token *previous = func->tokenDef->isName() ? func->token->previous() : func->token->tokAt(-2);
@ -1353,8 +1353,8 @@ void CheckClass::checkConst()
if (checkConstFunc(info, paramEnd))
{
std::string classname = info->className;
const SymbolDatabase::SpaceInfo *nest = info->nestedIn;
while (nest && nest->type != SymbolDatabase::SpaceInfo::Global)
const SpaceInfo *nest = info->nestedIn;
while (nest && nest->type != SpaceInfo::Global)
{
classname = std::string(nest->className + "::" + classname);
nest = nest->nestedIn;
@ -1378,7 +1378,7 @@ void CheckClass::checkConst()
}
}
bool CheckClass::isMemberVar(const SymbolDatabase::SpaceInfo *info, const Token *tok)
bool CheckClass::isMemberVar(const SpaceInfo *info, const Token *tok)
{
const Token *tok1 = tok;
@ -1400,7 +1400,7 @@ bool CheckClass::isMemberVar(const SymbolDatabase::SpaceInfo *info, const Token
if (tok->str() == info->className && tok->next()->str() == "::")
tok = tok->tokAt(2);
std::list<SymbolDatabase::Var>::const_iterator var;
std::list<Var>::const_iterator var;
for (var = info->varlist.begin(); var != info->varlist.end(); ++var)
{
if (var->token->str() == tok->str())
@ -1416,7 +1416,7 @@ bool CheckClass::isMemberVar(const SymbolDatabase::SpaceInfo *info, const Token
for (unsigned int i = 0; i < info->derivedFrom.size(); ++i)
{
// find the base class
const SymbolDatabase::SpaceInfo *spaceInfo = info->derivedFrom[i].spaceInfo;
const SpaceInfo *spaceInfo = info->derivedFrom[i].spaceInfo;
// find the function in the base class
if (spaceInfo)
@ -1430,9 +1430,9 @@ bool CheckClass::isMemberVar(const SymbolDatabase::SpaceInfo *info, const Token
return false;
}
bool CheckClass::isConstMemberFunc(const SymbolDatabase::SpaceInfo *info, const Token *tok)
bool CheckClass::isConstMemberFunc(const SpaceInfo *info, const Token *tok)
{
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
for (func = info->functionList.begin(); func != info->functionList.end(); ++func)
{
@ -1447,7 +1447,7 @@ bool CheckClass::isConstMemberFunc(const SymbolDatabase::SpaceInfo *info, const
for (unsigned int i = 0; i < info->derivedFrom.size(); ++i)
{
// find the base class
const SymbolDatabase::SpaceInfo *spaceInfo = info->derivedFrom[i].spaceInfo;
const SpaceInfo *spaceInfo = info->derivedFrom[i].spaceInfo;
// find the function in the base class
if (spaceInfo)
@ -1461,7 +1461,7 @@ bool CheckClass::isConstMemberFunc(const SymbolDatabase::SpaceInfo *info, const
return false;
}
bool CheckClass::checkConstFunc(const SymbolDatabase::SpaceInfo *info, const Token *tok)
bool CheckClass::checkConstFunc(const SpaceInfo *info, const Token *tok)
{
// if the function doesn't have any assignment nor function call,
// it can be a const function..
@ -1558,7 +1558,7 @@ bool CheckClass::checkConstFunc(const SymbolDatabase::SpaceInfo *info, const Tok
//---------------------------------------------------------------------------
// check if this function is defined virtual in the base classes
bool CheckClass::isVirtualFunc(const SymbolDatabase::SpaceInfo *info, const Token *functionToken) const
bool CheckClass::isVirtualFunc(const SpaceInfo *info, const Token *functionToken) const
{
// check each base class
for (unsigned int i = 0; i < info->derivedFrom.size(); ++i)
@ -1566,9 +1566,9 @@ bool CheckClass::isVirtualFunc(const SymbolDatabase::SpaceInfo *info, const Toke
// check if base class exists in database
if (info->derivedFrom[i].spaceInfo)
{
const SymbolDatabase::SpaceInfo *derivedFrom = info->derivedFrom[i].spaceInfo;
const SpaceInfo *derivedFrom = info->derivedFrom[i].spaceInfo;
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
// check if function defined in base class
for (func = derivedFrom->functionList.begin(); func != derivedFrom->functionList.end(); ++func)

View File

@ -163,18 +163,18 @@ private:
}
// operatorEqRetRefThis helper function
void checkReturnPtrThis(const SymbolDatabase::SpaceInfo *info, const SymbolDatabase::Func *func, const Token *tok, const Token *last);
void checkReturnPtrThis(const SpaceInfo *info, const Func *func, const Token *tok, const Token *last);
// operatorEqToSelf helper functions
bool hasDeallocation(const Token *first, const Token *last);
bool hasAssignSelf(const Token *first, const Token *last, const Token *rhs);
// checkConst helper functions
bool isMemberVar(const SymbolDatabase::SpaceInfo *info, const Token *tok);
bool isConstMemberFunc(const SymbolDatabase::SpaceInfo *info, const Token *tok);
bool checkConstFunc(const SymbolDatabase::SpaceInfo *info, const Token *tok);
bool isMemberVar(const SpaceInfo *info, const Token *tok);
bool isConstMemberFunc(const SpaceInfo *info, const Token *tok);
bool checkConstFunc(const SpaceInfo *info, const Token *tok);
/** @brief check if this function is virtual in the base classes */
bool isVirtualFunc(const SymbolDatabase::SpaceInfo *info, const Token *functionToken) const;
bool isVirtualFunc(const SpaceInfo *info, const Token *functionToken) const;
// constructors helper function
/** @brief Information about a member variable. Used when checking for uninitialized variables */
@ -189,7 +189,7 @@ private:
bool init;
};
bool isBaseClassFunc(const Token *tok, const SymbolDatabase::SpaceInfo *info);
bool isBaseClassFunc(const Token *tok, const SpaceInfo *info);
/**
* @brief assign a variable in the varlist
@ -197,7 +197,7 @@ private:
* @param info pointer to variable SpaceInfo
* @param usage reference to usage vector
*/
void assignVar(const std::string &varname, const SymbolDatabase::SpaceInfo *info, std::vector<Usage> &usage);
void assignVar(const std::string &varname, const SpaceInfo *info, std::vector<Usage> &usage);
/**
* @brief initialize a variable in the varlist
@ -205,7 +205,7 @@ private:
* @param info pointer to variable SpaceInfo
* @param usage reference to usage vector
*/
void initVar(const std::string &varname, const SymbolDatabase::SpaceInfo *info, std::vector<Usage> &usage);
void initVar(const std::string &varname, const SpaceInfo *info, std::vector<Usage> &usage);
/**
* @brief set all variables in list assigned
@ -226,7 +226,7 @@ private:
* @param info pointer to variable SpaceInfo
* @param usage reference to usage vector
*/
void initializeVarList(const SymbolDatabase::Func &func, std::list<std::string> &callstack, const SymbolDatabase::SpaceInfo *info, std::vector<Usage> &usage);
void initializeVarList(const Func &func, std::list<std::string> &callstack, const SpaceInfo *info, std::vector<Usage> &usage);
};
/// @}
//---------------------------------------------------------------------------

View File

@ -565,14 +565,14 @@ void CheckMemoryLeakInFunction::parse_noreturn()
noreturn.insert("errx");
noreturn.insert("verrx");
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check functions
if (info->type != SymbolDatabase::SpaceInfo::Function)
if (info->type != SpaceInfo::Function)
continue;
// parse this function to check if it contains an "exit" call..
@ -2491,14 +2491,14 @@ void CheckMemoryLeakInFunction::checkScope(const Token *Tok1, const std::string
//---------------------------------------------------------------------------
void CheckMemoryLeakInFunction::checkReallocUsage()
{
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check functions
if (info->type != SymbolDatabase::SpaceInfo::Function)
if (info->type != SpaceInfo::Function)
continue;
// Record the varid's of the function parameters
@ -2644,14 +2644,14 @@ void CheckMemoryLeakInFunction::check()
// fill the "noreturn"
parse_noreturn();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check functions
if (info->type != SymbolDatabase::SpaceInfo::Function)
if (info->type != SpaceInfo::Function)
continue;
const Token *tok = info->classStart;
@ -2701,16 +2701,16 @@ void CheckMemoryLeakInClass::check()
{
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check classes and structures
if (info->type == SymbolDatabase::SpaceInfo::Class)
if (info->type == SpaceInfo::Class)
{
std::list<SymbolDatabase::Var>::const_iterator var;
std::list<Var>::const_iterator var;
for (var = info->varlist.begin(); var != info->varlist.end(); ++var)
{
if (!var->isStatic && var->token->previous()->str() == "*")
@ -2718,7 +2718,7 @@ void CheckMemoryLeakInClass::check()
// allocation but no deallocation of private variables in public function..
if (var->token->tokAt(-2)->isStandardType())
{
if (var->access == SymbolDatabase::Private)
if (var->access == Private)
checkPublicFunctions(info, var->token);
variable(info, var->token);
@ -2730,7 +2730,7 @@ void CheckMemoryLeakInClass::check()
// not derived and no constructor?
if (var->type->derivedFrom.empty() && var->type->numConstructors == 0)
{
if (var->access == SymbolDatabase::Private)
if (var->access == Private)
checkPublicFunctions(info, var->token);
variable(info, var->token);
@ -2743,7 +2743,7 @@ void CheckMemoryLeakInClass::check()
}
void CheckMemoryLeakInClass::variable(const SymbolDatabase::SpaceInfo *classinfo, const Token *tokVarname)
void CheckMemoryLeakInClass::variable(const SpaceInfo *classinfo, const Token *tokVarname)
{
const std::string varname = tokVarname->strAt(0);
const std::string classname = classinfo->className;
@ -2756,12 +2756,12 @@ void CheckMemoryLeakInClass::variable(const SymbolDatabase::SpaceInfo *classinfo
bool deallocInDestructor = false;
// Inspect member functions
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
for (func = classinfo->functionList.begin(); func != classinfo->functionList.end(); ++func)
{
const Token *functionToken = func->token;
const bool constructor = func->type == SymbolDatabase::Func::Constructor;
const bool destructor = func->type == SymbolDatabase::Func::Destructor;
const bool constructor = func->type == Func::Constructor;
const bool destructor = func->type == Func::Destructor;
unsigned int indent = 0;
bool initlist = false;
for (const Token *tok = functionToken; tok; tok = tok->next())
@ -2879,7 +2879,7 @@ void CheckMemoryLeakInClass::variable(const SymbolDatabase::SpaceInfo *classinfo
}
void CheckMemoryLeakInClass::checkPublicFunctions(const SymbolDatabase::SpaceInfo *spaceinfo, const Token *classtok)
void CheckMemoryLeakInClass::checkPublicFunctions(const SpaceInfo *spaceinfo, const Token *classtok)
{
// Check that public functions deallocate the pointers that they allocate.
// There is no checking how these functions are used and therefore it
@ -2891,12 +2891,12 @@ void CheckMemoryLeakInClass::checkPublicFunctions(const SymbolDatabase::SpaceInf
// Parse public functions..
// If they allocate member variables, they should also deallocate
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
for (func = spaceinfo->functionList.begin(); func != spaceinfo->functionList.end(); ++func)
{
if (func->type != SymbolDatabase::Func::Constructor &&
func->access == SymbolDatabase::Public && func->hasBody)
if (func->type != Func::Constructor &&
func->access == Public && func->hasBody)
{
const Token *tok2 = func->token;
while (tok2->str() != "{")
@ -3166,14 +3166,14 @@ void CheckMemoryLeakNoVar::check()
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
SymbolDatabase::SpaceInfo *info = *i;
SpaceInfo *info = *i;
// only check functions
if (info->type != SymbolDatabase::SpaceInfo::Function)
if (info->type != SpaceInfo::Function)
continue;
// goto the "}" that ends the executable scope..

View File

@ -387,10 +387,10 @@ public:
void check();
private:
void variable(const SymbolDatabase::SpaceInfo *spaceinfo, const Token *tokVarname);
void variable(const SpaceInfo *spaceinfo, const Token *tokVarname);
/** Public functions: possible double-allocation */
void checkPublicFunctions(const SymbolDatabase::SpaceInfo *spaceinfo, const Token *classtok);
void checkPublicFunctions(const SpaceInfo *spaceinfo, const Token *classtok);
void publicAllocationError(const Token *tok, const std::string &varname);
void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/)

View File

@ -1240,14 +1240,14 @@ void CheckOther::functionVariableUsage()
// Parse all executing scopes..
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check functions
if (info->type != SymbolDatabase::SpaceInfo::Function)
if (info->type != SpaceInfo::Function)
continue;
// First token for the current scope..
@ -1694,7 +1694,7 @@ void CheckOther::functionVariableUsage()
if (!start->tokAt(3)->isStandardType())
{
// lookup the type
const SymbolDatabase::SpaceInfo *type = symbolDatabase->findVarType(info, start->tokAt(3));
const SpaceInfo *type = symbolDatabase->findVarType(info, start->tokAt(3));
// unknown type?
if (!type)
@ -1702,7 +1702,7 @@ void CheckOther::functionVariableUsage()
// has default constructor or
// has members with unknown type or default constructor
else if (type->needInitialization == SymbolDatabase::SpaceInfo::False)
else if (type->needInitialization == SpaceInfo::False)
allocate = false;
}
}
@ -1908,14 +1908,14 @@ void CheckOther::checkVariableScope()
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check functions
if (info->type != SymbolDatabase::SpaceInfo::Function)
if (info->type != SpaceInfo::Function)
continue;
// Walk through all tokens..
@ -2536,14 +2536,14 @@ void CheckOther::checkMisusedScopedObject()
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
// only check functions
if (info->type != SymbolDatabase::SpaceInfo::Function)
if (info->type != SpaceInfo::Function)
continue;
unsigned int depth = 0;

View File

@ -249,7 +249,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
// friend class declaration?
else if (Token::Match(tok, "friend class| %any% ;"))
{
FriendInfo friendInfo;
SpaceInfo::FriendInfo friendInfo;
friendInfo.name = tok->strAt(1) == "class" ? tok->strAt(2) : tok->strAt(1);
/** @todo fill this in later after parsing is complete */
@ -411,11 +411,11 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
// check for default constructor
bool hasDefaultConstructor = false;
std::list<SymbolDatabase::Func>::const_iterator func;
std::list<Func>::const_iterator func;
for (func = info->functionList.begin(); func != info->functionList.end(); ++func)
{
if (func->type == SymbolDatabase::Func::Constructor)
if (func->type == Func::Constructor)
{
// check for no arguments: func ( )
if (func->argDef->next() == func->argDef->link())
@ -745,7 +745,7 @@ void SymbolDatabase::addFunction(SpaceInfo **info, const Token **tok, const Toke
func->arg = argStart;
}
}
else if (func->type == SymbolDatabase::Func::Destructor &&
else if (func->type == Func::Destructor &&
(*tok)->previous()->str() == "~" &&
func->tokenDef->str() == (*tok)->str())
{
@ -803,7 +803,7 @@ void SymbolDatabase::addFunction(SpaceInfo **info, const Token **tok, const Toke
addNewFunction(info, tok);
}
void SymbolDatabase::addNewFunction(SymbolDatabase::SpaceInfo **info, const Token **tok)
void SymbolDatabase::addNewFunction(SpaceInfo **info, const Token **tok)
{
const Token *tok1 = *tok;
SpaceInfo *new_info = new SpaceInfo(this, tok1, *info);
@ -853,7 +853,7 @@ const Token *SymbolDatabase::initBaseInfo(SpaceInfo *info, const Token *tok)
// check for base classes
else if (level == 0 && Token::Match(tok2, ":|,"))
{
BaseInfo base;
SpaceInfo::BaseInfo base;
tok2 = tok2->next();
@ -924,7 +924,7 @@ const Token *SymbolDatabase::initBaseInfo(SpaceInfo *info, const Token *tok)
//---------------------------------------------------------------------------
unsigned int SymbolDatabase::Func::argCount() const
unsigned int Func::argCount() const
{
unsigned int count = 0;
@ -942,7 +942,7 @@ unsigned int SymbolDatabase::Func::argCount() const
return count;
}
unsigned int SymbolDatabase::Func::initializedArgCount() const
unsigned int Func::initializedArgCount() const
{
unsigned int count = 0;
@ -960,7 +960,7 @@ unsigned int SymbolDatabase::Func::initializedArgCount() const
//---------------------------------------------------------------------------
SymbolDatabase::SpaceInfo::SpaceInfo(SymbolDatabase *check_, const Token *classDef_, SymbolDatabase::SpaceInfo *nestedIn_) :
SpaceInfo::SpaceInfo(SymbolDatabase *check_, const Token *classDef_, SpaceInfo *nestedIn_) :
check(check_),
classDef(classDef_),
classStart(NULL),
@ -1011,7 +1011,7 @@ SymbolDatabase::SpaceInfo::SpaceInfo(SymbolDatabase *check_, const Token *classD
}
bool
SymbolDatabase::SpaceInfo::hasDefaultConstructor() const
SpaceInfo::hasDefaultConstructor() const
{
if (numConstructors)
{
@ -1028,7 +1028,7 @@ SymbolDatabase::SpaceInfo::hasDefaultConstructor() const
}
// Get variable list..
void SymbolDatabase::SpaceInfo::getVarList()
void SpaceInfo::getVarList()
{
AccessControl varaccess = type == Class ? Private : Public;
const Token *start;
@ -1230,7 +1230,7 @@ const Token* skipPointers(const Token* tok)
return ret;
}
bool SymbolDatabase::SpaceInfo::isVariableDeclaration(const Token* tok, const Token*& vartok, const Token*& typetok) const
bool SpaceInfo::isVariableDeclaration(const Token* tok, const Token*& vartok, const Token*& typetok) const
{
const Token* localTypeTok = skipScopeIdentifiers(tok);
@ -1271,17 +1271,17 @@ bool SymbolDatabase::SpaceInfo::isVariableDeclaration(const Token* tok, const To
return NULL != vartok;
}
bool SymbolDatabase::SpaceInfo::isSimpleVariable(const Token* tok) const
bool SpaceInfo::isSimpleVariable(const Token* tok) const
{
return Token::Match(tok, "%var% ;");
}
bool SymbolDatabase::SpaceInfo::isArrayVariable(const Token* tok) const
bool SpaceInfo::isArrayVariable(const Token* tok) const
{
return Token::Match(tok, "%var% [") && tok->next()->str() != "operator";
}
bool SymbolDatabase::SpaceInfo::findClosingBracket(const Token* tok, const Token*& close) const
bool SpaceInfo::findClosingBracket(const Token* tok, const Token*& close) const
{
bool found = false;
if (NULL != tok && tok->str() == "<")
@ -1310,7 +1310,7 @@ bool SymbolDatabase::SpaceInfo::findClosingBracket(const Token* tok, const Token
//---------------------------------------------------------------------------
const SymbolDatabase::SpaceInfo *SymbolDatabase::findVarType(const SpaceInfo *start, const Token *type) const
const SpaceInfo *SymbolDatabase::findVarType(const SpaceInfo *start, const Token *type) const
{
std::list<SpaceInfo *>::const_iterator it;
@ -1352,7 +1352,7 @@ const SymbolDatabase::SpaceInfo *SymbolDatabase::findVarType(const SpaceInfo *st
//---------------------------------------------------------------------------
SymbolDatabase::SpaceInfo * SymbolDatabase::SpaceInfo::findInNestedList(const std::string & name)
SpaceInfo * SpaceInfo::findInNestedList(const std::string & name)
{
std::list<SpaceInfo *>::iterator it;
@ -1366,7 +1366,7 @@ SymbolDatabase::SpaceInfo * SymbolDatabase::SpaceInfo::findInNestedList(const st
//---------------------------------------------------------------------------
const SymbolDatabase::Func *SymbolDatabase::SpaceInfo::getDestructor() const
const Func *SpaceInfo::getDestructor() const
{
std::list<Func>::const_iterator it;
for (it = functionList.begin(); it != functionList.end(); ++it)
@ -1379,7 +1379,7 @@ const SymbolDatabase::Func *SymbolDatabase::SpaceInfo::getDestructor() const
//---------------------------------------------------------------------------
unsigned int SymbolDatabase::SpaceInfo::getNestedNonFunctions() const
unsigned int SpaceInfo::getNestedNonFunctions() const
{
unsigned int nested = 0;
std::list<SpaceInfo *>::const_iterator ni;

View File

@ -31,106 +31,104 @@ class Tokenizer;
class Settings;
class ErrorLogger;
class SymbolDatabase
class SpaceInfo;
class SymbolDatabase;
/**
* @brief Access control.
*/
enum AccessControl { Public, Protected, Private };
/** @brief Information about a member variable. */
class Var
{
public:
/**
* @brief Access control.
*/
enum AccessControl { Public, Protected, Private };
SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
~SymbolDatabase();
class SpaceInfo;
/** @brief Information about a member variable. */
class Var
Var(const Token *token_, std::size_t index_, AccessControl access_, bool mutable_, bool static_, bool const_, bool class_, const SpaceInfo *type_)
: token(token_),
index(index_),
access(access_),
isMutable(mutable_),
isStatic(static_),
isConst(const_),
isClass(class_),
type(type_)
{
public:
Var(const Token *token_, std::size_t index_, AccessControl access_, bool mutable_, bool static_, bool const_, bool class_, const SpaceInfo *type_)
: token(token_),
index(index_),
access(access_),
isMutable(mutable_),
isStatic(static_),
isConst(const_),
isClass(class_),
type(type_)
{
}
}
/** @brief variable token */
const Token *token;
/** @brief variable token */
const Token *token;
/** @brief order declared */
std::size_t index;
/** @brief order declared */
std::size_t index;
/** @brief what section is this variable declared in? */
AccessControl access; // public/protected/private
/** @brief what section is this variable declared in? */
AccessControl access; // public/protected/private
/** @brief is this variable mutable? */
bool isMutable;
/** @brief is this variable mutable? */
bool isMutable;
/** @brief is this variable static? */
bool isStatic;
/** @brief is this variable static? */
bool isStatic;
/** @brief is this variable const? */
bool isConst;
/** @brief is this variable const? */
bool isConst;
/** @brief is this variable a class (or unknown type)? */
bool isClass;
/** @brief is this variable a class (or unknown type)? */
bool isClass;
/** @brief pointer to user defined type info (for known types) */
const SpaceInfo *type;
};
/** @brief pointer to user defined type info (for known types) */
const SpaceInfo *type;
};
class Func
class Func
{
public:
enum Type { Constructor, CopyConstructor, OperatorEqual, Destructor, Function };
Func()
: tokenDef(NULL),
argDef(NULL),
token(NULL),
arg(NULL),
access(Public),
hasBody(false),
isInline(false),
isConst(false),
isVirtual(false),
isPure(false),
isStatic(false),
isFriend(false),
isExplicit(false),
isOperator(false),
retFuncPtr(false),
type(Function)
{
public:
enum Type { Constructor, CopyConstructor, OperatorEqual, Destructor, Function };
}
Func()
: tokenDef(NULL),
argDef(NULL),
token(NULL),
arg(NULL),
access(Public),
hasBody(false),
isInline(false),
isConst(false),
isVirtual(false),
isPure(false),
isStatic(false),
isFriend(false),
isExplicit(false),
isOperator(false),
retFuncPtr(false),
type(Function)
{
}
unsigned int argCount() const;
unsigned int initializedArgCount() const;
unsigned int argCount() const;
unsigned int initializedArgCount() const;
const Token *tokenDef; // function name token in class definition
const Token *argDef; // function argument start '(' in class definition
const Token *token; // function name token in implementation
const Token *arg; // function argument start '('
AccessControl access; // public/protected/private
bool hasBody; // has implementation
bool isInline; // implementation in class definition
bool isConst; // is const
bool isVirtual; // is virtual
bool isPure; // is pure virtual
bool isStatic; // is static
bool isFriend; // is friend
bool isExplicit; // is explicit
bool isOperator; // is operator
bool retFuncPtr; // returns function pointer
Type type; // constructor, destructor, ...
};
const Token *tokenDef; // function name token in class definition
const Token *argDef; // function argument start '(' in class definition
const Token *token; // function name token in implementation
const Token *arg; // function argument start '('
AccessControl access; // public/protected/private
bool hasBody; // has implementation
bool isInline; // implementation in class definition
bool isConst; // is const
bool isVirtual; // is virtual
bool isPure; // is pure virtual
bool isStatic; // is static
bool isFriend; // is friend
bool isExplicit; // is explicit
bool isOperator; // is operator
bool retFuncPtr; // returns function pointer
Type type; // constructor, destructor, ...
};
class SpaceInfo
{
public:
struct BaseInfo
{
AccessControl access; // public/protected/private
@ -144,75 +142,78 @@ public:
SpaceInfo *spaceInfo;
};
class SpaceInfo
enum SpaceType { Global, Class, Struct, Union, Namespace, Function };
enum NeedInitialization { Unknown, True, False };
SpaceInfo(SymbolDatabase *check_, const Token *classDef_, SpaceInfo *nestedIn_);
SymbolDatabase *check;
SpaceType type;
std::string className;
const Token *classDef; // class/struct/union/namespace token
const Token *classStart; // '{' token
const Token *classEnd; // '}' token
std::list<Func> functionList;
std::list<Var> varlist;
std::vector<BaseInfo> derivedFrom;
std::list<FriendInfo> friendList;
SpaceInfo *nestedIn;
std::list<SpaceInfo *> nestedList;
AccessControl access;
unsigned int numConstructors;
NeedInitialization needInitialization;
SpaceInfo * functionOf; // class/struct this function belongs to
bool isClassOrStruct() const
{
public:
enum SpaceType { Global, Class, Struct, Union, Namespace, Function };
enum NeedInitialization { Unknown, True, False };
return (type == Class || type == Struct);
}
SpaceInfo(SymbolDatabase *check_, const Token *classDef_, SpaceInfo *nestedIn_);
/**
* @brief find if name is in nested list
* @param name name of nested space
*/
SpaceInfo * findInNestedList(const std::string & name);
SymbolDatabase *check;
SpaceType type;
std::string className;
const Token *classDef; // class/struct/union/namespace token
const Token *classStart; // '{' token
const Token *classEnd; // '}' token
std::list<Func> functionList;
std::list<Var> varlist;
std::vector<BaseInfo> derivedFrom;
std::list<FriendInfo> friendList;
SpaceInfo *nestedIn;
std::list<SpaceInfo *> nestedList;
AccessControl access;
unsigned int numConstructors;
NeedInitialization needInitialization;
SpaceInfo * functionOf; // class/struct this function belongs to
void addVar(const Token *token_, AccessControl access_, bool mutable_, bool static_, bool const_, bool class_, const SpaceInfo *type_)
{
varlist.push_back(Var(token_, varlist.size(), access_, mutable_, static_, const_, class_, type_));
}
bool isClassOrStruct() const
{
return (type == Class || type == Struct);
}
/** @brief initialize varlist */
void getVarList();
/**
* @brief find if name is in nested list
* @param name name of nested space
*/
SpaceInfo * findInNestedList(const std::string & name);
const Func *getDestructor() const;
void addVar(const Token *token_, AccessControl access_, bool mutable_, bool static_, bool const_, bool class_, const SpaceInfo *type_)
{
varlist.push_back(Var(token_, varlist.size(), access_, mutable_, static_, const_, class_, type_));
}
/**
* @brief get the number of nested spaces that are not functions
*
* This returns the number of user defined types (class, struct, union)
* that are defined in this user defined type or namespace.
*/
unsigned int getNestedNonFunctions() const;
/** @brief initialize varlist */
void getVarList();
bool hasDefaultConstructor() const;
const Func *getDestructor() const;
private:
/**
* @brief helper function for getVarList()
* @param tok pointer to token to check
* @param vartok populated with pointer to the variable token, if found
* @param typetok populated with pointer to the type token, if found
* @return true if tok points to a variable declaration, false otherwise
*/
bool isVariableDeclaration(const Token* tok, const Token*& vartok, const Token*& typetok) const;
bool isSimpleVariable(const Token* tok) const;
bool isArrayVariable(const Token* tok) const;
bool findClosingBracket(const Token* tok, const Token*& close) const;
};
/**
* @brief get the number of nested spaces that are not functions
*
* This returns the number of user defined types (class, struct, union)
* that are defined in this user defined type or namespace.
*/
unsigned int getNestedNonFunctions() const;
bool hasDefaultConstructor() const;
private:
/**
* @brief helper function for getVarList()
* @param tok pointer to token to check
* @param vartok populated with pointer to the variable token, if found
* @param typetok populated with pointer to the type token, if found
* @return true if tok points to a variable declaration, false otherwise
*/
bool isVariableDeclaration(const Token* tok, const Token*& vartok, const Token*& typetok) const;
bool isSimpleVariable(const Token* tok) const;
bool isArrayVariable(const Token* tok) const;
bool findClosingBracket(const Token* tok, const Token*& close) const;
};
class SymbolDatabase
{
public:
SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
~SymbolDatabase();
/** @brief Information about all namespaces/classes/structrues */
std::list<SpaceInfo *> spaceInfoList;

View File

@ -735,7 +735,7 @@ Token * Tokenizer::deleteInvalidTypedef(Token *typeDef)
return tok;
}
struct SpaceInfo
struct Space
{
bool isNamespace;
std::string className;
@ -816,7 +816,7 @@ static Token *splitDefinitionFromTypedef(Token *tok)
void Tokenizer::simplifyTypedef()
{
std::vector<SpaceInfo> spaceInfo;
std::vector<Space> spaceInfo;
bool isNamespace = false;
std::string className;
bool hasClass = false;
@ -839,7 +839,7 @@ void Tokenizer::simplifyTypedef()
}
else if (hasClass && tok->str() == "{")
{
SpaceInfo info;
Space info;
info.isNamespace = isNamespace;
info.className = className;
info.classEnd = tok->link();
@ -7954,13 +7954,13 @@ const Token *Tokenizer::getFunctionTokenByName(const char funcname[]) const
if (_symbolDatabase == NULL)
getSymbolDatabase();
std::list<SymbolDatabase::SpaceInfo *>::const_iterator i;
std::list<SpaceInfo *>::const_iterator i;
for (i = _symbolDatabase->spaceInfoList.begin(); i != _symbolDatabase->spaceInfoList.end(); ++i)
{
const SymbolDatabase::SpaceInfo *info = *i;
const SpaceInfo *info = *i;
if (info->type == SymbolDatabase::SpaceInfo::Function)
if (info->type == SpaceInfo::Function)
{
if (info->classDef->str() == funcname)
return info->classDef;

View File

@ -32,7 +32,7 @@ public:
{}
private:
const SymbolDatabase::SpaceInfo si;
const SpaceInfo si;
const Token* vartok;
const Token* typetok;
const Token* t;