diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-08-25 14:12:28 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2019-08-25 14:12:28 (GMT) |
commit | 12d999af7931c96dfb9dc366d785c3981ac244d4 (patch) | |
tree | 6a20c3dc5455dd1fe80017f34dc88f40ab2673ac /src | |
parent | 082e135c2de6a4d84074f006726f4b6ff53b1169 (diff) | |
download | Doxygen-12d999af7931c96dfb9dc366d785c3981ac244d4.zip Doxygen-12d999af7931c96dfb9dc366d785c3981ac244d4.tar.gz Doxygen-12d999af7931c96dfb9dc366d785c3981ac244d4.tar.bz2 |
issue #7216: non-const getGroupDef() called on aliased member
Diffstat (limited to 'src')
-rw-r--r-- | src/classdef.cpp | 2 | ||||
-rw-r--r-- | src/classdef.h | 1 | ||||
-rw-r--r-- | src/context.cpp | 2 | ||||
-rw-r--r-- | src/filedef.cpp | 2 | ||||
-rw-r--r-- | src/memberdef.cpp | 30 | ||||
-rw-r--r-- | src/memberdef.h | 6 | ||||
-rw-r--r-- | src/membergroup.cpp | 31 | ||||
-rw-r--r-- | src/membergroup.h | 2 | ||||
-rw-r--r-- | src/namespacedef.cpp | 171 | ||||
-rw-r--r-- | src/util.cpp | 2 |
10 files changed, 137 insertions, 112 deletions
diff --git a/src/classdef.cpp b/src/classdef.cpp index 856ab05..78284d5 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -4813,7 +4813,7 @@ void ClassDefImpl::addMemberToList(MemberListType lt,MemberDef *md,bool isBrief) ml->append(md); // for members in the declaration lists we set the section, needed for member grouping - if ((ml->listType()&MemberListType_detailedLists)==0) md->setSectionList(this,ml); + if ((ml->listType()&MemberListType_detailedLists)==0) md->setSectionList(ml); } void ClassDefImpl::sortMemberLists() diff --git a/src/classdef.h b/src/classdef.h index a442ace..e64f0eb 100644 --- a/src/classdef.h +++ b/src/classdef.h @@ -72,7 +72,6 @@ class ClassDef : virtual public Definition virtual ~ClassDef() {} - virtual ClassDef *resolveAlias() = 0; //----------------------------------------------------------------------------------- // --- getters diff --git a/src/context.cpp b/src/context.cpp index 49c9afa..1933d43 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -9302,7 +9302,7 @@ class InheritedMemberInfoListContext::Private : public GenericNodeListContext MemberDef *md; for (li.toFirst();(md=li.current());++li) { - if (lt==md->getSectionList(mg->parent())->listType() && + if (lt==md->getSectionList()->listType() && !md->isReimplementedBy(inheritedFrom) && md->isBriefSectionVisible()) { diff --git a/src/filedef.cpp b/src/filedef.cpp index 9a82c8a..6c5ee58 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -2098,7 +2098,7 @@ void FileDefImpl::addMemberToList(MemberListType lt,MemberDef *md) { ml->setInFile(TRUE); } - if (ml->listType()&MemberListType_declarationLists) md->setSectionList(this,ml); + if (ml->listType()&MemberListType_declarationLists) md->setSectionList(ml); } void FileDefImpl::sortMemberLists() diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 9d6ac51..4fb0797 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -59,7 +59,7 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual ~MemberDefImpl(); virtual DefType definitionType() const { return TypeMember; } - virtual MemberDef *resolveAlias() { return this; } + virtual MemberDef *resolveAlias() { return this; } virtual const MemberDef *resolveAlias() const { return this; } virtual MemberDef *deepCopy() const; virtual void moveTo(Definition *); @@ -76,7 +76,7 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual const QCString &initializer() const; virtual int initializerLines() const; virtual uint64 getMemberSpecifiers() const; - virtual const MemberList *getSectionList(const Definition *d) const; + virtual const MemberList *getSectionList() const; virtual QCString displayDefinition() const; virtual const ClassDef *getClassDef() const; virtual ClassDef *getClassDef(); @@ -252,7 +252,7 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual void setBitfields(const char *s); virtual void setMaxInitLines(int lines); virtual void setMemberClass(ClassDef *cd); - virtual void setSectionList(Definition *d,MemberList *sl); + virtual void setSectionList(MemberList *sl); virtual void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri, const QCString &fileName,int startLine,bool hasDocs, MemberDef *member=0); @@ -380,12 +380,12 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef { public: MemberDefAliasImpl(const Definition *newScope,const MemberDef *md) - : DefinitionAliasImpl(newScope,md) {} + : DefinitionAliasImpl(newScope,md), m_memberGroup(0) {} virtual ~MemberDefAliasImpl() {} virtual DefType definitionType() const { return TypeMember; } - const MemberDef *getMdAlias() const { return dynamic_cast<const MemberDef*>(getAlias()); } - virtual MemberDef *resolveAlias() { return const_cast<MemberDef*>(getMdAlias()); } + const MemberDef *getMdAlias() const { return dynamic_cast<const MemberDef*>(getAlias()); } + virtual MemberDef *resolveAlias() { return const_cast<MemberDef*>(getMdAlias()); } virtual const MemberDef *resolveAlias() const { return getMdAlias(); } virtual MemberDef *deepCopy() const { @@ -419,8 +419,8 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef { return getMdAlias()->initializerLines(); } virtual uint64 getMemberSpecifiers() const { return getMdAlias()->getMemberSpecifiers(); } - virtual const MemberList *getSectionList(const Definition *d) const - { return getMdAlias()->getSectionList(d); } + virtual const MemberList *getSectionList() const + { return getMdAlias()->getSectionList(); } virtual QCString displayDefinition() const { return getMdAlias()->displayDefinition(); } virtual const ClassDef *getClassDef() const @@ -672,7 +672,7 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual int getMemberGroupId() const { return getMdAlias()->getMemberGroupId(); } virtual MemberGroup *getMemberGroup() const - { return getMdAlias()->getMemberGroup(); } + { return m_memberGroup; } virtual bool fromAnonymousScope() const { return getMdAlias()->fromAnonymousScope(); } virtual bool anonymousDeclShown() const @@ -762,7 +762,7 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual void setBitfields(const char *s) {} virtual void setMaxInitLines(int lines) {} virtual void setMemberClass(ClassDef *cd) {} - virtual void setSectionList(Definition *d,MemberList *sl) {} + virtual void setSectionList(MemberList *sl) {} virtual void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri, const QCString &fileName,int startLine,bool hasDocs, MemberDef *member=0) {} @@ -793,7 +793,7 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual void setType(const char *t) {} virtual void setAccessorType(ClassDef *cd,const char *t) {} virtual void setNamespace(NamespaceDef *nd) {} - virtual void setMemberGroup(MemberGroup *grp) {} + virtual void setMemberGroup(MemberGroup *grp) { m_memberGroup = grp; } virtual void setMemberGroupId(int id) {} virtual void makeImplementationDetail() {} virtual void setFromAnonymousScope(bool b) const {} @@ -849,6 +849,8 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual void warnIfUndocumented() const {} virtual void warnIfUndocumentedParams() const {} virtual void detectUndocumentedParams(bool hasParamCommand,bool hasReturnCommand) const {} + private: + MemberGroup *m_memberGroup; // group's member definition }; @@ -4536,16 +4538,18 @@ void MemberDefImpl::addListReference(Definition *) } } -const MemberList *MemberDefImpl::getSectionList(const Definition *d) const +const MemberList *MemberDefImpl::getSectionList() const { + const Definition *d= resolveAlias()->getOuterScope(); char key[20]; sprintf(key,"%p",d); return (d!=0 && m_impl->classSectionSDict) ? m_impl->classSectionSDict->find(key) : 0; } -void MemberDefImpl::setSectionList(Definition *d, MemberList *sl) +void MemberDefImpl::setSectionList(MemberList *sl) { //printf("MemberDefImpl::setSectionList(%p,%p) name=%s\n",d,sl,name().data()); + const Definition *d= resolveAlias()->getOuterScope(); char key[20]; sprintf(key,"%p",d); if (m_impl->classSectionSDict==0) diff --git a/src/memberdef.h b/src/memberdef.h index c81af80..b200833 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -50,7 +50,7 @@ class MemberDef : virtual public Definition virtual MemberDef *resolveAlias() = 0; virtual const MemberDef *resolveAlias() const = 0; - + //----------------------------------------------------------------------------------- // ---- getters ----- //----------------------------------------------------------------------------------- @@ -70,7 +70,7 @@ class MemberDef : virtual public Definition virtual const QCString &initializer() const = 0; virtual int initializerLines() const = 0; virtual uint64 getMemberSpecifiers() const = 0; - virtual const MemberList *getSectionList(const Definition *d) const = 0; + virtual const MemberList *getSectionList() const = 0; virtual QCString displayDefinition() const = 0; // scope query members @@ -294,7 +294,7 @@ class MemberDef : virtual public Definition virtual void setBitfields(const char *s) = 0; virtual void setMaxInitLines(int lines) = 0; virtual void setMemberClass(ClassDef *cd) = 0; - virtual void setSectionList(Definition *d,MemberList *sl) = 0; + virtual void setSectionList(MemberList *sl) = 0; virtual void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri, const QCString &fileName,int startLine,bool hasDocs, MemberDef *member=0) = 0; diff --git a/src/membergroup.cpp b/src/membergroup.cpp index a5852e4..3f0b144 100644 --- a/src/membergroup.cpp +++ b/src/membergroup.cpp @@ -40,8 +40,7 @@ MemberGroup::MemberGroup() { } -MemberGroup::MemberGroup(const Definition *parent, - int id,const char *hdr,const char *d,const char *docFile,int docLine) +MemberGroup::MemberGroup(int id,const char *hdr,const char *d,const char *docFile,int docLine) { static bool sortBriefDocs = Config_getBool(SORT_BRIEF_DOCS); @@ -55,7 +54,6 @@ MemberGroup::MemberGroup(const Definition *parent, inDeclSection = 0; m_numDecMembers = -1; m_numDocMembers = -1; - m_parent = parent; m_docFile = docFile; m_docLine = docLine; m_xrefListItems = 0; @@ -69,33 +67,32 @@ MemberGroup::~MemberGroup() void MemberGroup::insertMember(MemberDef *md) { - //printf("MemberGroup::insertMember m_parent=%s memberList=%p count=%d" + //printf("MemberGroup::insertMember memberList=%p count=%d" // " member section list: %p: md=%p:%s\n", - // m_parent ? m_parent->name().data() : "<null>", - // memberList->first() ? memberList->first()->getSectionList(m_parent) : 0, + // memberList->first() ? memberList->first()->getSectionList() : 0, // memberList->count(), - // md->getSectionList(m_parent), + // md->getSectionList(), // md,md->name().data()); MemberDef *firstMd = memberList->getFirst(); - if (inSameSection && firstMd && - firstMd->getSectionList(m_parent)!=md->getSectionList(m_parent)) + if (inSameSection && firstMd && firstMd->getSectionList()!=md->getSectionList()) { inSameSection=FALSE; } else if (inDeclSection==0) { - inDeclSection = const_cast<MemberList*>(md->getSectionList(m_parent)); + inDeclSection = const_cast<MemberList*>(md->getSectionList()); //printf("inDeclSection=%p type=%d\n",inDeclSection,inDeclSection->listType()); } memberList->append(md); // copy the group of the first member in the memberGroup GroupDef *gd; - if (firstMd && (gd=const_cast<GroupDef*>(firstMd->getGroupDef()))) + if (firstMd && !firstMd->isAlias() && (gd=const_cast<GroupDef*>(firstMd->getGroupDef()))) { - md->setGroupDef(gd, firstMd->getGroupPri(), - firstMd->getGroupFileName(), firstMd->getGroupStartLine(), + md->setGroupDef(gd, firstMd->getGroupPri(), + firstMd->getGroupFileName(), + firstMd->getGroupStartLine(), firstMd->getGroupHasDocs()); gd->insertMember(md); } @@ -152,8 +149,8 @@ void MemberGroup::addGroupedInheritedMembers(OutputList &ol,const ClassDef *cd, MemberDef *md; for (li.toFirst();(md=li.current());++li) { - //printf("matching %d == %d\n",lt,md->getSectionList(m_parent)->listType()); - const MemberList *ml = md->getSectionList(m_parent); + //printf("matching %d == %d\n",lt,md->getSectionList()->listType()); + const MemberList *ml = md->getSectionList(); if (ml && lt==ml->listType()) { MemberList ml(lt); @@ -172,8 +169,8 @@ int MemberGroup::countGroupedInheritedMembers(MemberListType lt) MemberDef *md; for (li.toFirst();(md=li.current());++li) { - //printf("matching %d == %d\n",lt,md->getSectionList(m_parent)->listType()); - const MemberList *ml = md->getSectionList(m_parent); + //printf("matching %d == %d\n",lt,md->getSectionList()->listType()); + const MemberList *ml = md->getSectionList(); if (ml && lt==ml->listType()) { count++; diff --git a/src/membergroup.h b/src/membergroup.h index c07d025..248c8cb 100644 --- a/src/membergroup.h +++ b/src/membergroup.h @@ -41,7 +41,7 @@ class MemberGroup { public: MemberGroup(); - MemberGroup(const Definition *parent,int id,const char *header, + MemberGroup(int id,const char *header, const char *docs,const char *docFile,int docLine); ~MemberGroup(); QCString header() const { return grpHeader; } diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 38e5c04..c0ae05d 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -467,92 +467,119 @@ void NamespaceDefImpl::addMembersToMemberGroup() void NamespaceDefImpl::insertMember(MemberDef *md) { - //printf("%s::insertMember(%s)\n",qPrint(name()),qPrint(md->name())); + //printf("%s::insertMember(%s) isInline=%d hasDocs=%d\n",qPrint(name()),qPrint(md->name()), + // isInline(),hasDocumentation()); if (md->isHidden()) return; - MemberList *allMemberList = getMemberList(MemberListType_allMembersList); - if (allMemberList==0) - { - allMemberList = new MemberList(MemberListType_allMembersList); - m_memberLists.append(allMemberList); - } - allMemberList->append(md); - if (m_allMembersDict==0) - { - m_allMembersDict = new MemberSDict; - } - //printf("%s::m_allMembersDict->append(%s)\n",name().data(),md->localName().data()); - m_allMembersDict->append(md->localName(),md); - //::addNamespaceMemberNameToIndex(md); - //static bool sortBriefDocs=Config_getBool(SORT_BRIEF_DOCS); - switch(md->memberType()) - { - case MemberType_Variable: - addMemberToList(MemberListType_decVarMembers,md); - addMemberToList(MemberListType_docVarMembers,md); - break; - case MemberType_Function: - addMemberToList(MemberListType_decFuncMembers,md); - addMemberToList(MemberListType_docFuncMembers,md); - break; - case MemberType_Typedef: - addMemberToList(MemberListType_decTypedefMembers,md); - addMemberToList(MemberListType_docTypedefMembers,md); - break; - case MemberType_Sequence: - addMemberToList(MemberListType_decSequenceMembers,md); - addMemberToList(MemberListType_docSequenceMembers,md); - break; - case MemberType_Dictionary: - addMemberToList(MemberListType_decDictionaryMembers,md); - addMemberToList(MemberListType_docDictionaryMembers,md); - break; - case MemberType_Enumeration: - addMemberToList(MemberListType_decEnumMembers,md); - addMemberToList(MemberListType_docEnumMembers,md); - break; - case MemberType_EnumValue: - break; - case MemberType_Define: - addMemberToList(MemberListType_decDefineMembers,md); - addMemberToList(MemberListType_docDefineMembers,md); - break; - default: - err("NamespaceDefImpl::insertMembers(): " - "member '%s' with class scope '%s' inserted in namespace scope '%s'!\n", - md->name().data(), - md->getClassDef() ? md->getClassDef()->name().data() : "", - name().data()); - } - // if this is an inline namespace, then insert an alias of this member in the outer scope. - if (isInline()) + + // if this is an inline namespace that is not documented, then insert the + // member in the parent scope instead + if (isInline() && !hasDocumentation()) { Definition *outerScope = getOuterScope(); if (outerScope) { - MemberDef *aliasMd = 0; if (outerScope->definitionType()==Definition::TypeNamespace) { - aliasMd = createMemberDefAlias(outerScope,md); - dynamic_cast<NamespaceDef*>(outerScope)->insertMember(aliasMd); + NamespaceDef *nd = dynamic_cast<NamespaceDef*>(outerScope); + nd->insertMember(md); + md->setNamespace(nd); } else if (outerScope->definitionType()==Definition::TypeFile) { - aliasMd = createMemberDefAlias(outerScope,md); - dynamic_cast<FileDef*>(outerScope)->insertMember(aliasMd); + FileDef *fd = dynamic_cast<FileDef*>(outerScope); + fd->insertMember(md); + md->setFileDef(fd); + md->setOuterScope(fd); } - if (aliasMd) + } + } + else // member is a non-inline namespace or a documented inline namespace + { + MemberList *allMemberList = getMemberList(MemberListType_allMembersList); + if (allMemberList==0) + { + allMemberList = new MemberList(MemberListType_allMembersList); + m_memberLists.append(allMemberList); + } + allMemberList->append(md); + if (m_allMembersDict==0) + { + m_allMembersDict = new MemberSDict; + } + //printf("%s::m_allMembersDict->append(%s)\n",name().data(),md->localName().data()); + m_allMembersDict->append(md->localName(),md); + //::addNamespaceMemberNameToIndex(md); + //static bool sortBriefDocs=Config_getBool(SORT_BRIEF_DOCS); + switch(md->memberType()) + { + case MemberType_Variable: + addMemberToList(MemberListType_decVarMembers,md); + addMemberToList(MemberListType_docVarMembers,md); + break; + case MemberType_Function: + addMemberToList(MemberListType_decFuncMembers,md); + addMemberToList(MemberListType_docFuncMembers,md); + break; + case MemberType_Typedef: + addMemberToList(MemberListType_decTypedefMembers,md); + addMemberToList(MemberListType_docTypedefMembers,md); + break; + case MemberType_Sequence: + addMemberToList(MemberListType_decSequenceMembers,md); + addMemberToList(MemberListType_docSequenceMembers,md); + break; + case MemberType_Dictionary: + addMemberToList(MemberListType_decDictionaryMembers,md); + addMemberToList(MemberListType_docDictionaryMembers,md); + break; + case MemberType_Enumeration: + addMemberToList(MemberListType_decEnumMembers,md); + addMemberToList(MemberListType_docEnumMembers,md); + break; + case MemberType_EnumValue: + break; + case MemberType_Define: + addMemberToList(MemberListType_decDefineMembers,md); + addMemberToList(MemberListType_docDefineMembers,md); + break; + default: + err("NamespaceDefImpl::insertMembers(): " + "member '%s' with class scope '%s' inserted in namespace scope '%s'!\n", + md->name().data(), + md->getClassDef() ? md->getClassDef()->name().data() : "", + name().data()); + } + // if this is an inline namespace, then insert an alias of this member in the outer scope. + if (isInline()) + { + Definition *outerScope = getOuterScope(); + if (outerScope) { - MemberName *mn; - QCString name = md->name(); - if ((mn=Doxygen::functionNameSDict->find(name))) + MemberDef *aliasMd = 0; + if (outerScope->definitionType()==Definition::TypeNamespace) { - mn->append(aliasMd); + aliasMd = createMemberDefAlias(outerScope,md); + dynamic_cast<NamespaceDef*>(outerScope)->insertMember(aliasMd); } - else + else if (outerScope->definitionType()==Definition::TypeFile) { - mn = new MemberName(name); - mn->append(aliasMd); - Doxygen::functionNameSDict->append(name,mn); + aliasMd = createMemberDefAlias(outerScope,md); + dynamic_cast<FileDef*>(outerScope)->insertMember(aliasMd); + } + if (aliasMd) + { + MemberName *mn; + QCString name = md->name(); + if ((mn=Doxygen::functionNameSDict->find(name))) + { + mn->append(aliasMd); + } + else + { + mn = new MemberName(name); + mn->append(aliasMd); + Doxygen::functionNameSDict->append(name,mn); + } } } } @@ -1460,7 +1487,7 @@ void NamespaceDefImpl::addMemberToList(MemberListType lt,MemberDef *md) if (ml->listType()&MemberListType_declarationLists) { - md->setSectionList(this,ml); + md->setSectionList(ml); } } diff --git a/src/util.cpp b/src/util.cpp index f5e43a4..3e49384 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -6276,7 +6276,6 @@ void addMembersToMemberGroup(MemberList *ml, if (mg==0) { mg = new MemberGroup( - context, groupId, info->header, info->doc, @@ -6309,7 +6308,6 @@ void addMembersToMemberGroup(MemberList *ml, if (mg==0) { mg = new MemberGroup( - context, groupId, info->header, info->doc, |