diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index c44b2ee79..e50762e15 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1055,10 +1055,10 @@ void CheckClass::privateFunctions() // Check that all private functions are used bool used = checkFunctionUsage(privateFuncs.front(), scope); // Usage in this class // Check in friend classes - const std::list& friendList = scope->definedType->friendList; - for (std::list::const_iterator it = friendList.begin(); !used && it != friendList.end(); ++it) { - if (it->type) - used = checkFunctionUsage(privateFuncs.front(), it->type->classScope); + const std::vector& friendList = scope->definedType->friendList; + for (size_t i = 0; i < friendList.size(); i++) { + if (friendList[i].type) + used = checkFunctionUsage(privateFuncs.front(), friendList[i].type->classScope); else used = true; // Assume, it is used if we do not see friend class } diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 0a0ae30b9..863aae7cf 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -544,10 +544,6 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() while (friendInfo.nameEnd && friendInfo.nameEnd->strAt(1) == "::") friendInfo.nameEnd = friendInfo.nameEnd->tokAt(2); - // save the name - if (friendInfo.nameEnd) - friendInfo.name = friendInfo.nameEnd->str(); - // fill this in after parsing is complete friendInfo.type = nullptr; @@ -705,7 +701,7 @@ void SymbolDatabase::createSymbolDatabaseClassInfo() // fill in friend info for (std::list::iterator it = typeList.begin(); it != typeList.end(); ++it) { - for (std::list::iterator i = it->friendList.begin(); i != it->friendList.end(); ++i) { + for (std::vector::iterator i = it->friendList.begin(); i != it->friendList.end(); ++i) { i->type = findType(i->nameStart, it->enclosingScope); } } @@ -2884,18 +2880,14 @@ void SymbolDatabase::printOut(const char *title) const std::cout << " )" << std::endl; std::cout << " friendList[" << type->friendList.size() << "] = ("; - - std::list::const_iterator fii; - - count = type->friendList.size(); - for (fii = type->friendList.begin(); fii != type->friendList.end(); ++fii) { - if (fii->type) - std::cout << fii->type; + for (size_t i = 0; i < type->friendList.size(); i++) { + if (type->friendList[i].type) + std::cout << type->friendList[i].type; else std::cout << " Unknown"; - std::cout << " " << fii->name; - if (count-- > 1) + std::cout << " " << type->friendList[i].nameEnd ? type->friendList[i].nameEnd->str() : emptyString; + if (i+1 < type->friendList.size()) std::cout << ","; } diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 5590ba0ab..25fc5fffe 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -93,12 +93,11 @@ public: const Token* nameStart; const Token* nameEnd; - std::string name; const Type* type; }; std::vector derivedFrom; - std::list friendList; + std::vector friendList; const Token * typeStart; const Token * typeEnd; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index b67adb274..ec39205eb 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -1580,8 +1580,8 @@ private: ASSERT(bar2 != nullptr); if (foo && bar1 && bar2) { - ASSERT(bar1->definedType->friendList.size() == 1 && bar1->definedType->friendList.front().name == "Foo" && bar1->definedType->friendList.front().type == foo->definedType); - ASSERT(bar2->definedType->friendList.size() == 1 && bar2->definedType->friendList.front().name == "Foo" && bar2->definedType->friendList.front().type == foo->definedType); + ASSERT(bar1->definedType->friendList.size() == 1 && bar1->definedType->friendList.front().nameEnd->str() == "Foo" && bar1->definedType->friendList.front().type == foo->definedType); + ASSERT(bar2->definedType->friendList.size() == 1 && bar2->definedType->friendList.front().nameEnd->str() == "Foo" && bar2->definedType->friendList.front().type == foo->definedType); } } }