Merge pull request #376 from Dmitry-Me/resolveIssue1214637

Resolve CID 1214637.
This commit is contained in:
PKEuS 2014-07-24 15:49:36 +02:00
commit 65e9085b66
2 changed files with 12 additions and 8 deletions

View File

@ -1190,7 +1190,13 @@ void CheckClass::operatorEqRetRefThis()
} }
} }
void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set<const Function*>* analyzedFunctions) void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last)
{
std::set<const Function*> analyzedFunctions;
checkReturnPtrThis(scope, func, tok, last, analyzedFunctions);
}
void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set<const Function*>& analyzedFunctions)
{ {
bool foundReturn = false; bool foundReturn = false;
@ -1219,11 +1225,8 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
if (!it->isConst) { if (!it->isConst) {
/** @todo make sure argument types match */ /** @todo make sure argument types match */
// avoid endless recursions // avoid endless recursions
if (!analyzedFunctions || analyzedFunctions->find(&*it)==analyzedFunctions->end()) { if (analyzedFunctions.find(&*it) == analyzedFunctions.end()) {
std::set<const Function*> local_analyzedFunctions; analyzedFunctions.insert(&*it);
if (!analyzedFunctions)
analyzedFunctions=&local_analyzedFunctions;
analyzedFunctions->insert(&*it);
checkReturnPtrThis(scope, &*it, it->arg->link()->next(), it->arg->link()->next()->link(), checkReturnPtrThis(scope, &*it, it->arg->link()->next(), it->arg->link()->next()->link(),
analyzedFunctions); analyzedFunctions);
} }

View File

@ -201,8 +201,9 @@ private:
"* Duplicated inherited data members\n"; "* Duplicated inherited data members\n";
} }
// operatorEqRetRefThis helper function // operatorEqRetRefThis helper functions
void checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set<const Function*>* analyzedFunctions=nullptr); void checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last);
void checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set<const Function*>& analyzedFunctions);
// operatorEqToSelf helper functions // operatorEqToSelf helper functions
bool hasAllocation(const Function *func, const Scope* scope) const; bool hasAllocation(const Function *func, const Scope* scope) const;