@@ -6123,7 +6123,7 @@ const Scope *SymbolDatabase::findScopeByName(const std::string& name) const
61236123// ---------------------------------------------------------------------------
61246124
61256125template <class S , class T , REQUIRES(" S must be a Scope class" , std::is_convertible<S*, const Scope*> ), REQUIRES(" T must be a Type class" , std::is_convertible<T*, const Type*> )>
6126- S* findRecordInNestedListImpl (S& thisScope, const std::string & name, bool isC)
6126+ S* findRecordInNestedListImpl (S& thisScope, const std::string& name, bool isC, std::set< const Scope*>& visited )
61276127{
61286128 for (S* scope: thisScope.nestedList ) {
61296129 if (scope->className == name && scope->type != Scope::eFunction)
@@ -6136,9 +6136,10 @@ S* findRecordInNestedListImpl(S& thisScope, const std::string & name, bool isC)
61366136 }
61376137
61386138 for (const auto & u : thisScope.usingList ) {
6139- if (!u.scope || u.scope == &thisScope)
6139+ if (!u.scope || u.scope == &thisScope || visited. find (u. scope ) != visited. end () )
61406140 continue ;
6141- S* nestedScope = const_cast <S*>(u.scope )->findRecordInNestedList (name, false );
6141+ visited.emplace (u.scope );
6142+ S* nestedScope = findRecordInNestedListImpl<S, T>(const_cast <S&>(*u.scope ), name, false , visited);
61426143 if (nestedScope)
61436144 return nestedScope;
61446145 }
@@ -6158,12 +6159,14 @@ S* findRecordInNestedListImpl(S& thisScope, const std::string & name, bool isC)
61586159
61596160const Scope* Scope::findRecordInNestedList (const std::string & name, bool isC) const
61606161{
6161- return findRecordInNestedListImpl<const Scope, const Type>(*this , name, isC);
6162+ std::set<const Scope*> visited;
6163+ return findRecordInNestedListImpl<const Scope, const Type>(*this , name, isC, visited);
61626164}
61636165
61646166Scope* Scope::findRecordInNestedList (const std::string & name, bool isC)
61656167{
6166- return findRecordInNestedListImpl<Scope, Type>(*this , name, isC);
6168+ std::set<const Scope*> visited;
6169+ return findRecordInNestedListImpl<Scope, Type>(*this , name, isC, visited);
61676170}
61686171
61696172// ---------------------------------------------------------------------------
0 commit comments