Remove some code checking for invalid class hierarchy which got obsolete since 480a5672b0. Run astyle

This commit is contained in:
Alexander Mai 2015-07-01 07:50:13 +02:00
parent 480a5672b0
commit 6e03e7dca2
11 changed files with 71 additions and 70 deletions

View File

@ -1764,7 +1764,7 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const
} }
// not found in this class // not found in this class
if (!scope->definedType->derivedFrom.empty() && !scope->definedType->hasCircularDependencies()) { if (!scope->definedType->derivedFrom.empty()) {
// check each base class // check each base class
for (std::size_t i = 0; i < scope->definedType->derivedFrom.size(); ++i) { for (std::size_t i = 0; i < scope->definedType->derivedFrom.size(); ++i) {
// find the base class // find the base class
@ -1794,7 +1794,7 @@ bool CheckClass::isMemberFunc(const Scope *scope, const Token *tok) const
const Type *derivedFrom = scope->definedType->derivedFrom[i].type; const Type *derivedFrom = scope->definedType->derivedFrom[i].type;
// find the function in the base class // find the function in the base class
if (derivedFrom && derivedFrom->classScope && !derivedFrom->hasCircularDependencies()) { if (derivedFrom && derivedFrom->classScope) {
if (isMemberFunc(derivedFrom->classScope, tok)) if (isMemberFunc(derivedFrom->classScope, tok))
return true; return true;
} }
@ -1817,7 +1817,7 @@ bool CheckClass::isConstMemberFunc(const Scope *scope, const Token *tok) const
const Type *derivedFrom = scope->definedType->derivedFrom[i].type; const Type *derivedFrom = scope->definedType->derivedFrom[i].type;
// find the function in the base class // find the function in the base class
if (derivedFrom && derivedFrom->classScope && !derivedFrom->hasCircularDependencies()) { if (derivedFrom && derivedFrom->classScope) {
if (isConstMemberFunc(derivedFrom->classScope, tok)) if (isConstMemberFunc(derivedFrom->classScope, tok))
return true; return true;
} }

View File

@ -41,7 +41,8 @@ namespace {
<< "fgetgrent" << "ecvt" << "gcvt" << "getservent" << "gethostent" << "getgrent" << "fcvt" ; << "fgetgrent" << "ecvt" << "gcvt" << "getservent" << "gethostent" << "getgrent" << "fcvt" ;
} }
std::string CheckNonReentrantFunctions::generateErrorMessage(const std::string& function) { std::string CheckNonReentrantFunctions::generateErrorMessage(const std::string& function)
{
return std::string("Non reentrant function '") + function + "' called. " + return std::string("Non reentrant function '") + function + "' called. " +
"For threadsafe applications it is recommended to use the reentrant replacement function '" + function + "_r'."; "For threadsafe applications it is recommended to use the reentrant replacement function '" + function + "_r'.";
} }
@ -83,7 +84,8 @@ void CheckNonReentrantFunctions::nonReentrantFunctions()
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void CheckNonReentrantFunctions::getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const { void CheckNonReentrantFunctions::getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const
{
CheckNonReentrantFunctions c(0, settings, errorLogger); CheckNonReentrantFunctions c(0, settings, errorLogger);
std::set<std::string>::const_iterator it(_nonReentrantFunctions.begin()), itend(_nonReentrantFunctions.end()); std::set<std::string>::const_iterator it(_nonReentrantFunctions.begin()), itend(_nonReentrantFunctions.end());
@ -92,7 +94,8 @@ void CheckNonReentrantFunctions::getErrorMessages(ErrorLogger *errorLogger, cons
} }
} }
std::string CheckNonReentrantFunctions::classInfo() const { std::string CheckNonReentrantFunctions::classInfo() const
{
std::string info = "Warn if any of these non reentrant functions are used:\n"; std::string info = "Warn if any of these non reentrant functions are used:\n";
std::set<std::string>::const_iterator it(_nonReentrantFunctions.begin()), itend(_nonReentrantFunctions.end()); std::set<std::string>::const_iterator it(_nonReentrantFunctions.begin()), itend(_nonReentrantFunctions.end());
for (; it!=itend; ++it) { for (; it!=itend; ++it) {

View File

@ -849,8 +849,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
if (found && found->findDependency(&(*it))) { if (found && found->findDependency(&(*it))) {
// circular dependency // circular dependency
//_tokenizer->syntaxError(nullptr); //_tokenizer->syntaxError(nullptr);
} } else {
else {
it->derivedFrom[i].type = found; it->derivedFrom[i].type = found;
} }
} }
@ -2062,7 +2061,8 @@ bool Type::hasCircularDependencies(std::set<BaseInfo>* anchestors) const
return false; return false;
} }
bool Type::findDependency(const Type* anchestor) const { bool Type::findDependency(const Type* anchestor) const
{
if (this==anchestor) if (this==anchestor)
return true; return true;
for (std::vector<BaseInfo>::const_iterator parent=derivedFrom.begin(); parent!=derivedFrom.end(); ++parent) { for (std::vector<BaseInfo>::const_iterator parent=derivedFrom.begin(); parent!=derivedFrom.end(); ++parent) {

View File

@ -824,8 +824,7 @@ const Token * Token::findClosingBracket() const
closing = closing->link(); closing = closing->link();
if (!closing) if (!closing)
return nullptr; // #6803 return nullptr; // #6803
} } else if (Token::Match(closing, "}|]|)|;"))
else if (Token::Match(closing, "}|]|)|;"))
break; break;
else if (closing->str() == "<") else if (closing->str() == "<")
++depth; ++depth;

View File

@ -148,8 +148,7 @@ private:
// run alternate check first. It should only ensure stability // run alternate check first. It should only ensure stability
try { try {
checkCodeInternal(code, alternatefilename); checkCodeInternal(code, alternatefilename);
} } catch (InternalError&) {
catch(InternalError& ) {
} }
return checkCodeInternal(code, filename); return checkCodeInternal(code, filename);