From 8578e6bead66cae44b61214b3a43f776ed008362 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Mon, 24 Aug 2020 11:05:08 +0200 Subject: issue #7973: C++ grouped functions in namespace have disapeard - reverted some of the change that introduced the problem - fixed the original problem (#7216) in a different way --- src/classdef.cpp | 2 +- src/code.l | 2 +- src/context.cpp | 2 +- src/doxygen.cpp | 11 ++++---- src/filedef.cpp | 8 +----- src/memberdef.cpp | 20 +++++++-------- src/memberdef.h | 4 +-- src/membergroup.cpp | 37 +++++++++------------------ src/membergroup.h | 12 ++++----- src/namespacedef.cpp | 2 +- src/util.cpp | 72 ++++++++++++++++++++++++++++++---------------------- 11 files changed, 83 insertions(+), 89 deletions(-) diff --git a/src/classdef.cpp b/src/classdef.cpp index 5dee0dc..c3cd3ee 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -4416,7 +4416,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(ml); + if ((ml->listType()&MemberListType_detailedLists)==0) md->setSectionList(this,ml); } void ClassDefImpl::sortMemberLists() diff --git a/src/code.l b/src/code.l index ddeca01..6627498 100644 --- a/src/code.l +++ b/src/code.l @@ -571,7 +571,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" // absPath = QDir::cleanDirPath(yyextra->sourceFileDef->getPath()+"/"+absPath); //} - FileDef *fd=findFileDef(Doxygen::inputNameLinkedMap,yytext,ambig); + const FileDef *fd=findFileDef(Doxygen::inputNameLinkedMap,yytext,ambig); //printf("looking for include %s -> %s fd=%p\n",yytext,absPath.data(),fd); if (fd && fd->isLinkable()) { diff --git a/src/context.cpp b/src/context.cpp index 2af2c84..29a704a 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -9238,7 +9238,7 @@ class InheritedMemberInfoListContext::Private : public GenericNodeListContext MemberDef *md; for (li.toFirst();(md=li.current());++li) { - if (lt==md->getSectionList()->listType() && + if (lt==md->getSectionList(mg->container())->listType() && !md->isReimplementedBy(inheritedFrom) && md->isBriefSectionVisible()) { diff --git a/src/doxygen.cpp b/src/doxygen.cpp index aa091f9..4b5c267 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -3680,17 +3680,18 @@ static void transferFunctionReferences() { MemberDef *mdef=0,*mdec=0; /* find a matching function declaration and definition for this function */ - for (const auto &md : *mn) + for (const auto &md_p : *mn) { + MemberDef *md = md_p.get(); if (md->isPrototype()) - mdec=md.get(); + mdec=md; else if (md->isVariable() && md->isExternal()) - mdec=md.get(); + mdec=md; if (md->isFunction() && !md->isStatic() && !md->isPrototype()) - mdef=md.get(); + mdef=md; else if (md->isVariable() && !md->isExternal() && !md->isStatic()) - mdef=md.get(); + mdef=md; if (mdef && mdec) break; } diff --git a/src/filedef.cpp b/src/filedef.cpp index 658023b..15fd1e5 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -2050,17 +2050,11 @@ void FileDefImpl::addMemberToList(MemberListType lt,MemberDef *md) ((ml->listType()&MemberListType_declarationLists) && sortBriefDocs) || ((ml->listType()&MemberListType_documentationLists) && sortMemberDocs)); ml->append(md); -#if 0 - if (ml->needsSorting()) - ml->inSort(md); - else - ml->append(md); -#endif if (lt&MemberListType_documentationLists) { ml->setInFile(TRUE); } - if (ml->listType()&MemberListType_declarationLists) md->setSectionList(ml); + if (ml->listType()&MemberListType_declarationLists) md->setSectionList(this,ml); } void FileDefImpl::sortMemberLists() diff --git a/src/memberdef.cpp b/src/memberdef.cpp index bd7cecf..464dbd0 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -75,7 +75,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; + virtual const MemberList *getSectionList(const Definition *) const; virtual QCString displayDefinition() const; virtual const ClassDef *getClassDef() const; virtual ClassDef *getClassDef(); @@ -251,7 +251,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(MemberList *sl); + virtual void setSectionList(const Definition *container,MemberList *sl); virtual void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri, const QCString &fileName,int startLine,bool hasDocs, MemberDef *member=0); @@ -418,8 +418,8 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef { return getMdAlias()->initializerLines(); } virtual uint64 getMemberSpecifiers() const { return getMdAlias()->getMemberSpecifiers(); } - virtual const MemberList *getSectionList() const - { return getMdAlias()->getSectionList(); } + virtual const MemberList *getSectionList(const Definition *container) const + { return getMdAlias()->getSectionList(container); } virtual QCString displayDefinition() const { return getMdAlias()->displayDefinition(); } virtual const ClassDef *getClassDef() const @@ -763,7 +763,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(MemberList *sl) {} + virtual void setSectionList(const Definition *c,MemberList *sl) {} virtual void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri, const QCString &fileName,int startLine,bool hasDocs, MemberDef *member=0) {} @@ -4449,18 +4449,18 @@ void MemberDefImpl::addListReference(Definition *) getOutputFileBase()+"#"+anchor(),memName,memArgs,pd); } -const MemberList *MemberDefImpl::getSectionList() const +const MemberList *MemberDefImpl::getSectionList(const Definition *container) const { - const Definition *d= resolveAlias()->getOuterScope(); + const Definition *d = container; char key[20]; sprintf(key,"%p",(void*)d); return (d!=0 && m_impl->classSectionSDict) ? m_impl->classSectionSDict->find(key) : 0; } -void MemberDefImpl::setSectionList(MemberList *sl) +void MemberDefImpl::setSectionList(const Definition *container,MemberList *sl) { - //printf("MemberDefImpl::setSectionList(%p,%p) name=%s\n",d,sl,name().data()); - const Definition *d= resolveAlias()->getOuterScope(); + //printf("MemberDefImpl::setSectionList(%s,%p) name=%s\n",d->name().data(),sl,name().data()); + const Definition *d= container; char key[20]; sprintf(key,"%p",(void*)d); if (m_impl->classSectionSDict==0) diff --git a/src/memberdef.h b/src/memberdef.h index 4a488d9..f15c31e 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -73,7 +73,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 = 0; + virtual const MemberList *getSectionList(const Definition *container) const = 0; virtual QCString displayDefinition() const = 0; // scope query members @@ -297,7 +297,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(MemberList *sl) = 0; + virtual void setSectionList(const Definition *container,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 523b577..e229835 100644 --- a/src/membergroup.cpp +++ b/src/membergroup.cpp @@ -29,33 +29,14 @@ #include "entry.h" #include "md5.h" -//static QCString idToName(int id) -//{ -// QCString result; -// result.sprintf("mgroup_%d",id); -// return result; -//} - -MemberGroup::MemberGroup() -{ -} - -MemberGroup::MemberGroup(int id,const char *hdr,const char *d,const char *docFile,int docLine) +MemberGroup::MemberGroup(const Definition *container,int id,const char *hdr,const char *d,const char *docFile,int docLine) + : m_container(container), grpId(id), grpHeader(hdr), doc(d), m_docFile(docFile), m_docLine(docLine) { static bool sortBriefDocs = Config_getBool(SORT_BRIEF_DOCS); //printf("New member group id=%d header=%s desc=%s\n",id,hdr,d); memberList = new MemberList(MemberListType_memberGroup); memberList->setNeedsSorting(sortBriefDocs); // detailed sections are already sorted elsewhere. - grpId = id; - grpHeader = hdr; - doc = d; - inSameSection = TRUE; - inDeclSection = 0; - m_numDecMembers = -1; - m_numDocMembers = -1; - m_docFile = docFile; - m_docLine = docLine; //printf("Member group docs='%s'\n",doc.data()); } @@ -74,13 +55,14 @@ void MemberGroup::insertMember(MemberDef *md) // md,md->name().data()); MemberDef *firstMd = memberList->getFirst(); - if (inSameSection && firstMd && firstMd->getSectionList()!=md->getSectionList()) + if (inSameSection && firstMd && + firstMd->getSectionList(m_container)!=md->getSectionList(m_container)) { inSameSection=FALSE; } else if (inDeclSection==0) { - inDeclSection = const_cast(md->getSectionList()); + inDeclSection = const_cast(md->getSectionList(m_container)); //printf("inDeclSection=%p type=%d\n",inDeclSection,inDeclSection->listType()); } memberList->append(md); @@ -125,6 +107,7 @@ void MemberGroup::writePlainDeclarations(OutputList &ol, void MemberGroup::writeDocumentation(OutputList &ol,const char *scopeName, const Definition *container,bool showEnumValues,bool showInline) const { + //printf("MemberGroup::writeDocumentation() %s\n",grpHeader.data()); memberList->writeDocumentation(ol,scopeName,container,0,showEnumValues,showInline); } @@ -149,7 +132,7 @@ void MemberGroup::addGroupedInheritedMembers(OutputList &ol,const ClassDef *cd, for (li.toFirst();(md=li.current());++li) { //printf("matching %d == %d\n",lt,md->getSectionList()->listType()); - const MemberList *ml = md->getSectionList(); + const MemberList *ml = md->getSectionList(m_container); if (ml && lt==ml->listType()) { MemberList mml(lt); @@ -169,7 +152,7 @@ int MemberGroup::countGroupedInheritedMembers(MemberListType lt) for (li.toFirst();(md=li.current());++li) { //printf("matching %d == %d\n",lt,md->getSectionList()->listType()); - const MemberList *ml = md->getSectionList(); + const MemberList *ml = md->getSectionList(m_container); if (ml && lt==ml->listType()) { count++; @@ -202,6 +185,10 @@ void MemberGroup::countDocMembers() memberList->countDocMembers(); } +const Definition *MemberGroup::container() const +{ + return m_container; +} int MemberGroup::countInheritableMembers(const ClassDef *inheritedFrom) const { diff --git a/src/membergroup.h b/src/membergroup.h index 3b8e0fc..c10e421 100644 --- a/src/membergroup.h +++ b/src/membergroup.h @@ -42,8 +42,8 @@ class RefItem; class MemberGroup { public: - MemberGroup(); - MemberGroup(int id,const char *header, + //MemberGroup(); + MemberGroup(const Definition *container,int id,const char *header, const char *docs,const char *docFile,int docLine); ~MemberGroup(); QCString header() const { return grpHeader; } @@ -78,6 +78,7 @@ class MemberGroup int numDecEnumValues() const; int numDocMembers() const; int numDocEnumValues() const; + const Definition *container() const; int countInheritableMembers(const ClassDef *inheritedFrom) const; void setInGroup(bool b); @@ -90,17 +91,16 @@ class MemberGroup int docLine() const { return m_docLine; } private: + const Definition *m_container; MemberList *memberList = 0; // list of all members in the group MemberList *inDeclSection = 0; int grpId = 0; QCString grpHeader; QCString fileName; // base name of the generated file QCString doc; - bool inSameSection = 0; - int m_numDecMembers = 0; - int m_numDocMembers = 0; + bool inSameSection = true; QCString m_docFile; - int m_docLine = 0; + int m_docLine; RefItemVector m_xrefListItems; }; diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 6e0b45c..88eea5d 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -1483,7 +1483,7 @@ void NamespaceDefImpl::addMemberToList(MemberListType lt,MemberDef *md) if (ml->listType()&MemberListType_declarationLists) { - md->setSectionList(ml); + md->setSectionList(this,ml); } } diff --git a/src/util.cpp b/src/util.cpp index fb7a8dc..acc6098 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -377,7 +377,7 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName, return result; } } - MemberDef *md=0; + const MemberDef *md=0; while (mContext && md==0) { // step 1: get the right scope @@ -422,17 +422,18 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName, if (mn) { int minDist=-1; - for (const auto &tmd : *mn) + for (const auto &tmd_p : *mn) { + const MemberDef *tmd = tmd_p.get(); //printf("Found member %s resScope=%s outerScope=%s mContext=%p\n", // tmd->name().data(), resScope->name().data(), // tmd->getOuterScope()->name().data(), mContext); if (tmd->isTypedef() /*&& tmd->getOuterScope()==resScope*/) { - int dist=isAccessibleFrom(resScope,0,tmd.get()); + int dist=isAccessibleFrom(resScope,0,tmd); if (dist!=-1 && (md==0 || distmemberName(),args); - for (const auto &md : *mn) + for (const auto &md_p : *mn) { + const MemberDef *md = md_p.get(); const FileDef *fd=md->getFileDef(); const GroupDef *gd=md->getGroupDef(); //printf(" md->name()='%s' md->args='%s' fd=%p gd=%p current=%p ref=%s\n", @@ -3422,7 +3424,7 @@ static void findMembersWithSpecificName(MemberName *mn, if (match && (forceTagFile==0 || md->getReference()==forceTagFile)) { //printf("Found match!\n"); - members.append(md.get()); + members.append(md); } } } @@ -3544,8 +3546,9 @@ bool getDefs(const QCString &scName, { argList = stringToArgumentList(fcd->getLanguage(),args); } - for (const auto &mmd : *mn) + for (const auto &mmd_p : *mn) { + MemberDef *mmd = mmd_p.get(); if (!mmd->isStrongEnumValue()) { const ArgumentList &mmdAl = mmd->argumentList(); @@ -3564,7 +3567,7 @@ bool getDefs(const QCString &scName, { mdist=m; cd=mcd; - md=mmd.get(); + md=mmd; } } } @@ -3574,8 +3577,9 @@ bool getDefs(const QCString &scName, // no exact match found, but if args="()" an arbitrary member will do { //printf(" >Searching for arbitrary member\n"); - for (const auto &mmd : *mn) + for (const auto &mmd_p : *mn) { + MemberDef *mmd = mmd_p.get(); //if (mmd->isLinkable()) //{ ClassDef *mcd=mmd->getClassDef(); @@ -3588,7 +3592,7 @@ bool getDefs(const QCString &scName, //printf("Class distance %d\n",m); mdist=m; cd=mcd; - md=mmd.get(); + md=mmd; } } //} @@ -3654,7 +3658,7 @@ bool getDefs(const QCString &scName, if (mn && scopeName.isEmpty() && mScope.isEmpty()) // Maybe a related function? { //printf("Global symbol\n"); - MemberDef *fuzzy_mmd = 0; + const MemberDef *fuzzy_mmd = 0; std::unique_ptr argList; bool hasEmptyArgs = args && qstrcmp(args, "()") == 0; @@ -3663,8 +3667,9 @@ bool getDefs(const QCString &scName, argList = stringToArgumentList(SrcLangExt_Cpp, args); } - for (const auto &mmd : *mn) + for (const auto &mmd_p : *mn) { + const MemberDef *mmd = mmd_p.get(); if (!mmd->isLinkable() || (!mmd->isRelated() && !mmd->isForeign()) || !mmd->getClassDef()) { @@ -3673,24 +3678,24 @@ bool getDefs(const QCString &scName, if (!args) { - fuzzy_mmd = mmd.get(); + fuzzy_mmd = mmd; break; } - ArgumentList &mmdAl = mmd->argumentList(); + const ArgumentList &mmdAl = mmd->argumentList(); if (matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),&mmdAl, Doxygen::globalScope,mmd->getFileDef(),argList.get(), checkCV ) ) { - fuzzy_mmd = mmd.get(); + fuzzy_mmd = mmd; break; } if (!fuzzy_mmd && hasEmptyArgs) { - fuzzy_mmd = mmd.get(); + fuzzy_mmd = mmd; } } @@ -3731,8 +3736,9 @@ bool getDefs(const QCString &scName, //printf("Symbol inside existing namespace '%s' count=%d\n", // namespaceName.data(),mn->count()); bool found=FALSE; - for (const auto &mmd : *mn) + for (const auto &mmd_p : *mn) { + const MemberDef *mmd = mmd_p.get(); //printf("mmd->getNamespaceDef()=%p fnd=%p\n", // mmd->getNamespaceDef(),fnd); const MemberDef *emd = mmd->getEnumScope(); @@ -3744,7 +3750,7 @@ bool getDefs(const QCString &scName, { //printf("found it!\n"); nd=fnd; - md=mmd.get(); + md=mmd; found=TRUE; break; } @@ -3770,7 +3776,7 @@ bool getDefs(const QCString &scName, if (match) { nd=fnd; - md=mmd.get(); + md=mmd; found=TRUE; break; } @@ -3780,12 +3786,13 @@ bool getDefs(const QCString &scName, // no exact match found, but if args="()" an arbitrary // member will do { - for (const auto &mmd : *mn) + for (const auto &mmd_p : *mn) { + const MemberDef *mmd = mmd_p.get(); if (mmd->getNamespaceDef()==fnd /*&& mmd->isLinkable() */ ) { nd=fnd; - md=mmd.get(); + md=mmd; found=TRUE; break; } @@ -3810,8 +3817,9 @@ bool getDefs(const QCString &scName, else { //printf("not a namespace\n"); - for (const auto &mmd : *mn) + for (const auto &mmd_p : *mn) { + const MemberDef *mmd = mmd_p.get(); const MemberDef *tmd = mmd->getEnumScope(); //printf("try member %s tmd=%s\n",mmd->name().data(),tmd?tmd->name().data():""); int ni=namespaceName.findRev("::"); @@ -3824,7 +3832,7 @@ bool getDefs(const QCString &scName, namespaceName.length()>0 // enum is part of namespace so this should not be empty ) { - md=mmd.get(); + md=mmd; fd=mmd->getFileDef(); gd=mmd->getGroupDef(); if (gd && gd->isLinkable()) fd=0; else gd=0; @@ -3863,7 +3871,8 @@ bool getDefs(const QCString &scName, //for (mni.toLast();(md=mni.current());--mni) for (auto it = mn->rbegin(); it!=mn->rend(); ++it) { - const auto &mmd = *it; + const auto &mmd_p = *it; + const MemberDef *mmd = mmd_p.get(); //printf("Found member '%s'\n",mmd->name().data()); //printf("member is linkable mmd->name()='%s'\n",mmd->name().data()); fd=mmd->getFileDef(); @@ -3874,7 +3883,7 @@ bool getDefs(const QCString &scName, (tmd && tmd->isStrong()) ) { - members.append(mmd.get()); + members.append(mmd); } } } @@ -4544,13 +4553,14 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const char *n,bool &ambig) int count=0; FileDef *lastMatch=0; QCString pathStripped = stripFromIncludePath(path); - for (const auto &fd : *fn) + for (const auto &fd_p : *fn) { + FileDef *fd = fd_p.get(); QCString fdStripPath = stripFromIncludePath(fd->getPath()); if (path.isEmpty() || fdStripPath.right(pathStripped.length())==pathStripped) { count++; - lastMatch=fd.get(); + lastMatch=fd; } } //printf(">1 ===> add to cache %p\n",fd); @@ -5520,7 +5530,7 @@ void addMembersToMemberGroup(MemberList *ml, const Definition *context) { ASSERT(context!=0); - //printf("addMemberToMemberGroup()\n"); + //printf("addMemberToMemberGroup() context=%s\n",context->name().data()); if (ml==0) return; MemberListIterator mli(*ml); MemberDef *md; @@ -5553,6 +5563,7 @@ void addMembersToMemberGroup(MemberList *ml, if (mg==0) { mg = new MemberGroup( + context, groupId, info->header, info->doc, @@ -5585,6 +5596,7 @@ void addMembersToMemberGroup(MemberList *ml, if (mg==0) { mg = new MemberGroup( + context, groupId, info->header, info->doc, @@ -5594,7 +5606,7 @@ void addMembersToMemberGroup(MemberList *ml, (*ppMemberGroupSDict)->append(groupId,mg); } md = ml->take(index); // remove from member list - mg->insertMember(md); // insert in member group + mg->insertMember(md->resolveAlias()); // insert in member group mg->setRefItems(info->m_sli); md->setMemberGroup(mg); continue; -- cgit v0.12