Refactorization in SymbolDatabase: Do not redundantly store name in FriendInfo, and store FriendInfo in vector instead of list
This commit is contained in:
parent
4d549553b0
commit
090a178ed6
|
@ -1055,10 +1055,10 @@ void CheckClass::privateFunctions()
|
||||||
// Check that all private functions are used
|
// Check that all private functions are used
|
||||||
bool used = checkFunctionUsage(privateFuncs.front(), scope); // Usage in this class
|
bool used = checkFunctionUsage(privateFuncs.front(), scope); // Usage in this class
|
||||||
// Check in friend classes
|
// Check in friend classes
|
||||||
const std::list<Type::FriendInfo>& friendList = scope->definedType->friendList;
|
const std::vector<Type::FriendInfo>& friendList = scope->definedType->friendList;
|
||||||
for (std::list<Type::FriendInfo>::const_iterator it = friendList.begin(); !used && it != friendList.end(); ++it) {
|
for (size_t i = 0; i < friendList.size(); i++) {
|
||||||
if (it->type)
|
if (friendList[i].type)
|
||||||
used = checkFunctionUsage(privateFuncs.front(), it->type->classScope);
|
used = checkFunctionUsage(privateFuncs.front(), friendList[i].type->classScope);
|
||||||
else
|
else
|
||||||
used = true; // Assume, it is used if we do not see friend class
|
used = true; // Assume, it is used if we do not see friend class
|
||||||
}
|
}
|
||||||
|
|
|
@ -544,10 +544,6 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
while (friendInfo.nameEnd && friendInfo.nameEnd->strAt(1) == "::")
|
while (friendInfo.nameEnd && friendInfo.nameEnd->strAt(1) == "::")
|
||||||
friendInfo.nameEnd = friendInfo.nameEnd->tokAt(2);
|
friendInfo.nameEnd = friendInfo.nameEnd->tokAt(2);
|
||||||
|
|
||||||
// save the name
|
|
||||||
if (friendInfo.nameEnd)
|
|
||||||
friendInfo.name = friendInfo.nameEnd->str();
|
|
||||||
|
|
||||||
// fill this in after parsing is complete
|
// fill this in after parsing is complete
|
||||||
friendInfo.type = nullptr;
|
friendInfo.type = nullptr;
|
||||||
|
|
||||||
|
@ -705,7 +701,7 @@ void SymbolDatabase::createSymbolDatabaseClassInfo()
|
||||||
|
|
||||||
// fill in friend info
|
// fill in friend info
|
||||||
for (std::list<Type>::iterator it = typeList.begin(); it != typeList.end(); ++it) {
|
for (std::list<Type>::iterator it = typeList.begin(); it != typeList.end(); ++it) {
|
||||||
for (std::list<Type::FriendInfo>::iterator i = it->friendList.begin(); i != it->friendList.end(); ++i) {
|
for (std::vector<Type::FriendInfo>::iterator i = it->friendList.begin(); i != it->friendList.end(); ++i) {
|
||||||
i->type = findType(i->nameStart, it->enclosingScope);
|
i->type = findType(i->nameStart, it->enclosingScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2884,18 +2880,14 @@ void SymbolDatabase::printOut(const char *title) const
|
||||||
std::cout << " )" << std::endl;
|
std::cout << " )" << std::endl;
|
||||||
|
|
||||||
std::cout << " friendList[" << type->friendList.size() << "] = (";
|
std::cout << " friendList[" << type->friendList.size() << "] = (";
|
||||||
|
for (size_t i = 0; i < type->friendList.size(); i++) {
|
||||||
std::list<Type::FriendInfo>::const_iterator fii;
|
if (type->friendList[i].type)
|
||||||
|
std::cout << type->friendList[i].type;
|
||||||
count = type->friendList.size();
|
|
||||||
for (fii = type->friendList.begin(); fii != type->friendList.end(); ++fii) {
|
|
||||||
if (fii->type)
|
|
||||||
std::cout << fii->type;
|
|
||||||
else
|
else
|
||||||
std::cout << " Unknown";
|
std::cout << " Unknown";
|
||||||
|
|
||||||
std::cout << " " << fii->name;
|
std::cout << " " << type->friendList[i].nameEnd ? type->friendList[i].nameEnd->str() : emptyString;
|
||||||
if (count-- > 1)
|
if (i+1 < type->friendList.size())
|
||||||
std::cout << ",";
|
std::cout << ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,12 +93,11 @@ public:
|
||||||
|
|
||||||
const Token* nameStart;
|
const Token* nameStart;
|
||||||
const Token* nameEnd;
|
const Token* nameEnd;
|
||||||
std::string name;
|
|
||||||
const Type* type;
|
const Type* type;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<BaseInfo> derivedFrom;
|
std::vector<BaseInfo> derivedFrom;
|
||||||
std::list<FriendInfo> friendList;
|
std::vector<FriendInfo> friendList;
|
||||||
|
|
||||||
const Token * typeStart;
|
const Token * typeStart;
|
||||||
const Token * typeEnd;
|
const Token * typeEnd;
|
||||||
|
|
|
@ -1580,8 +1580,8 @@ private:
|
||||||
ASSERT(bar2 != nullptr);
|
ASSERT(bar2 != nullptr);
|
||||||
|
|
||||||
if (foo && bar1 && bar2) {
|
if (foo && bar1 && bar2) {
|
||||||
ASSERT(bar1->definedType->friendList.size() == 1 && bar1->definedType->friendList.front().name == "Foo" && bar1->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().name == "Foo" && bar2->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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue