From daeba94e228802e374eea260b8ba8f6157f91dbd Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Thu, 29 Oct 2020 19:54:59 +0100 Subject: Refactoring: modernize getUsedClasses() method --- src/definition.cpp | 2 +- src/definition.h | 2 +- src/definitionimpl.h | 4 +- src/doxygen.cpp | 2 +- src/filedef.cpp | 49 ++++++------------------- src/filedef.h | 5 ++- src/linkedmap.h | 99 +++++++++++++++++++++++++++++++++++++++++--------- src/namespacedef.cpp | 45 ++++++++--------------- src/namespacedef.h | 17 ++++----- src/symbolresolver.cpp | 62 ++++++++++--------------------- 10 files changed, 144 insertions(+), 143 deletions(-) diff --git a/src/definition.cpp b/src/definition.cpp index 8f0b5a1..65bbd24 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -1424,7 +1424,7 @@ void DefinitionImpl::addSourceReferences(const MemberDef *md) } } -Definition *DefinitionImpl::findInnerCompound(const char *) const +const Definition *DefinitionImpl::findInnerCompound(const char *) const { return 0; } diff --git a/src/definition.h b/src/definition.h index 9b31f2f..ee5c428 100644 --- a/src/definition.h +++ b/src/definition.h @@ -263,7 +263,7 @@ class Definition virtual const RefItemVector &xrefListItems() const = 0; - virtual Definition *findInnerCompound(const char *name) const = 0; + virtual const Definition *findInnerCompound(const char *name) const = 0; virtual Definition *getOuterScope() const = 0; virtual std::vector getReferencesMembers() const = 0; diff --git a/src/definitionimpl.h b/src/definitionimpl.h index c4e6e2a..65027b4 100644 --- a/src/definitionimpl.h +++ b/src/definitionimpl.h @@ -72,7 +72,7 @@ class DefinitionImpl : virtual public Definition virtual GroupList *partOfGroups() const; virtual bool isLinkableViaGroup() const; virtual const RefItemVector &xrefListItems() const; - virtual Definition *findInnerCompound(const char *name) const; + virtual const Definition *findInnerCompound(const char *name) const; virtual Definition *getOuterScope() const; virtual std::vector getReferencesMembers() const; virtual std::vector getReferencedByMembers() const; @@ -224,7 +224,7 @@ class DefinitionAliasImpl : virtual public Definition { return m_def->isLinkableViaGroup(); } virtual const RefItemVector &xrefListItems() const { return m_def->xrefListItems(); } - virtual Definition *findInnerCompound(const char *name) const + virtual const Definition *findInnerCompound(const char *name) const { return m_def->findInnerCompound(name); } virtual Definition *getOuterScope() const { return const_cast(m_scope); } diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 05937fe..868425b 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -795,7 +795,7 @@ static Definition *findScopeFromQualifiedName(Definition *startScope,const QCStr QCString nestedNameSpecifier = scope.mid(i1,l1); Definition *orgScope = resultScope; //printf(" nestedNameSpecifier=%s\n",nestedNameSpecifier.data()); - resultScope = resultScope->findInnerCompound(nestedNameSpecifier); + resultScope = const_cast(resultScope->findInnerCompound(nestedNameSpecifier)); //printf(" resultScope=%p\n",resultScope); if (resultScope==0) { diff --git a/src/filedef.cpp b/src/filedef.cpp index 6ab4e85..00255f5 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -79,7 +79,7 @@ class FileDefImpl : public DefinitionImpl, public FileDef virtual PackageDef *packageDef() const { return m_package; } virtual DirDef *getDirDef() const { return m_dir; } virtual NamespaceSDict *getUsedNamespaces() const; - virtual SDict *getUsedClasses() const { return m_usingDeclList; } + virtual LinkedRefMap getUsedClasses() const { return m_usingDeclList; } virtual QList *includeFileList() const { return m_includeList; } virtual QList *includedByFileList() const { return m_includedByList; } virtual void getAllIncludeFilesRecursively(StringVector &incFiles) const; @@ -113,7 +113,7 @@ class FileDefImpl : public DefinitionImpl, public FileDef virtual void setPackageDef(PackageDef *pd) { m_package=pd; } virtual void setDirDef(DirDef *dd) { m_dir=dd; } virtual void addUsingDirective(const NamespaceDef *nd); - virtual void addUsingDeclaration(Definition *def); + virtual void addUsingDeclaration(const ClassDef *cd); virtual void combineUsingRelations(); virtual bool generateSourceFile() const; virtual void sortMemberLists(); @@ -157,7 +157,7 @@ class FileDefImpl : public DefinitionImpl, public FileDef QDict *m_includedByDict; QList *m_includedByList; NamespaceSDict *m_usingDirList; - SDict *m_usingDeclList; + LinkedRefMap m_usingDeclList; QCString m_path; QCString m_filePath; QCString m_inclDepFileName; @@ -241,7 +241,6 @@ FileDefImpl::FileDefImpl(const char *p,const char *nm, m_srcDefDict = 0; m_srcMemberDict = 0; m_usingDirList = 0; - m_usingDeclList = 0; m_package = 0; m_isSource = guessSection(nm)==Entry::SOURCE_SEC; m_docname = nm; @@ -272,7 +271,6 @@ FileDefImpl::~FileDefImpl() delete m_srcDefDict; delete m_srcMemberDict; delete m_usingDirList; - delete m_usingDeclList; delete m_memberGroupSDict; } @@ -1507,16 +1505,9 @@ NamespaceSDict *FileDefImpl::getUsedNamespaces() const return m_usingDirList; } -void FileDefImpl::addUsingDeclaration(Definition *d) +void FileDefImpl::addUsingDeclaration(const ClassDef *cd) { - if (m_usingDeclList==0) - { - m_usingDeclList = new SDict(17); - } - if (m_usingDeclList->find(d->qualifiedName())==0) - { - m_usingDeclList->append(d->qualifiedName(),d); - } + m_usingDeclList.add(cd->qualifiedName(),cd); } void FileDefImpl::addIncludeDependency(FileDef *fd,const char *incName,bool local,bool imported) @@ -1588,23 +1579,11 @@ void FileDefImpl::addIncludedUsingDirectives() } } // add using declarations - SDict *udl = ii->fileDef->getUsedClasses(); - if (udl) + auto udl = ii->fileDef->getUsedClasses(); + for (auto it = udl.rbegin(); it!=udl.rend(); ++it) { - SDict::Iterator udi(*udl); - Definition *d; - for (udi.toLast();(d=udi.current());--udi) - { - //printf("Adding using declaration %s\n",d->name().data()); - if (m_usingDeclList==0) - { - m_usingDeclList = new SDict(17); - } - if (m_usingDeclList->find(d->qualifiedName())==0) - { - m_usingDeclList->prepend(d->qualifiedName(),d); - } - } + const auto *cd = *it; + m_usingDeclList.prepend(cd->qualifiedName(),cd); } } } @@ -1955,15 +1934,9 @@ void FileDefImpl::combineUsingRelations() } } // add used classes of namespace nd to this namespace - if (nd->getUsedClasses()) + for (const auto &ucd : nd->getUsedClasses()) { - SDict::Iterator cli(*nd->getUsedClasses()); - Definition *ucd; - for (cli.toFirst();(ucd=cli.current());++cli) - { - //printf("Adding class %s to the using list of %s\n",cd->qualifiedName().data(),qualifiedName().data()); - addUsingDeclaration(ucd); - } + addUsingDeclaration(ucd); } } } diff --git a/src/filedef.h b/src/filedef.h index 2e11b97..03c6e2f 100644 --- a/src/filedef.h +++ b/src/filedef.h @@ -26,6 +26,7 @@ #include "sortdict.h" #include "memberlist.h" #include "containers.h" +#include "classlist.h" class MemberList; class FileDef; @@ -117,7 +118,7 @@ class FileDef : virtual public Definition virtual PackageDef *packageDef() const = 0; virtual DirDef *getDirDef() const = 0; virtual NamespaceSDict *getUsedNamespaces() const = 0; - virtual SDict *getUsedClasses() const = 0; + virtual LinkedRefMap getUsedClasses() const = 0; virtual QList *includeFileList() const = 0; virtual QList *includedByFileList() const = 0; virtual void getAllIncludeFilesRecursively(StringVector &incFiles) const = 0; @@ -165,7 +166,7 @@ class FileDef : virtual public Definition virtual void setDirDef(DirDef *dd) = 0; virtual void addUsingDirective(const NamespaceDef *nd) = 0; - virtual void addUsingDeclaration(Definition *def) = 0; + virtual void addUsingDeclaration(const ClassDef *cd) = 0; virtual void combineUsingRelations() = 0; virtual bool generateSourceFile() const = 0; diff --git a/src/linkedmap.h b/src/linkedmap.h index 84dcf26..b2aff88 100644 --- a/src/linkedmap.h +++ b/src/linkedmap.h @@ -35,6 +35,8 @@ class LinkedMap using Map = std::unordered_map; using iterator = typename Vec::iterator; using const_iterator = typename Vec::const_iterator; + using reverse_iterator = typename Vec::reverse_iterator; + using const_reverse_iterator = typename Vec::const_reverse_iterator; //! Find an object given the key. //! Returns a pointer to the element if found or nullptr if it is not found. @@ -51,7 +53,7 @@ class LinkedMap return const_cast(static_cast(*this).find(key)); } - //! Adds a new object to the ordered set if it was not added already. + //! Adds a new object to the ordered vector if it was not added already. //! Return a non-owning pointer to the newly added object, or to the existing object if //! it was already inserted before under the given key. template @@ -69,6 +71,24 @@ class LinkedMap return result; } + //! Prepends a new object to the ordered vector if it was not added already. + //! Return a non-owning pointer to the newly added object, or to the existing object if + //! it was already inserted before under the given key. + template + T *prepend(const char *k, Args&&... args) + { + T *result = find(k); + if (result==nullptr) + { + std::string key = k ? std::string(k) : std::string(); + Ptr ptr = std::make_unique(k,std::forward(args)...); + result = ptr.get(); + m_lookup.insert({key,result}); + m_entries.push_front(std::move(ptr)); + } + return result; + } + //! Removes an object from the container and deletes it. //! Returns true if the object was delete or false it is was not found. bool del(const char *k) @@ -88,12 +108,16 @@ class LinkedMap return false; } - iterator begin() { return m_entries.begin(); } - iterator end() { return m_entries.end(); } - const_iterator begin() const { return m_entries.cbegin(); } - const_iterator end() const { return m_entries.cend(); } - bool empty() const { return m_entries.empty(); } - size_t size() const { return m_entries.size(); } + iterator begin() { return m_entries.begin(); } + iterator end() { return m_entries.end(); } + const_iterator begin() const { return m_entries.cbegin(); } + const_iterator end() const { return m_entries.cend(); } + reverse_iterator rbegin() { return m_entries.rbegin(); } + reverse_iterator rend() { return m_entries.rend(); } + const_reverse_iterator rbegin() const { return m_entries.crbegin(); } + const_reverse_iterator rend() const { return m_entries.crend(); } + bool empty() const { return m_entries.empty(); } + size_t size() const { return m_entries.size(); } void clear() { @@ -106,7 +130,6 @@ class LinkedMap Vec m_entries; }; -#if 0 // not yet used //! @brief Container class representing a vector of objects with unique keys. //! @details Objects can be efficiently be looked up given the key. //! Objects are \e not owned by the container, the container will only hold references. @@ -120,6 +143,8 @@ class LinkedRefMap using Map = std::unordered_map; using iterator = typename Vec::iterator; using const_iterator = typename Vec::const_iterator; + using reverse_iterator = typename Vec::reverse_iterator; + using const_reverse_iterator = typename Vec::const_reverse_iterator; //! find an object given the key. //! Returns a pointer to the object if found or nullptr if it is not found. @@ -136,8 +161,8 @@ class LinkedRefMap return const_cast(static_cast(*this).find(key)); } - //! Adds a new object to the ordered set if it was not added already. - //! Return true if the object was added, and false if an object with the same key + //! Adds an object reference to the ordered vector if it was not added already. + //! Return true if the reference was added, and false if an object with the same key //! was already added before bool add(const char *k, T* obj) { @@ -154,12 +179,53 @@ class LinkedRefMap } } - iterator begin() { return m_entries.begin(); } - iterator end() { return m_entries.end(); } - const_iterator begin() const { return m_entries.cbegin(); } - const_iterator end() const { return m_entries.cend(); } - bool empty() const { return m_entries.empty(); } - size_t size() const { return m_entries.size(); } + //! Prepends an object reference to the ordered vector if it was not added already. + //! Return true if the reference was added, and false if an object with the same key + //! was already added before + bool prepend(const char *k, T* obj) + { + if (find(k)==nullptr) // new element + { + std::string key = k ? std::string(k) : std::string(); + m_lookup.insert({key,obj}); + m_entries.insert(m_entries.begin(),obj); + return true; + } + else // already existing, don't add + { + return false; + } + } + + //! Removes an object from the container and deletes it. + //! Returns true if the object was delete or false it is was not found. + bool del(const char *k) + { + std::string key = k ? std::string(k) : std::string(); + auto it = m_lookup.find(key); + if (it!=m_lookup.end()) + { + auto vecit = std::find_if(m_entries.begin(),m_entries.end(),[obj=it->second](auto &el) { return el.get()==obj; }); + if (vecit!=m_entries.end()) // should always be true + { + m_entries.erase(vecit); + m_lookup.erase(it); + return true; + } + } + return false; + } + + iterator begin() { return m_entries.begin(); } + iterator end() { return m_entries.end(); } + const_iterator begin() const { return m_entries.cbegin(); } + const_iterator end() const { return m_entries.cend(); } + reverse_iterator rbegin() { return m_entries.rbegin(); } + reverse_iterator rend() { return m_entries.rend(); } + const_reverse_iterator rbegin() const { return m_entries.crbegin(); } + const_reverse_iterator rend() const { return m_entries.crend(); } + bool empty() const { return m_entries.empty(); } + size_t size() const { return m_entries.size(); } void clear() { @@ -171,7 +237,6 @@ class LinkedRefMap Map m_lookup; Vec m_entries; }; -#endif #endif diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 65456ac..f6d35fb 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -59,8 +59,8 @@ class NamespaceDefImpl : public DefinitionImpl, public NamespaceDef virtual int numDocMembers() const; virtual void addUsingDirective(const NamespaceDef *nd); virtual const NamespaceSDict *getUsedNamespaces() const; - virtual void addUsingDeclaration(const Definition *def); - virtual const SDict *getUsedClasses() const { return usingDeclList; } + virtual void addUsingDeclaration(const ClassDef *cd); + virtual LinkedRefMap getUsedClasses() const { return m_usingDeclList; } virtual void combineUsingRelations(); virtual QCString displayName(bool=TRUE) const; virtual QCString localName() const; @@ -76,7 +76,7 @@ class NamespaceDefImpl : public DefinitionImpl, public NamespaceDef virtual void distributeMemberGroupDocumentation(); virtual void findSectionsInDocumentation(); virtual void sortMemberLists(); - virtual Definition *findInnerCompound(const char *name) const; + virtual const Definition *findInnerCompound(const char *name) const; virtual void addInnerCompound(const Definition *d); virtual void addListReferences(); virtual void setFileName(const QCString &fn); @@ -125,7 +125,7 @@ class NamespaceDefImpl : public DefinitionImpl, public NamespaceDef FileList files; NamespaceSDict *usingDirList = 0; - SDict *usingDeclList = 0; + LinkedRefMap m_usingDeclList; SDict *m_innerCompounds = 0; MemberSDict *m_allMembersDict = 0; @@ -172,8 +172,8 @@ class NamespaceDefAliasImpl : public DefinitionAliasImpl, public NamespaceDef virtual void addUsingDirective(const NamespaceDef *nd) {} virtual const NamespaceSDict *getUsedNamespaces() const { return getNSAlias()->getUsedNamespaces(); } - virtual void addUsingDeclaration(const Definition *def) {} - virtual const SDict *getUsedClasses() const + virtual void addUsingDeclaration(const ClassDef *cd) {} + virtual LinkedRefMap getUsedClasses() const { return getNSAlias()->getUsedClasses(); } virtual void combineUsingRelations() {} virtual QCString displayName(bool b=TRUE) const @@ -195,7 +195,7 @@ class NamespaceDefAliasImpl : public DefinitionAliasImpl, public NamespaceDef { return getNSAlias()->isLinkable(); } virtual bool hasDetailedDescription() const { return getNSAlias()->hasDetailedDescription(); } - virtual Definition *findInnerCompound(const char *name) const + virtual const Definition *findInnerCompound(const char *name) const { return getNSAlias()->findInnerCompound(name); } virtual bool subGrouping() const { return getNSAlias()->subGrouping(); } @@ -285,7 +285,6 @@ NamespaceDefImpl::NamespaceDefImpl(const char *df,int dl,int dc, namespaceSDict = new NamespaceSDict(17); m_innerCompounds = new SDict(17); usingDirList = 0; - usingDeclList = 0; m_allMembersDict = 0; setReference(lref); memberGroupSDict = new MemberGroupSDict; @@ -320,7 +319,6 @@ NamespaceDefImpl::~NamespaceDefImpl() delete namespaceSDict; delete m_innerCompounds; delete usingDirList; - delete usingDeclList; delete memberGroupSDict; delete m_allMembersDict; } @@ -1226,16 +1224,9 @@ const NamespaceSDict *NamespaceDefImpl::getUsedNamespaces() const return usingDirList; } -void NamespaceDefImpl::addUsingDeclaration(const Definition *d) +void NamespaceDefImpl::addUsingDeclaration(const ClassDef *cd) { - if (usingDeclList==0) - { - usingDeclList = new SDict(17); - } - if (usingDeclList->find(d->qualifiedName())==0) - { - usingDeclList->append(d->qualifiedName(),d); - } + m_usingDeclList.add(cd->qualifiedName(),cd); } QCString NamespaceDefImpl::getOutputFileBase() const @@ -1243,19 +1234,19 @@ QCString NamespaceDefImpl::getOutputFileBase() const return fileName; } -Definition *NamespaceDefImpl::findInnerCompound(const char *n) const +const Definition *NamespaceDefImpl::findInnerCompound(const char *n) const { if (n==0) return 0; - Definition *d = m_innerCompounds->find(n); + const Definition *d = m_innerCompounds->find(n); if (d==0) { if (usingDirList) { d = usingDirList->find(n); } - if (d==0 && usingDeclList) + if (d==0 && !m_usingDeclList.empty()) { - d = usingDeclList->find(n); + d = m_usingDeclList.find(n); } } return d; @@ -1343,15 +1334,9 @@ void NamespaceDefImpl::combineUsingRelations() } } // add used classes of namespace nd to this namespace - if (nd->getUsedClasses()) + for (const auto &ucd : nd->getUsedClasses()) { - SDict::Iterator cli(*nd->getUsedClasses()); - Definition *ucd; - for (cli.toFirst();(ucd=cli.current());++cli) - { - //printf("Adding class %s to the using list of %s\n",cd->qualifiedName().data(),qualifiedName().data()); - addUsingDeclaration(ucd); - } + addUsingDeclaration(ucd); } } } diff --git a/src/namespacedef.h b/src/namespacedef.h index a35f0b1..a16301a 100644 --- a/src/namespacedef.h +++ b/src/namespacedef.h @@ -1,12 +1,10 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2020 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -23,6 +21,7 @@ #include "sortdict.h" #include "definition.h" #include "filedef.h" +#include "linkedmap.h" class MemberList; class ClassDef; @@ -57,8 +56,8 @@ class NamespaceDef : virtual public Definition virtual int numDocMembers() const = 0; virtual void addUsingDirective(const NamespaceDef *nd) = 0; virtual const NamespaceSDict *getUsedNamespaces() const = 0; - virtual void addUsingDeclaration(const Definition *def) = 0; - virtual const SDict *getUsedClasses() const = 0; + virtual void addUsingDeclaration(const ClassDef *cd) = 0; + virtual LinkedRefMap getUsedClasses() const = 0; virtual void combineUsingRelations() = 0; virtual QCString displayName(bool=TRUE) const = 0; virtual QCString localName() const = 0; @@ -77,7 +76,7 @@ class NamespaceDef : virtual public Definition virtual void findSectionsInDocumentation() = 0; virtual void sortMemberLists() = 0; - virtual Definition *findInnerCompound(const char *name) const = 0; + virtual const Definition *findInnerCompound(const char *name) const = 0; virtual void addInnerCompound(const Definition *d) = 0; virtual void addListReferences() = 0; virtual void setFileName(const QCString &fn) = 0; @@ -138,7 +137,7 @@ class NamespaceList : public QList class NamespaceListIterator : public QListIterator { public: - NamespaceListIterator(const NamespaceList &l) : + NamespaceListIterator(const NamespaceList &l) : QListIterator(l) {} }; diff --git a/src/symbolresolver.cpp b/src/symbolresolver.cpp index 1c6baf4..bdc2862 100644 --- a/src/symbolresolver.cpp +++ b/src/symbolresolver.cpp @@ -143,13 +143,13 @@ struct SymbolResolver::Private const Definition *followPath(const Definition *start,const QCString &path); - const Definition *endOfPathIsUsedClass(const SDict *cl,const QCString &localName); + const Definition *endOfPathIsUsedClass(LinkedRefMap cl,const QCString &localName); bool accessibleViaUsingNamespace(StringUnorderedSet &visited, const NamespaceSDict *nl, const Definition *item, const QCString &explicitScopePart=""); - bool accessibleViaUsingClass(const SDict *cl, + bool accessibleViaUsingClass(const LinkedRefMap &cl, const Definition *item, const QCString &explicitScopePart="" ); @@ -219,8 +219,7 @@ const ClassDef *SymbolResolver::Private::getResolvedClassRec( bool hasUsingStatements = (m_fileScope && ((m_fileScope->getUsedNamespaces() && m_fileScope->getUsedNamespaces()->count()>0) || - (m_fileScope->getUsedClasses() && - m_fileScope->getUsedClasses()->count()>0)) + !m_fileScope->getUsedClasses().empty()) ); //printf("hasUsingStatements=%d\n",hasUsingStatements); // Since it is often the case that the same name is searched in the same @@ -687,19 +686,12 @@ int SymbolResolver::Private::isAccessibleFromWithExpScope( // in A via a using directive. //printf("newScope is a namespace: %s!\n",newScope->name().data()); const NamespaceDef *nscope = dynamic_cast(newScope); - const SDict *cl = nscope->getUsedClasses(); - if (cl) + for (const auto &cd : nscope->getUsedClasses()) { - SDict::Iterator cli(*cl); - const Definition *cd; - for (cli.toFirst();(cd=cli.current());++cli) + //printf("Trying for class %s\n",cd->name().data()); + if (cd==item) { - //printf("Trying for class %s\n",cd->name().data()); - if (cd==item) - { - //printf("> class is used in this scope\n"); - goto done; - } + goto done; } } const NamespaceSDict *nl = nscope->getUsedNamespaces(); @@ -830,18 +822,13 @@ const Definition *SymbolResolver::Private::followPath(const Definition *start,co return current; // path could be followed } -const Definition *SymbolResolver::Private::endOfPathIsUsedClass(const SDict *cl,const QCString &localName) +const Definition *SymbolResolver::Private::endOfPathIsUsedClass(LinkedRefMap cl,const QCString &localName) { - if (cl) + for (const auto &cd : cl) { - SDict::Iterator cli(*cl); - Definition *cd; - for (cli.toFirst();(cd=cli.current());++cli) + if (cd->localName()==localName) { - if (cd->localName()==localName) - { - return cd; - } + return cd; } } return 0; @@ -890,25 +877,18 @@ bool SymbolResolver::Private::accessibleViaUsingNamespace(StringUnorderedSet &vi } -bool SymbolResolver::Private::accessibleViaUsingClass(const SDict *cl, +bool SymbolResolver::Private::accessibleViaUsingClass(const LinkedRefMap &cl, const Definition *item, const QCString &explicitScopePart) { - //printf("accessibleViaUsingClass(%p)\n",cl); - if (cl) // see if the class was imported via a using statement + for (const auto &ucd : cl) { - SDict::Iterator cli(*cl); - Definition *ucd; - bool explicitScopePartEmpty = explicitScopePart.isEmpty(); - for (cli.toFirst();(ucd=cli.current());++cli) - { - //printf("Trying via used class %s\n",ucd->name().data()); - const Definition *sc = explicitScopePartEmpty ? ucd : followPath(ucd,explicitScopePart); - if (sc && sc==item) return TRUE; - //printf("Try via used class done\n"); - } + //printf("Trying via used class %s\n",ucd->name().data()); + const Definition *sc = explicitScopePart.isEmpty() ? ucd : followPath(ucd,explicitScopePart); + if (sc && sc==item) return true; + //printf("Try via used class done\n"); } - return FALSE; + return false; } int SymbolResolver::Private::isAccessibleFrom(AccessStack &accessStack, @@ -952,8 +932,7 @@ int SymbolResolver::Private::isAccessibleFrom(AccessStack &accessStack, { if (m_fileScope) { - SDict *cl = m_fileScope->getUsedClasses(); - if (accessibleViaUsingClass(cl,item)) + if (accessibleViaUsingClass(m_fileScope->getUsedClasses(),item)) { //printf("> found via used class\n"); goto done; @@ -976,8 +955,7 @@ int SymbolResolver::Private::isAccessibleFrom(AccessStack &accessStack, { const NamespaceDef *nscope = dynamic_cast(scope); //printf(" %s is namespace with %d used classes\n",nscope->name().data(),nscope->getUsedClasses()); - const SDict *cl = nscope->getUsedClasses(); - if (accessibleViaUsingClass(cl,item)) + if (accessibleViaUsingClass(nscope->getUsedClasses(),item)) { //printf("> found via used class\n"); goto done; -- cgit v0.12