From 4e2ddbab71e5daa9496cffc3ad1be1b30593cd10 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:30:47 +0200 Subject: [PATCH] Update symboldatabase.cpp --- lib/symboldatabase.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 4082a894e2f..9bdff3f622c 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6123,7 +6123,7 @@ const Scope *SymbolDatabase::findScopeByName(const std::string& name) const //--------------------------------------------------------------------------- template ), REQUIRES("T must be a Type class", std::is_convertible )> -S* findRecordInNestedListImpl(S& thisScope, const std::string & name, bool isC) +S* findRecordInNestedListImpl(S& thisScope, const std::string& name, bool isC, std::set& visited) { for (S* scope: thisScope.nestedList) { if (scope->className == name && scope->type != Scope::eFunction) @@ -6136,9 +6136,10 @@ S* findRecordInNestedListImpl(S& thisScope, const std::string & name, bool isC) } for (const auto& u : thisScope.usingList) { - if (!u.scope || u.scope == &thisScope) + if (!u.scope || u.scope == &thisScope || visited.find(u.scope) != visited.end()) continue; - S* nestedScope = const_cast(u.scope)->findRecordInNestedList(name, false); + visited.emplace(u.scope); + S* nestedScope = findRecordInNestedListImpl(const_cast(*u.scope), name, false, visited); if (nestedScope) return nestedScope; } @@ -6158,12 +6159,14 @@ S* findRecordInNestedListImpl(S& thisScope, const std::string & name, bool isC) const Scope* Scope::findRecordInNestedList(const std::string & name, bool isC) const { - return findRecordInNestedListImpl(*this, name, isC); + std::set visited; + return findRecordInNestedListImpl(*this, name, isC, visited); } Scope* Scope::findRecordInNestedList(const std::string & name, bool isC) { - return findRecordInNestedListImpl(*this, name, isC); + std::set visited; + return findRecordInNestedListImpl(*this, name, isC, visited); } //---------------------------------------------------------------------------