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

6383{
6384 MemberDefMutable *src = toMemberDefMutable(const_cast<MemberDef*>(s));
6385 MemberDefMutable *dst = toMemberDefMutable(const_cast<MemberDef*>(d));
6386 if (src==nullptr || dst==nullptr) return;
6387 //printf("--> addDocCrossReference src=%s,dst=%s\n",qPrint(src->name()),qPrint(dst->name()));
6388 if (dst->isTypedef() || dst->isEnumerate()) return; // don't add types
6389 if ((dst->hasReferencedByRelation() || dst->hasCallerGraph()) &&
6390 src->isCallable()
6391 )
6392 {
6393 QCString sourceRefName = src->sourceRefName();
6396
6397 // ---- critical section
6398 std::lock_guard<std::mutex> lock(g_docCrossReferenceMutex);
6399 dst->addSourceReferencedBy(src,sourceRefName);
6400 if (mdDef)
6401 {
6402 mdDef->addSourceReferencedBy(src,sourceRefName);
6403 }
6404 if (mdDecl)
6405 {
6406 mdDecl->addSourceReferencedBy(src,sourceRefName);
6407 }
6408 // ---- end critical section
6409 }
6410 if ((src->hasReferencesRelation() || src->hasCallGraph()) &&
6411 src->isCallable()
6412 )
6413 {
6414 QCString sourceRefName = dst->sourceRefName();
6417
6418 // ---- critical section
6419 std::lock_guard<std::mutex> lock(g_docCrossReferenceMutex);
6420 src->addSourceReferences(dst,sourceRefName);
6421 if (mdDef)
6422 {
6423 mdDef->addSourceReferences(dst,sourceRefName);
6424 }
6425 if (mdDecl)
6426 {
6427 mdDecl->addSourceReferences(dst,sourceRefName);
6428 }
6429 // ---- end critical section
6430 }
6431}
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 6148 of file memberdef.cpp.

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

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

6461{
6462 if (d && (typeid(*d)==typeid(MemberDefImpl) || typeid(*d)==typeid(MemberDefAliasImpl)))
6463 {
6464 return static_cast<const MemberDef*>(d);
6465 }
6466 else
6467 {
6468 return nullptr;
6469 }
6470}

◆ toMemberDef() [2/3]

◆ toMemberDef() [3/3]

MemberDef * toMemberDef ( DefinitionMutable * d)

Definition at line 6447 of file memberdef.cpp.

6448{
6449 Definition *d = toDefinition(md);
6450 if (d && typeid(*d)==typeid(MemberDefImpl))
6451 {
6452 return static_cast<MemberDef*>(d);
6453 }
6454 else
6455 {
6456 return nullptr;
6457 }
6458}
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 6472 of file memberdef.cpp.

6473{
6474 if (d && typeid(*d)==typeid(MemberDefImpl))
6475 {
6476 return static_cast<MemberDefMutable*>(d);
6477 }
6478 else
6479 {
6480 return nullptr;
6481 }
6482}

Referenced by addDocCrossReference(), addEnumValuesToEnums(), addGlobalFunction(), addInstance(), addInterfaceOrServiceToServiceOrSingleton(), MemberList::addListReferences(), addLocalObjCMethod(), addMemberFunction(), addMemberSpecialization(), addMembersToMemberGroup(), ClassDefImpl::addMembersToTemplateInstance(), addMemberToGroups(), ClassDefImpl::addMemberToList(), FileDefImpl::addMemberToList(), ModuleDefImpl::addMemberToList(), NamespaceDefImpl::addMemberToList(), ModuleDefImpl::addMemberToModule(), ModuleManager::addMemberToModule(), 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(), getLinkInScope(), 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().