Skip to content

Commit 8bfcbec

Browse files
committed
issue #10588 C++: Inherited virtual functions duplicated when using Base::func
1 parent 96b5b76 commit 8bfcbec

File tree

3 files changed

+77
-46
lines changed

3 files changed

+77
-46
lines changed

src/classdef.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/******************************************************************************
22
*
3-
*
4-
*
5-
* Copyright (C) 1997-2015 by Dimitri van Heesch.
3+
* Copyright (C) 1997-2024 by Dimitri van Heesch.
64
*
75
* Permission to use, copy, modify, and distribute this software and its
86
* documentation under the terms of the GNU General Public License is hereby
@@ -272,6 +270,7 @@ class ClassDefImpl : public DefinitionMixin<ClassDefMutable>
272270
bool hasNonReferenceSuperClass() const override;
273271
QCString requiresClause() const override;
274272
StringVector getQualifiers() const override;
273+
bool containsOverload(const MemberDef *md) const override;
275274
ClassDef *insertTemplateInstance(const QCString &fileName,int startLine,int startColumn,
276275
const QCString &templSpec,bool &freshInstance) const override;
277276

@@ -578,6 +577,8 @@ class ClassDefAliasImpl : public DefinitionAliasMixin<ClassDef>
578577
{ return getCdAlias()->requiresClause(); }
579578
StringVector getQualifiers() const override
580579
{ return getCdAlias()->getQualifiers(); }
580+
bool containsOverload(const MemberDef *md) const override
581+
{ return getCdAlias()->containsOverload(md); }
581582

582583
int countMembersIncludingGrouped(MemberListType lt,const ClassDef *inheritedFrom,bool additional) const override
583584
{ return getCdAlias()->countMembersIncludingGrouped(lt,inheritedFrom,additional); }
@@ -4971,6 +4972,30 @@ StringVector ClassDefImpl::getQualifiers() const
49714972
return m_impl->qualifiers;
49724973
}
49734974

4975+
bool ClassDefImpl::containsOverload(const MemberDef *md) const
4976+
{
4977+
const auto &mni = m_impl->allMemberNameInfoLinkedMap.find(md->name());
4978+
if (mni)
4979+
{
4980+
for (const auto &mi : *mni)
4981+
{
4982+
const MemberDef *classMd = mi->memberDef();
4983+
ArgumentList &classAl = const_cast<ArgumentList&>(classMd->argumentList());
4984+
ArgumentList &al = const_cast<ArgumentList&>(md->argumentList());
4985+
bool found = matchArguments2(
4986+
classMd->getOuterScope(),classMd->getFileDef(),&classAl,
4987+
md->getOuterScope(),md->getFileDef(),&al,
4988+
true,getLanguage()
4989+
);
4990+
if (found)
4991+
{
4992+
return true;
4993+
}
4994+
}
4995+
}
4996+
return false;
4997+
}
4998+
49744999
bool ClassDefImpl::isExtension() const
49755000
{
49765001
QCString n = name();

src/classdef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ class ClassDef : public Definition
361361
virtual QCString requiresClause() const = 0;
362362
virtual StringVector getQualifiers() const = 0;
363363

364+
virtual bool containsOverload(const MemberDef *md) const = 0;
365+
364366
//-----------------------------------------------------------------------------------
365367
// --- count members ----
366368
//-----------------------------------------------------------------------------------

src/doxygen.cpp

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ static void findUsingDeclImports(const Entry *root)
20582058
root->parent()->section.isCompound() // in a class/struct member
20592059
)
20602060
{
2061-
AUTO_TRACE("Found using declaration '{}' inside section {:#10x}", root->name, root->parent()->section);
2061+
AUTO_TRACE("Found using declaration '{}' inside section {}", root->name, root->parent()->section);
20622062
QCString fullName=removeRedundantWhiteSpace(root->parent()->name);
20632063
fullName=stripAnonymousNamespaceScope(fullName);
20642064
fullName=stripTemplateSpecifiersFromScope(fullName);
@@ -2093,49 +2093,53 @@ static void findUsingDeclImports(const Entry *root)
20932093
}
20942094
const ArgumentList &templAl = md->templateArguments();
20952095
const ArgumentList &al = md->argumentList();
2096-
auto newMd = createMemberDef(
2097-
fileName,root->startLine,root->startColumn,
2098-
md->typeString(),memName,md->argsString(),
2099-
md->excpString(),root->protection,root->virt,
2100-
md->isStatic(),Relationship::Member,md->memberType(),
2101-
templAl,al,root->metaData
2102-
);
2103-
auto newMmd = toMemberDefMutable(newMd.get());
2104-
newMmd->setMemberClass(cd);
2105-
cd->insertMember(newMd.get());
2106-
if (!root->doc.isEmpty() || !root->brief.isEmpty())
2107-
{
2108-
newMmd->setDocumentation(root->doc,root->docFile,root->docLine);
2109-
newMmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2110-
newMmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
2111-
}
2112-
else
2096+
2097+
if (!cd->containsOverload(md))
21132098
{
2114-
newMmd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
2115-
newMmd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
2116-
newMmd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
2099+
auto newMd = createMemberDef(
2100+
fileName,root->startLine,root->startColumn,
2101+
md->typeString(),memName,md->argsString(),
2102+
md->excpString(),root->protection,root->virt,
2103+
md->isStatic(),Relationship::Member,md->memberType(),
2104+
templAl,al,root->metaData
2105+
);
2106+
auto newMmd = toMemberDefMutable(newMd.get());
2107+
newMmd->setMemberClass(cd);
2108+
cd->insertMember(newMd.get());
2109+
if (!root->doc.isEmpty() || !root->brief.isEmpty())
2110+
{
2111+
newMmd->setDocumentation(root->doc,root->docFile,root->docLine);
2112+
newMmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2113+
newMmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
2114+
}
2115+
else
2116+
{
2117+
newMmd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
2118+
newMmd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
2119+
newMmd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
2120+
}
2121+
newMmd->setDefinition(md->definition());
2122+
newMmd->enableCallGraph(root->callGraph);
2123+
newMmd->enableCallerGraph(root->callerGraph);
2124+
newMmd->enableReferencedByRelation(root->referencedByRelation);
2125+
newMmd->enableReferencesRelation(root->referencesRelation);
2126+
newMmd->enableInlineSource(root->inlineSource);
2127+
newMmd->addQualifiers(root->qualifiers);
2128+
newMmd->setBitfields(md->bitfieldString());
2129+
newMmd->addSectionsToDefinition(root->anchors);
2130+
newMmd->setBodySegment(md->getDefLine(),md->getStartBodyLine(),md->getEndBodyLine());
2131+
newMmd->setBodyDef(md->getBodyDef());
2132+
newMmd->setInitializer(md->initializer());
2133+
newMmd->setRequiresClause(md->requiresClause());
2134+
newMmd->setMaxInitLines(md->initializerLines());
2135+
newMmd->setMemberGroupId(root->mGrpId);
2136+
newMmd->setMemberSpecifiers(md->getMemberSpecifiers());
2137+
newMmd->setVhdlSpecifiers(md->getVhdlSpecifiers());
2138+
newMmd->setLanguage(root->lang);
2139+
newMmd->setId(root->id);
2140+
MemberName *mn = Doxygen::memberNameLinkedMap->add(memName);
2141+
mn->push_back(std::move(newMd));
21172142
}
2118-
newMmd->setDefinition(md->definition());
2119-
newMmd->enableCallGraph(root->callGraph);
2120-
newMmd->enableCallerGraph(root->callerGraph);
2121-
newMmd->enableReferencedByRelation(root->referencedByRelation);
2122-
newMmd->enableReferencesRelation(root->referencesRelation);
2123-
newMmd->enableInlineSource(root->inlineSource);
2124-
newMmd->addQualifiers(root->qualifiers);
2125-
newMmd->setBitfields(md->bitfieldString());
2126-
newMmd->addSectionsToDefinition(root->anchors);
2127-
newMmd->setBodySegment(md->getDefLine(),md->getStartBodyLine(),md->getEndBodyLine());
2128-
newMmd->setBodyDef(md->getBodyDef());
2129-
newMmd->setInitializer(md->initializer());
2130-
newMmd->setRequiresClause(md->requiresClause());
2131-
newMmd->setMaxInitLines(md->initializerLines());
2132-
newMmd->setMemberGroupId(root->mGrpId);
2133-
newMmd->setMemberSpecifiers(md->getMemberSpecifiers());
2134-
newMmd->setVhdlSpecifiers(md->getVhdlSpecifiers());
2135-
newMmd->setLanguage(root->lang);
2136-
newMmd->setId(root->id);
2137-
MemberName *mn = Doxygen::memberNameLinkedMap->add(memName);
2138-
mn->push_back(std::move(newMd));
21392143
}
21402144
}
21412145
}
@@ -6813,7 +6817,7 @@ static void findMember(const Entry *root,
68136817
static void filterMemberDocumentation(const Entry *root,const QCString &relates)
68146818
{
68156819
int i=-1,l;
6816-
AUTO_TRACE("root->type='{}' root->inside='{}' root->name='{}' root->args='{}' section={:#x} root->spec={} root->mGrpId={}",
6820+
AUTO_TRACE("root->type='{}' root->inside='{}' root->name='{}' root->args='{}' section={} root->spec={} root->mGrpId={}",
68176821
root->type,root->inside,root->name,root->args,root->section,root->spec,root->mGrpId);
68186822
//printf("root->parent()->name=%s\n",qPrint(root->parent()->name));
68196823
bool isFunc=TRUE;

0 commit comments

Comments
 (0)