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 6377 of file memberdef.cpp.

6378{
6379 MemberDefMutable *src = toMemberDefMutable(const_cast<MemberDef*>(s));
6380 MemberDefMutable *dst = toMemberDefMutable(const_cast<MemberDef*>(d));
6381 if (src==nullptr || dst==nullptr) return;
6382 //printf("--> addDocCrossReference src=%s,dst=%s\n",qPrint(src->name()),qPrint(dst->name()));
6383 if (dst->isTypedef() || dst->isEnumerate()) return; // don't add types
6384 if ((dst->hasReferencedByRelation() || dst->hasCallerGraph()) &&
6385 src->isCallable()
6386 )
6387 {
6388 QCString sourceRefName = src->sourceRefName();
6391
6392 // ---- critical section
6393 std::lock_guard<std::mutex> lock(g_docCrossReferenceMutex);
6394 dst->addSourceReferencedBy(src,sourceRefName);
6395 if (mdDef)
6396 {
6397 mdDef->addSourceReferencedBy(src,sourceRefName);
6398 }
6399 if (mdDecl)
6400 {
6401 mdDecl->addSourceReferencedBy(src,sourceRefName);
6402 }
6403 // ---- end critical section
6404 }
6405 if ((src->hasReferencesRelation() || src->hasCallGraph()) &&
6406 src->isCallable()
6407 )
6408 {
6409 QCString sourceRefName = dst->sourceRefName();
6412
6413 // ---- critical section
6414 std::lock_guard<std::mutex> lock(g_docCrossReferenceMutex);
6415 src->addSourceReferences(dst,sourceRefName);
6416 if (mdDef)
6417 {
6418 mdDef->addSourceReferences(dst,sourceRefName);
6419 }
6420 if (mdDecl)
6421 {
6422 mdDecl->addSourceReferences(dst,sourceRefName);
6423 }
6424 // ---- end critical section
6425 }
6426}
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(), MemberDefMutable::setFromAnonymousScope(), and writeObjCMethodCall().

◆ combineDeclarationAndDefinition()

void combineDeclarationAndDefinition ( MemberDefMutable * mdec,
MemberDefMutable * mdef )

Definition at line 6143 of file memberdef.cpp.

6144{
6145 AUTO_TRACE("mdec='{}' mdef='{}' mdec.isPrototype={} mdef.isPrototype={}",
6146 mdec->name(), mdef->name(), mdec->isPrototype(), mdef->isPrototype());
6147 if (
6148 (mdef->isFunction() && !mdef->isStatic() && !mdef->isPrototype()) ||
6149 (mdef->isVariable() && !mdef->isExternal() && !mdef->isStatic())
6150 )
6151 {
6152 bool sameNumTemplateArgs = mdef->templateArguments().size()==mdec->templateArguments().size();
6153
6154 ArgumentList &mdefAl = const_cast<ArgumentList&>(mdef->argumentList());
6155 ArgumentList &mdecAl = const_cast<ArgumentList&>(mdec->argumentList());
6156 if (sameNumTemplateArgs &&
6157 matchArguments2(mdef->getOuterScope(),mdef->getFileDef(),&mdefAl,
6158 mdec->getOuterScope(),mdec->getFileDef(),&mdecAl,
6159 TRUE,mdef->getLanguage()
6160 )
6161 ) /* match found */
6162 {
6163 AUTO_TRACE_ADD("combining definition and declaration");
6164
6165 if (Config_getBool(RESOLVE_UNNAMED_PARAMS))
6166 {
6167 mdec->resolveUnnamedParameters(mdef);
6168 }
6169
6170 // first merge argument documentation
6171 transferArgumentDocumentation(mdecAl,mdefAl);
6172
6173 /* copy documentation between function definition and declaration */
6174 if (!mdec->briefDescription().isEmpty())
6175 {
6176 mdef->setBriefDescription(mdec->briefDescription(),mdec->briefFile(),mdec->briefLine());
6177 }
6178 else if (!mdef->briefDescription().isEmpty())
6179 {
6180 mdec->setBriefDescription(mdef->briefDescription(),mdef->briefFile(),mdef->briefLine());
6181 }
6182 if (!mdef->documentation().isEmpty())
6183 {
6184 //printf("transferring docs mdef->mdec (%s->%s)\n",mdef->argsString(),mdec->argsString());
6185 mdec->setDocumentation(mdef->documentation(),mdef->docFile(),mdef->docLine());
6187 if (mdefAl.hasParameters())
6188 {
6189 auto mdefAlComb = stringToArgumentList(mdef->getLanguage(),mdef->argsString());
6190 transferArgumentDocumentation(mdefAl,*mdefAlComb);
6191 mdec->moveArgumentList(std::move(mdefAlComb));
6192 }
6193 }
6194 else if (!mdec->documentation().isEmpty())
6195 {
6196 //printf("transferring docs mdec->mdef (%s->%s)\n",mdec->argsString(),mdef->argsString());
6197 mdef->setDocumentation(mdec->documentation(),mdec->docFile(),mdec->docLine());
6199 if (mdecAl.hasParameters())
6200 {
6201 auto mdecAlComb = stringToArgumentList(mdec->getLanguage(),mdec->argsString());
6202 transferArgumentDocumentation(mdecAl,*mdecAlComb);
6203 mdef->moveDeclArgumentList(std::move(mdecAlComb));
6204 }
6205 }
6206 if (!mdef->inbodyDocumentation().isEmpty())
6207 {
6208 mdec->setInbodyDocumentation(mdef->inbodyDocumentation(),mdef->inbodyFile(),mdef->inbodyLine());
6209 }
6210 else if (!mdec->inbodyDocumentation().isEmpty())
6211 {
6212 mdef->setInbodyDocumentation(mdec->inbodyDocumentation(),mdec->inbodyFile(),mdec->inbodyLine());
6213 }
6214 if (mdec->getStartBodyLine()!=-1 && mdef->getStartBodyLine()==-1)
6215 {
6216 //printf("body mdec->mdef %d-%d\n",mdec->getStartBodyLine(),mdef->getEndBodyLine());
6217 mdef->setBodySegment(mdec->getDefLine(),mdec->getStartBodyLine(),mdec->getEndBodyLine());
6218 mdef->setBodyDef(mdec->getBodyDef());
6219 //mdef->setBodyMember(mdec);
6220 }
6221 else if (mdef->getStartBodyLine()!=-1 && mdec->getStartBodyLine()==-1)
6222 {
6223 //printf("body mdef->mdec %d-%d\n",mdef->getStartBodyLine(),mdec->getEndBodyLine());
6224 mdec->setBodySegment(mdef->getDefLine(),mdef->getStartBodyLine(),mdef->getEndBodyLine());
6225 mdec->setBodyDef(mdef->getBodyDef());
6226 //mdec->setBodyMember(mdef);
6227 }
6230
6231 // copy group info.
6232 if (mdec->getGroupDef()==nullptr && mdef->getGroupDef()!=nullptr)
6233 {
6234 mdec->setGroupDef(mdef->getGroupDef(),
6235 mdef->getGroupPri(),
6236 mdef->docFile(),
6237 mdef->docLine(),
6238 mdef->hasDocumentation(),
6239 mdef
6240 );
6241 }
6242 else if (mdef->getGroupDef()==nullptr && mdec->getGroupDef()!=nullptr)
6243 {
6244 mdef->setGroupDef(mdec->getGroupDef(),
6245 mdec->getGroupPri(),
6246 mdec->docFile(),
6247 mdec->docLine(),
6248 mdec->hasDocumentation(),
6249 mdec
6250 );
6251 }
6252
6253
6254 mdec->mergeRefItems(mdef);
6255 mdef->mergeRefItems(mdec);
6256
6257 mdef->setMemberDeclaration(mdec);
6258 mdec->setMemberDefinition(mdef);
6259
6260 mergeMemberOverrideOptions(mdec,mdef);
6261
6262 mdef->addQualifiers(mdec->getQualifiers());
6263 mdec->addQualifiers(mdef->getQualifiers());
6264 }
6265 }
6266}
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:7285

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(), MemberDefMutable::setFromAnonymousScope(), 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 )

◆ 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(), insertMemberAlias(), and MemberDefMutable::setFromAnonymousScope().

◆ toMemberDef() [1/3]

const MemberDef * toMemberDef ( const Definition * d)

Definition at line 6455 of file memberdef.cpp.

6456{
6457 if (d && (typeid(*d)==typeid(MemberDefImpl) || typeid(*d)==typeid(MemberDefAliasImpl)))
6458 {
6459 return static_cast<const MemberDef*>(d);
6460 }
6461 else
6462 {
6463 return nullptr;
6464 }
6465}

◆ toMemberDef() [2/3]

◆ toMemberDef() [3/3]

MemberDef * toMemberDef ( DefinitionMutable * d)

Definition at line 6442 of file memberdef.cpp.

6443{
6444 Definition *d = toDefinition(md);
6445 if (d && typeid(*d)==typeid(MemberDefImpl))
6446 {
6447 return static_cast<MemberDef*>(d);
6448 }
6449 else
6450 {
6451 return nullptr;
6452 }
6453}
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 6467 of file memberdef.cpp.

6468{
6469 if (d && typeid(*d)==typeid(MemberDefImpl))
6470 {
6471 return static_cast<MemberDefMutable*>(d);
6472 }
6473 else
6474 {
6475 return nullptr;
6476 }
6477}

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