Doxygen
Loading...
Searching...
No Matches
memberdef.h File Reference
#include <vector>
#include <memory>
#include <optional>
#include <sys/types.h>
#include "types.h"
#include "definition.h"
#include "arguments.h"
#include "classdef.h"
+ Include dependency graph for memberdef.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  MemberDef
 A model of a class/file/namespace member symbol. More...
 
class  MemberDefMutable
 

Functions

MemberDeftoMemberDef (Definition *d)
 
MemberDeftoMemberDef (DefinitionMutable *d)
 
const MemberDeftoMemberDef (const Definition *d)
 
MemberDefMutabletoMemberDefMutable (Definition *d)
 
std::unique_ptr< MemberDefcreateMemberDef (const QCString &defFileName, int defLine, int defColumn, const QCString &type, const QCString &name, const QCString &args, const QCString &excp, Protection prot, Specifier virt, bool stat, Relationship related, MemberType t, const ArgumentList &tal, const ArgumentList &al, const QCString &metaData)
 Factory method to create a new instance of a MemberDef.
 
std::unique_ptr< MemberDefcreateMemberDefAlias (const Definition *newScope, const MemberDef *aliasMd)
 
void combineDeclarationAndDefinition (MemberDefMutable *mdec, MemberDefMutable *mdef)
 
void addDocCrossReference (const MemberDef *src, const MemberDef *dst)
 

Function Documentation

◆ addDocCrossReference()

void addDocCrossReference ( const MemberDef * src,
const MemberDef * dst )

Definition at line 6386 of file memberdef.cpp.

6387{
6388 MemberDefMutable *src = toMemberDefMutable(const_cast<MemberDef*>(s));
6389 MemberDefMutable *dst = toMemberDefMutable(const_cast<MemberDef*>(d));
6390 if (src==nullptr || dst==nullptr) return;
6391 //printf("--> addDocCrossReference src=%s,dst=%s\n",qPrint(src->name()),qPrint(dst->name()));
6392 if (dst->isTypedef() || dst->isEnumerate()) return; // don't add types
6393 if ((dst->hasReferencedByRelation() || dst->hasCallerGraph()) &&
6394 src->isCallable()
6395 )
6396 {
6397 QCString sourceRefName = src->sourceRefName();
6400
6401 // ---- critical section
6402 std::lock_guard<std::mutex> lock(g_docCrossReferenceMutex);
6403 dst->addSourceReferencedBy(src,sourceRefName);
6404 if (mdDef)
6405 {
6406 mdDef->addSourceReferencedBy(src,sourceRefName);
6407 }
6408 if (mdDecl)
6409 {
6410 mdDecl->addSourceReferencedBy(src,sourceRefName);
6411 }
6412 // ---- end critical section
6413 }
6414 if ((src->hasReferencesRelation() || src->hasCallGraph()) &&
6415 src->isCallable()
6416 )
6417 {
6418 QCString sourceRefName = dst->sourceRefName();
6421
6422 // ---- critical section
6423 std::lock_guard<std::mutex> lock(g_docCrossReferenceMutex);
6424 src->addSourceReferences(dst,sourceRefName);
6425 if (mdDef)
6426 {
6427 mdDef->addSourceReferences(dst,sourceRefName);
6428 }
6429 if (mdDecl)
6430 {
6431 mdDecl->addSourceReferences(dst,sourceRefName);
6432 }
6433 // ---- end critical section
6434 }
6435}
virtual void addSourceReferences(MemberDef *d, const QCString &sourceRefName)=0
virtual void addSourceReferencedBy(MemberDef *d, const QCString &sourceRefName)=0
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
virtual MemberDef * memberDefinition() const =0
virtual MemberDef * memberDeclaration() const =0
virtual bool hasReferencesRelation() const =0
virtual bool isTypedef() const =0
virtual bool hasCallGraph() const =0
virtual QCString sourceRefName() const =0
virtual bool hasCallerGraph() const =0
virtual bool isEnumerate() const =0
virtual bool hasReferencedByRelation() const =0
virtual bool isCallable() const =0
This is an alternative implementation of QCString.
Definition qcstring.h:101
static std::mutex g_docCrossReferenceMutex
MemberDefMutable * toMemberDefMutable(Definition *d)

References DefinitionMutable::addSourceReferencedBy(), DefinitionMutable::addSourceReferences(), g_docCrossReferenceMutex, MemberDef::hasCallerGraph(), MemberDef::hasCallGraph(), MemberDef::hasReferencedByRelation(), MemberDef::hasReferencesRelation(), MemberDef::isCallable(), MemberDef::isEnumerate(), MemberDef::isTypedef(), MemberDef::memberDeclaration(), MemberDef::memberDefinition(), MemberDef::sourceRefName(), and toMemberDefMutable().

Referenced by findMemberLink(), generateClassMemberLink(), generateClassOrGlobalLink(), generateClassOrGlobalLink(), getLink(), getLinkInScope(), getLinkInScope(), and writeObjCMethodCall().

◆ combineDeclarationAndDefinition()

void combineDeclarationAndDefinition ( MemberDefMutable * mdec,
MemberDefMutable * mdef )

Definition at line 6152 of file memberdef.cpp.

6153{
6154 AUTO_TRACE("mdec='{}' mdef='{}' mdec.isPrototype={} mdef.isPrototype={}",
6155 mdec->name(), mdef->name(), mdec->isPrototype(), mdef->isPrototype());
6156 if (
6157 (mdef->isFunction() && !mdef->isStatic() && !mdef->isPrototype()) ||
6158 (mdef->isVariable() && !mdef->isExternal() && !mdef->isStatic())
6159 )
6160 {
6161 bool sameNumTemplateArgs = mdef->templateArguments().size()==mdec->templateArguments().size();
6162
6163 ArgumentList &mdefAl = const_cast<ArgumentList&>(mdef->argumentList());
6164 ArgumentList &mdecAl = const_cast<ArgumentList&>(mdec->argumentList());
6165 if (sameNumTemplateArgs &&
6166 matchArguments2(mdef->getOuterScope(),mdef->getFileDef(),&mdefAl,
6167 mdec->getOuterScope(),mdec->getFileDef(),&mdecAl,
6168 TRUE,mdef->getLanguage()
6169 )
6170 ) /* match found */
6171 {
6172 AUTO_TRACE_ADD("combining definition and declaration");
6173
6174 if (Config_getBool(RESOLVE_UNNAMED_PARAMS))
6175 {
6176 mdec->resolveUnnamedParameters(mdef);
6177 }
6178
6179 // first merge argument documentation
6180 transferArgumentDocumentation(mdecAl,mdefAl);
6181
6182 /* copy documentation between function definition and declaration */
6183 if (!mdec->briefDescription().isEmpty())
6184 {
6185 mdef->setBriefDescription(mdec->briefDescription(),mdec->briefFile(),mdec->briefLine());
6186 }
6187 else if (!mdef->briefDescription().isEmpty())
6188 {
6189 mdec->setBriefDescription(mdef->briefDescription(),mdef->briefFile(),mdef->briefLine());
6190 }
6191 if (!mdef->documentation().isEmpty())
6192 {
6193 //printf("transferring docs mdef->mdec (%s->%s)\n",mdef->argsString(),mdec->argsString());
6194 mdec->setDocumentation(mdef->documentation(),mdef->docFile(),mdef->docLine());
6196 if (mdefAl.hasParameters())
6197 {
6198 auto mdefAlComb = stringToArgumentList(mdef->getLanguage(),mdef->argsString());
6199 transferArgumentDocumentation(mdefAl,*mdefAlComb);
6200 mdec->moveArgumentList(std::move(mdefAlComb));
6201 }
6202 }
6203 else if (!mdec->documentation().isEmpty())
6204 {
6205 //printf("transferring docs mdec->mdef (%s->%s)\n",mdec->argsString(),mdef->argsString());
6206 mdef->setDocumentation(mdec->documentation(),mdec->docFile(),mdec->docLine());
6208 if (mdecAl.hasParameters())
6209 {
6210 auto mdecAlComb = stringToArgumentList(mdec->getLanguage(),mdec->argsString());
6211 transferArgumentDocumentation(mdecAl,*mdecAlComb);
6212 mdef->moveDeclArgumentList(std::move(mdecAlComb));
6213 }
6214 }
6215 if (!mdef->inbodyDocumentation().isEmpty())
6216 {
6217 mdec->setInbodyDocumentation(mdef->inbodyDocumentation(),mdef->inbodyFile(),mdef->inbodyLine());
6218 }
6219 else if (!mdec->inbodyDocumentation().isEmpty())
6220 {
6221 mdef->setInbodyDocumentation(mdec->inbodyDocumentation(),mdec->inbodyFile(),mdec->inbodyLine());
6222 }
6223 if (mdec->getStartBodyLine()!=-1 && mdef->getStartBodyLine()==-1)
6224 {
6225 //printf("body mdec->mdef %d-%d\n",mdec->getStartBodyLine(),mdef->getEndBodyLine());
6226 mdef->setBodySegment(mdec->getDefLine(),mdec->getStartBodyLine(),mdec->getEndBodyLine());
6227 mdef->setBodyDef(mdec->getBodyDef());
6228 //mdef->setBodyMember(mdec);
6229 }
6230 else if (mdef->getStartBodyLine()!=-1 && mdec->getStartBodyLine()==-1)
6231 {
6232 //printf("body mdef->mdec %d-%d\n",mdef->getStartBodyLine(),mdec->getEndBodyLine());
6233 mdec->setBodySegment(mdef->getDefLine(),mdef->getStartBodyLine(),mdef->getEndBodyLine());
6234 mdec->setBodyDef(mdef->getBodyDef());
6235 //mdec->setBodyMember(mdef);
6236 }
6239
6240 // copy group info.
6241 if (mdec->getGroupDef()==nullptr && mdef->getGroupDef()!=nullptr)
6242 {
6243 mdec->setGroupDef(mdef->getGroupDef(),
6244 mdef->getGroupPri(),
6245 mdef->docFile(),
6246 mdef->docLine(),
6247 mdef->hasDocumentation(),
6248 mdef
6249 );
6250 }
6251 else if (mdef->getGroupDef()==nullptr && mdec->getGroupDef()!=nullptr)
6252 {
6253 mdef->setGroupDef(mdec->getGroupDef(),
6254 mdec->getGroupPri(),
6255 mdec->docFile(),
6256 mdec->docLine(),
6257 mdec->hasDocumentation(),
6258 mdec
6259 );
6260 }
6261
6262
6263 mdec->mergeRefItems(mdef);
6264 mdef->mergeRefItems(mdec);
6265
6266 mdef->setMemberDeclaration(mdec);
6267 mdec->setMemberDefinition(mdef);
6268
6269 mergeMemberOverrideOptions(mdec,mdef);
6270
6271 mdef->addQualifiers(mdec->getQualifiers());
6272 mdec->addQualifiers(mdef->getQualifiers());
6273 }
6274 }
6275}
This class represents an function or template argument list.
Definition arguments.h:60
bool hasParameters() const
Definition arguments.h:69
size_t size() const
Definition arguments.h:93
virtual QCString docFile() const =0
virtual int getEndBodyLine() const =0
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
virtual int docLine() const =0
virtual int getDefLine() const =0
virtual int inbodyLine() const =0
virtual const FileDef * getBodyDef() const =0
virtual int briefLine() const =0
virtual bool hasDocumentation() const =0
virtual QCString briefDescription(bool abbreviate=FALSE) const =0
virtual QCString documentation() const =0
virtual QCString briefFile() const =0
virtual Definition * getOuterScope() const =0
virtual int getStartBodyLine() const =0
virtual QCString inbodyDocumentation() const =0
virtual QCString inbodyFile() const =0
virtual const QCString & name() const =0
virtual void setBodySegment(int defLine, int bls, int ble)=0
virtual void setDocumentation(const QCString &d, const QCString &docFile, int docLine, bool stripWhiteSpace=TRUE)=0
virtual void setInbodyDocumentation(const QCString &d, const QCString &docFile, int docLine)=0
virtual void mergeRefItems(Definition *d)=0
virtual void setBodyDef(const FileDef *fd)=0
virtual void setBriefDescription(const QCString &b, const QCString &briefFile, int briefLine)=0
virtual const ArgumentList & templateArguments() const =0
virtual GroupDef * getGroupDef()=0
virtual const FileDef * getFileDef() const =0
virtual const ArgumentList & argumentList() const =0
virtual bool isFunction() const =0
virtual bool isExternal() const =0
virtual bool isStatic() const =0
virtual StringVector getQualifiers() const =0
virtual bool isDocsForDefinition() const =0
virtual Grouping::GroupPri_t getGroupPri() const =0
virtual TypeSpecifier getMemberSpecifiers() const =0
virtual bool isVariable() const =0
virtual QCString argsString() const =0
virtual bool isPrototype() const =0
virtual void setMemberDeclaration(MemberDef *md)=0
virtual void resolveUnnamedParameters(const MemberDef *md)=0
virtual void setDocsForDefinition(bool b)=0
virtual void mergeMemberSpecifiers(TypeSpecifier s)=0
virtual void addQualifiers(const StringVector &qualifiers)=0
virtual void moveDeclArgumentList(std::unique_ptr< ArgumentList > al)=0
virtual void setGroupDef(GroupDef *gd, Grouping::GroupPri_t pri, const QCString &fileName, int startLine, bool hasDocs, MemberDef *member=nullptr)=0
virtual void setMemberDefinition(MemberDef *md)=0
virtual void moveArgumentList(std::unique_ptr< ArgumentList > al)=0
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
#define Config_getBool(name)
Definition config.h:33
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const QCString &argsString, QCString *extraTypeChars=nullptr)
Definition defargs.l:814
#define AUTO_TRACE_ADD(...)
Definition docnode.cpp:47
#define AUTO_TRACE(...)
Definition docnode.cpp:46
static void transferArgumentDocumentation(ArgumentList &decAl, ArgumentList &defAl)
#define TRUE
Definition qcstring.h:37
bool matchArguments2(const Definition *srcScope, const FileDef *srcFileScope, const ArgumentList *srcAl, const Definition *dstScope, const FileDef *dstFileScope, const ArgumentList *dstAl, bool checkCV, SrcLangExt lang)
Definition util.cpp:1931
void mergeMemberOverrideOptions(MemberDefMutable *md1, MemberDefMutable *md2)
Definition util.cpp:7188

References MemberDefMutable::addQualifiers(), MemberDef::argsString(), MemberDef::argumentList(), AUTO_TRACE, AUTO_TRACE_ADD, Definition::briefDescription(), Definition::briefFile(), Definition::briefLine(), Config_getBool, Definition::docFile(), Definition::docLine(), Definition::documentation(), Definition::getBodyDef(), Definition::getDefLine(), Definition::getEndBodyLine(), MemberDef::getFileDef(), MemberDef::getGroupDef(), MemberDef::getGroupPri(), Definition::getLanguage(), MemberDef::getMemberSpecifiers(), Definition::getOuterScope(), MemberDef::getQualifiers(), Definition::getStartBodyLine(), Definition::hasDocumentation(), ArgumentList::hasParameters(), Definition::inbodyDocumentation(), Definition::inbodyFile(), Definition::inbodyLine(), MemberDef::isDocsForDefinition(), QCString::isEmpty(), MemberDef::isExternal(), MemberDef::isFunction(), MemberDef::isPrototype(), MemberDef::isStatic(), MemberDef::isVariable(), matchArguments2(), mergeMemberOverrideOptions(), MemberDefMutable::mergeMemberSpecifiers(), DefinitionMutable::mergeRefItems(), MemberDefMutable::moveArgumentList(), MemberDefMutable::moveDeclArgumentList(), Definition::name(), MemberDefMutable::resolveUnnamedParameters(), DefinitionMutable::setBodyDef(), DefinitionMutable::setBodySegment(), DefinitionMutable::setBriefDescription(), MemberDefMutable::setDocsForDefinition(), DefinitionMutable::setDocumentation(), MemberDefMutable::setGroupDef(), DefinitionMutable::setInbodyDocumentation(), MemberDefMutable::setMemberDeclaration(), MemberDefMutable::setMemberDefinition(), ArgumentList::size(), stringToArgumentList(), MemberDef::templateArguments(), transferArgumentDocumentation(), and TRUE.

Referenced by ClassDefImpl::mergeCategory(), and transferFunctionDocumentation().

◆ createMemberDef()

std::unique_ptr< MemberDef > createMemberDef ( const QCString & defFileName,
int defLine,
int defColumn,
const QCString & type,
const QCString & name,
const QCString & args,
const QCString & excp,
Protection prot,
Specifier virt,
bool stat,
Relationship related,
MemberType t,
const ArgumentList & tal,
const ArgumentList & al,
const QCString & metaData )

Factory method to create a new instance of a MemberDef.

Definition at line 516 of file memberdef.cpp.

521{
522 return std::make_unique<MemberDefImpl>(defFileName,defLine,defColumn,type,name,args,excp,prot,virt,
523 stat,related,t,tal,al,metaData);
524}

Referenced by addEnumValuesToEnums(), addInstance(), addLocalObjCMethod(), addMemberSpecialization(), addOverloaded(), addVariableToClass(), addVariableToFile(), buildDefineList(), createTagLessInstance(), MemberDefImpl::createTemplateInstanceMember(), findDefineDocumentation(), findEnums(), findMember(), and findUsingDeclImports().

◆ createMemberDefAlias()

std::unique_ptr< MemberDef > createMemberDefAlias ( const Definition * newScope,
const MemberDef * aliasMd )

Definition at line 966 of file memberdef.cpp.

967{
968 auto amd = std::make_unique<MemberDefAliasImpl>(newScope,aliasMd);
969 //printf("amd: name=%s displayName=%s\n",qPrint(amd->name()),qPrint(amd->displayName()));
970 return amd;
971}

Referenced by MemberDefAliasImpl::deepCopy(), findUsingDeclImports(), NamespaceDefImpl::insertMember(), and insertMemberAlias().

◆ toMemberDef() [1/3]

const MemberDef * toMemberDef ( const Definition * d)

Definition at line 6464 of file memberdef.cpp.

6465{
6466 if (d && (typeid(*d)==typeid(MemberDefImpl) || typeid(*d)==typeid(MemberDefAliasImpl)))
6467 {
6468 return static_cast<const MemberDef*>(d);
6469 }
6470 else
6471 {
6472 return nullptr;
6473 }
6474}

◆ toMemberDef() [2/3]

◆ toMemberDef() [3/3]

MemberDef * toMemberDef ( DefinitionMutable * d)

Definition at line 6451 of file memberdef.cpp.

6452{
6453 Definition *d = toDefinition(md);
6454 if (d && typeid(*d)==typeid(MemberDefImpl))
6455 {
6456 return static_cast<MemberDef*>(d);
6457 }
6458 else
6459 {
6460 return nullptr;
6461 }
6462}
The common base class of all entity definitions found in the sources.
Definition definition.h:76
Definition * toDefinition(DefinitionMutable *dm)

References toDefinition().

◆ toMemberDefMutable()

MemberDefMutable * toMemberDefMutable ( Definition * d)

Definition at line 6476 of file memberdef.cpp.

6477{
6478 if (d && typeid(*d)==typeid(MemberDefImpl))
6479 {
6480 return static_cast<MemberDefMutable*>(d);
6481 }
6482 else
6483 {
6484 return nullptr;
6485 }
6486}

Referenced by addDocCrossReference(), addEnumValuesToEnums(), addInstance(), MemberList::addListReferences(), addLocalObjCMethod(), addMemberFunction(), addMemberSpecialization(), addMembersToMemberGroup(), ClassDefImpl::addMembersToTemplateInstance(), addMemberToGroups(), ClassDefImpl::addMemberToList(), FileDefImpl::addMemberToList(), ModuleDefImpl::addMemberToList(), NamespaceDefImpl::addMemberToList(), ModuleDefImpl::addMemberToModule(), ModuleManager::addMemberToModule(), addOverloaded(), addVariableToClass(), addVariableToFile(), buildDefineList(), computeMemberRelationsForBaseClass(), createTagLessInstance(), MemberDefImpl::createTemplateInstanceMember(), ClassDefImpl::deepCopy(), MemberGroup::distributeMemberGroupDocumentation(), findDefineDocumentation(), findDEV(), findEnumDocumentation(), findEnums(), findGlobalMember(), findMember(), MemberList::findSectionsInDocumentation(), findUsingDeclImports(), flushCachedTemplateRelations(), flushUnresolvedRelations(), generateClassMemberLink(), getLinkInScope(), incrementFlowKeyWordCount(), incrementFlowKeyWordCount(), inheritDocumentation(), GroupDefImpl::insertMember(), MemberGroup::insertMember(), NamespaceDefImpl::insertMember(), MemberDefImpl::insertReimplementedBy(), ClassDefImpl::mergeCategory(), SymbolResolver::Private::newResolveTypedef(), processTagLessClasses(), MemberList::setAnchors(), MemberList::setAnonymousEnumType(), ClassDefImpl::setGroupDefForAllMembers(), transferFunctionDocumentation(), transferFunctionReferences(), transferRelatedFunctionDocumentation(), transferStaticInstanceInitializers(), tryAddEnumDocsToGroupMember(), vhdlCorrectMemberProperties(), MemberDefImpl::writeDeclaration(), MemberList::writeDocumentation(), MemberList::writeDocumentationPage(), VhdlDocGen::writePlainVHDLDeclarations(), MemberList::writeSimpleDocumentation(), VhdlDocGen::writeSource(), and MemberList::writeTagFile().