From 9e2b6a2dac870b5daabde118c5327281e3f79ba2 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Fri, 24 Apr 2020 08:27:22 +0200 Subject: Performance improvements after profiling In some cases performance dropped when upgrading from version 1.8.16 to 1.8.17 or 1.8.18. With these changes the performance should be back to normal again. --- .gitignore | 2 + src/classdef.cpp | 9 ++- src/classlist.cpp | 10 ++-- src/defargs.h | 12 ++-- src/defargs.l | 32 ++++++----- src/defgen.cpp | 3 +- src/doxygen.cpp | 89 +++++++++++++++-------------- src/entry.cpp | 9 ++- src/groupdef.cpp | 164 +++++++++++++++++++++++++++--------------------------- src/htmlgen.cpp | 2 +- src/memberdef.cpp | 70 ++++++++++++----------- src/memberdef.h | 21 +++---- src/pre.l | 4 +- src/scanner.l | 8 +-- src/tagreader.cpp | 2 +- src/util.cpp | 146 +++++++++++++++++++++++++----------------------- src/util.h | 10 ++-- 17 files changed, 302 insertions(+), 291 deletions(-) diff --git a/.gitignore b/.gitignore index fa8ffb5..82dab79 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ /doxygen_docs /doxygen.tag /build* + +.idea diff --git a/src/classdef.cpp b/src/classdef.cpp index 52d2f49..5670109 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -3665,8 +3665,8 @@ void ClassDefImpl::mergeMembers() ArgumentList &srcAl = srcMd->argumentList(); ArgumentList &dstAl = dstMd->argumentList(); found=matchArguments2( - srcMd->getOuterScope(),srcMd->getFileDef(),srcAl, - dstMd->getOuterScope(),dstMd->getFileDef(),dstAl, + srcMd->getOuterScope(),srcMd->getFileDef(),&srcAl, + dstMd->getOuterScope(),dstMd->getFileDef(),&dstAl, TRUE ); //printf(" Yes, matching (%s<->%s): %d\n", @@ -4254,11 +4254,10 @@ void ClassDefImpl::addMembersToTemplateInstance(const ClassDef *cd,const char *t MemberInfo *mi; for (mnii.toFirst();(mi=mnii.current());++mnii) { - ArgumentList actualArguments; - stringToArgumentList(getLanguage(),templSpec,actualArguments); + auto actualArguments_p = stringToArgumentList(getLanguage(),templSpec); MemberDef *md = mi->memberDef; std::unique_ptr imd { md->createTemplateInstanceMember( - cd->templateArguments(),actualArguments) }; + cd->templateArguments(),actualArguments_p) }; //printf("%s->setMemberClass(%p)\n",imd->name().data(),this); imd->setMemberClass(this); imd->setTemplateMaster(md); diff --git a/src/classlist.cpp b/src/classlist.cpp index 5e14051..ee4ffa4 100644 --- a/src/classlist.cpp +++ b/src/classlist.cpp @@ -166,9 +166,8 @@ void GenericsSDict::insert(const QCString &key,ClassDef *cd) { int i=key.find('<'); if (i==-1) return; - ArgumentList argList; - stringToArgumentList(SrcLangExt_CSharp, key.mid(i),argList); - int c = (int)argList.size(); + auto argList = stringToArgumentList(SrcLangExt_CSharp, key.mid(i)); + int c = (int)argList->size(); if (c==0) return; GenericsCollection *collection = m_dict.find(key.left(i)); if (collection==0) // new name @@ -199,9 +198,8 @@ ClassDef *GenericsSDict::find(const QCString &key) GenericsCollection *collection = m_dict.find(key.left(i)); if (collection) { - ArgumentList argList; - stringToArgumentList(SrcLangExt_CSharp,key.mid(i),argList); - int c = (int)argList.size(); + auto argList = stringToArgumentList(SrcLangExt_CSharp,key.mid(i)); + int c = (int)argList->size(); return collection->find(c); } } diff --git a/src/defargs.h b/src/defargs.h index 4a38723..589eb90 100644 --- a/src/defargs.h +++ b/src/defargs.h @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -19,11 +19,13 @@ #define DEFARGS_H #include "types.h" +#include class ArgumentList; class QCString; -extern void stringToArgumentList(SrcLangExt lang, const char *argsString,ArgumentList& argList, - QCString *extraTypeChars=0); +std::unique_ptr stringToArgumentList(SrcLangExt lang, + const char *argsString, + QCString *extraTypeChars=0); #endif diff --git a/src/defargs.l b/src/defargs.l index 2541a43..9c58508 100644 --- a/src/defargs.l +++ b/src/defargs.l @@ -75,10 +75,10 @@ */ struct defargsYY_state { - defargsYY_state(const char *inStr,ArgumentList &al,SrcLangExt l) + defargsYY_state(const char *inStr,std::unique_ptr &al,SrcLangExt l) : inputString(inStr), argList(al), lang(l) {} const char *inputString; - ArgumentList &argList; + std::unique_ptr &argList; SrcLangExt lang; int inputPosition = 0; QCString *copyArgValue = 0; @@ -437,7 +437,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" //printf("a->type=%s a->name=%s a->defval=\"%s\"\n",a->type.data(),a->name.data(),a->defval.data()); a.docs = yyextra->curArgDocs.stripWhiteSpace(); //printf("Argument '%s' '%s' adding docs='%s'\n",a->type.data(),a->name.data(),a->docs.data()); - yyextra->argList.push_back(a); + yyextra->argList->push_back(a); } yyextra->curArgAttrib.resize(0); yyextra->curArgTypeName.resize(0); @@ -506,23 +506,23 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" yyextra->curTypeConstraint+=' '; } "const" { - yyextra->argList.constSpecifier=TRUE; + yyextra->argList->constSpecifier=TRUE; } "volatile" { - yyextra->argList.volatileSpecifier=TRUE; + yyextra->argList->volatileSpecifier=TRUE; } "&" { - yyextra->argList.refQualifier=RefQualifierLValue; + yyextra->argList->refQualifier=RefQualifierLValue; } "&&" { - yyextra->argList.refQualifier=RefQualifierRValue; + yyextra->argList->refQualifier=RefQualifierRValue; } "="{B}*"0" { - yyextra->argList.pureSpecifier=TRUE; + yyextra->argList->pureSpecifier=TRUE; BEGIN(FuncQual); } "->" { // C++11 trailing return type - yyextra->argList.trailingReturnType=" -> "; + yyextra->argList->trailingReturnType=" -> "; BEGIN(TrailingReturn); } {B}/("final"|"override"){B}* { @@ -530,10 +530,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" BEGIN(FuncQual); } . { - yyextra->argList.trailingReturnType+=yytext; + yyextra->argList->trailingReturnType+=yytext; } \n { - yyextra->argList.trailingReturnType+=yytext; + yyextra->argList->trailingReturnType+=yytext; } ")"{B}*"["[^]]*"]" { // for functions returning a pointer to an array, // i.e. ")[]" in "int (*f(int))[4]" with argsString="(int))[4]" @@ -768,9 +768,10 @@ static bool nameIsActuallyPartOfType(QCString &name) * for complex types are written to */ -void stringToArgumentList(SrcLangExt lang, const char *argsString,ArgumentList& al,QCString *extraTypeChars) +std::unique_ptr stringToArgumentList(SrcLangExt lang, const char *argsString,QCString *extraTypeChars) { - if (argsString==0) return; + std::unique_ptr al = std::make_unique(); + if (argsString==0) return al; yyscan_t yyscanner; defargsYY_state extra(argsString,al,lang); @@ -784,14 +785,15 @@ void stringToArgumentList(SrcLangExt lang, const char *argsString,ArgumentList& defargsYYrestart( 0, yyscanner ); BEGIN( Start ); defargsYYlex(yyscanner); - if (yyextra->argList.empty()) + if (yyextra->argList->empty()) { - yyextra->argList.noParameters = TRUE; + yyextra->argList->noParameters = TRUE; } if (extraTypeChars) *extraTypeChars=yyextra->extraTypeChars; //printf("stringToArgumentList(%s) result=%s\n",argsString,argListToString(al).data()); printlex(yy_flex_debug, FALSE, __FILE__, NULL); defargsYYlex_destroy(yyscanner); + return al; } #if USE_STATE2STRING diff --git a/src/defgen.cpp b/src/defgen.cpp index 96f9da3..02f51c5 100644 --- a/src/defgen.cpp +++ b/src/defgen.cpp @@ -145,8 +145,7 @@ void generateDEFForMember(MemberDef *md, if (isFunc) //function { const ArgumentList &defAl = md->argumentList(); - ArgumentList declAl; - stringToArgumentList(md->getLanguage(),md->argsString(),declAl); + ArgumentList declAl = *stringToArgumentList(md->getLanguage(),md->argsString()); QCString fcnPrefix = " " + memPrefix + "param-"; auto defIt = defAl.begin(); diff --git a/src/doxygen.cpp b/src/doxygen.cpp index c59b075..873f5dc 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -867,7 +867,7 @@ static Definition *findScopeFromQualifiedName(Definition *startScope,const QCStr return resultScope; } -ArgumentList getTemplateArgumentsFromName( +std::unique_ptr getTemplateArgumentsFromName( const QCString &name, const std::vector &tArgLists) { @@ -891,7 +891,9 @@ ArgumentList getTemplateArgumentsFromName( } p=i+2; } - return alIt!=tArgLists.end() ? *alIt : ArgumentList(); + return alIt!=tArgLists.end() ? + std::make_unique(*alIt) : + std::unique_ptr(); } static @@ -1008,8 +1010,11 @@ static void addClassToContext(const Entry *root) // this happens if a template class declared with @class is found // before the actual definition or if a forward declaration has different template // parameter names. - ArgumentList tArgList = getTemplateArgumentsFromName(cd->name(),root->tArgLists); - cd->setTemplateArguments(tArgList); + std::unique_ptr tArgList = getTemplateArgumentsFromName(cd->name(),root->tArgLists); + if (tArgList) + { + cd->setTemplateArguments(*tArgList); + } } cd->setCompoundType(convertToCompoundType(root->section,root->spec)); @@ -1042,12 +1047,12 @@ static void addClassToContext(const Entry *root) buildScopeFromQualifiedName(fullName,fullName.contains("::"),root->lang,tagInfo); } } - ArgumentList tArgList; + std::unique_ptr tArgList; if ((root->lang==SrcLangExt_CSharp || root->lang==SrcLangExt_Java) && (i=fullName.find('<'))!=-1) { // a Java/C# generic class looks like a C++ specialization, so we need to split the // name and template arguments here - stringToArgumentList(root->lang,fullName.mid(i),tArgList); + tArgList = stringToArgumentList(root->lang,fullName.mid(i)); fullName=fullName.left(i); } else @@ -1070,7 +1075,10 @@ static void addClassToContext(const Entry *root) //printf("class %s template args=%s\n",fullName.data(), // tArgList ? tempArgListToString(tArgList,root->lang).data() : ""); - cd->setTemplateArguments(tArgList); + if (tArgList) + { + cd->setTemplateArguments(*tArgList); + } cd->setProtection(root->protection); cd->setIsStatic(root->stat); @@ -3060,7 +3068,6 @@ static void addMethodToClass(const Entry *root,ClassDef *cd, md->setId(root->id); md->setBodyDef(fd); md->setFileDef(fd); - //md->setScopeTemplateArguments(root->tArgList); md->addSectionsToDefinition(root->anchors); QCString def; QCString qualScope = cd->qualifiedNameWithTemplateParameters(); @@ -3410,8 +3417,8 @@ static void buildFunctionList(const Entry *root) root->stat && md->isStatic() && root->fileName!=md->getDefFileName(); if ( - matchArguments2(md->getOuterScope(),mfd,mdAl, - rnd ? rnd : Doxygen::globalScope,rfd,root->argList, + matchArguments2(md->getOuterScope(),mfd,&mdAl, + rnd ? rnd : Doxygen::globalScope,rfd,&root->argList, FALSE) && sameNumTemplateArgs && matchingReturnTypes && @@ -3449,16 +3456,14 @@ static void buildFunctionList(const Entry *root) // merge documentation if (md->documentation().isEmpty() && !root->doc.isEmpty()) { - ArgumentList argList; - stringToArgumentList(root->lang,root->args,argList); if (root->proto) { //printf("setDeclArgumentList to %p\n",argList); - md->setDeclArgumentList(argList); + md->moveDeclArgumentList(stringToArgumentList(root->lang,root->args)); } else { - md->setArgumentList(argList); + md->moveArgumentList(stringToArgumentList(root->lang,root->args)); } } @@ -3578,8 +3583,8 @@ static void findFriends() // mmd->isRelated(),mmd->isFriend(),mmd->isFunction()); if ((cmmd->isFriend() || (cmmd->isRelated() && cmmd->isFunction())) && !fmd->isAlias() && !mmd->isAlias() && - matchArguments2(cmmd->getOuterScope(), cmmd->getFileDef(), cmmd->argumentList(), - cfmd->getOuterScope(), cfmd->getFileDef(), cfmd->argumentList(), + matchArguments2(cmmd->getOuterScope(), cmmd->getFileDef(), &cmmd->argumentList(), + cfmd->getOuterScope(), cfmd->getFileDef(), &cfmd->argumentList(), TRUE ) @@ -3702,8 +3707,8 @@ static void transferFunctionReferences() ArgumentList &mdefAl = mdef->argumentList(); ArgumentList &mdecAl = mdec->argumentList(); if ( - matchArguments2(mdef->getOuterScope(),mdef->getFileDef(),mdefAl, - mdec->getOuterScope(),mdec->getFileDef(),mdecAl, + matchArguments2(mdef->getOuterScope(),mdef->getFileDef(),&mdefAl, + mdec->getOuterScope(),mdec->getFileDef(),&mdecAl, TRUE ) ) /* match found */ @@ -3789,8 +3794,8 @@ static void transferRelatedFunctionDocumentation() //printf(" Member found: related='%d'\n",rmd->isRelated()); if ((rmd->isRelated() || rmd->isForeign()) && // related function !md->isAlias() && !rmd->isAlias() && - matchArguments2( md->getOuterScope(), md->getFileDef(), md->argumentList(), - rmd->getOuterScope(),rmd->getFileDef(),rmd->argumentList(), + matchArguments2( md->getOuterScope(), md->getFileDef(), &md->argumentList(), + rmd->getOuterScope(),rmd->getFileDef(),&rmd->argumentList(), TRUE ) ) @@ -3886,7 +3891,7 @@ static void findUsedClassesForClass(const Entry *root, ClassDef *masterCd, ClassDef *instanceCd, bool isArtificial, - const ArgumentList &actualArgs=ArgumentList(), + const std::unique_ptr &actualArgs = std::unique_ptr(), QDict *templateNames=0 ) { @@ -4048,7 +4053,7 @@ static void findBaseClassesForClass( ClassDef *instanceCd, FindBaseClassRelation_Mode mode, bool isArtificial, - const ArgumentList &actualArgs=ArgumentList(), + const std::unique_ptr &actualArgs = std::unique_ptr(), QDict *templateNames=0 ) { @@ -4145,8 +4150,7 @@ static bool findTemplateInstanceRelation(const Entry *root, const Entry *templateRoot = it->second; Debug::print(Debug::Classes,0," template root found %s templSpec=%s!\n", qPrint(templateRoot->name),qPrint(templSpec)); - ArgumentList templArgs; - stringToArgumentList(root->lang,templSpec,templArgs); + std::unique_ptr templArgs = stringToArgumentList(root->lang,templSpec); findBaseClassesForClass(templateRoot,context,templateClass,instanceClass, TemplateInstances,isArtificial,templArgs,templateNames); @@ -4759,8 +4763,7 @@ static void computeTemplateClassRelations() { Debug::print(Debug::Classes,0," Template instance %s : \n",qPrint(tcd->name())); QCString templSpec = tdi.currentKey(); - ArgumentList templArgs; - stringToArgumentList(tcd->getLanguage(),templSpec,templArgs); + std::unique_ptr templArgs = stringToArgumentList(tcd->getLanguage(),templSpec); for (const BaseInfo &bi : root->extends) { // check if the base class is a template argument @@ -4780,9 +4783,9 @@ static void computeTemplateClassRelations() int templIndex = *qdi.current(); Argument actArg; bool hasActArg=FALSE; - if (templIndex<(int)templArgs.size()) + if (templIndex<(int)templArgs->size()) { - actArg=templArgs.at(templIndex); + actArg=templArgs->at(templIndex); hasActArg=TRUE; } if (hasActArg && @@ -4974,8 +4977,8 @@ static void addMemberDocs(const Entry *root, else { if ( - matchArguments2( md->getOuterScope(), md->getFileDef(), mdAl, - rscope,rfd,root->argList, + matchArguments2( md->getOuterScope(), md->getFileDef(), &mdAl, + rscope,rfd,&root->argList, TRUE ) ) @@ -5155,8 +5158,8 @@ static bool findGlobalMember(const Entry *root, bool matching= (mdAl.empty() && root->argList.empty()) || md->isVariable() || md->isTypedef() || /* in case of function pointers */ - matchArguments2(md->getOuterScope(),const_cast(md.get())->getFileDef(),mdAl, - rnd ? rnd : Doxygen::globalScope,fd,root->argList, + matchArguments2(md->getOuterScope(),const_cast(md.get())->getFileDef(),&mdAl, + rnd ? rnd : Doxygen::globalScope,fd,&root->argList, FALSE); // for template members we need to check if the number of @@ -5546,8 +5549,8 @@ static void addMemberFunction(const Entry *root, bool matching= md->isVariable() || md->isTypedef() || // needed for function pointers matchArguments2( - md->getClassDef(),md->getFileDef(),argList, - cd,fd,root->argList, + md->getClassDef(),md->getFileDef(),&argList, + cd,fd,&root->argList, TRUE); if (md->getLanguage()==SrcLangExt_ObjC && md->isVariable() && (root->section&Entry::FUNCTION_SEC)) @@ -5602,7 +5605,7 @@ static void addMemberFunction(const Entry *root, if (matching) // replace member's argument list { md->setDefinitionTemplateParameterLists(root->tArgLists); - md->setArgumentList(argList); + md->moveArgumentList(std::make_unique(argList)); } else // no match { @@ -5850,14 +5853,14 @@ static void addOverloaded(const Entry *root,MemberName *mn, else mtype=MemberType_Function; // new overloaded member function - ArgumentList tArgList = + std::unique_ptr tArgList = getTemplateArgumentsFromName(cd->name()+"::"+funcName,root->tArgLists); //printf("new related member %s args='%s'\n",md->name().data(),funcArgs.data()); std::unique_ptr md { createMemberDef( root->fileName,root->startLine,root->startColumn, funcType,funcName,funcArgs,exceptions, root->protection,root->virt,root->stat,Related, - mtype,tArgList,root->argList,root->metaData) }; + mtype,tArgList ? *tArgList : ArgumentList(),root->argList,root->metaData) }; md->setTagInfo(root->tagInfo()); md->setLanguage(root->lang); md->setId(root->id); @@ -6305,8 +6308,8 @@ static void findMember(const Entry *root, newMember= className!=rmd->getOuterScope()->name() || - !matchArguments2(rmd->getOuterScope(),rmd->getFileDef(),rmdAl, - cd,fd,root->argList, + !matchArguments2(rmd->getOuterScope(),rmd->getFileDef(),&rmdAl, + cd,fd,&root->argList, TRUE); if (!newMember) { @@ -6400,8 +6403,8 @@ static void findMember(const Entry *root, const ArgumentList &rmdAl = rmd->argumentList(); // check for matching argument lists if ( - matchArguments2(rmd->getOuterScope(),rmd->getFileDef(),rmdAl, - cd,fd,root->argList, + matchArguments2(rmd->getOuterScope(),rmd->getFileDef(),&rmdAl, + cd,fd,&root->argList, TRUE) ) { @@ -7379,8 +7382,8 @@ static void computeMemberRelations() // argListToString(mdAl.pointer()).data() // ); if ( - matchArguments2(bmd->getOuterScope(),bmd->getFileDef(),bmdAl, - md->getOuterScope(), md->getFileDef(), mdAl, + matchArguments2(bmd->getOuterScope(),bmd->getFileDef(),&bmdAl, + md->getOuterScope(), md->getFileDef(), &mdAl, TRUE ) ) diff --git a/src/entry.cpp b/src/entry.cpp index 305487e..0c7da99 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -240,9 +240,8 @@ void Entry::reset() extends.clear(); groups.clear(); anchors.clear(); - argList.clear(); - tArgLists.clear(); argList.reset(); + tArgLists.clear(); typeConstr.reset(); sli.clear(); m_fileDef = 0; diff --git a/src/groupdef.cpp b/src/groupdef.cpp index 5af1525..90de94b 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -58,7 +58,7 @@ class GroupDefImpl : public DefinitionImpl, public GroupDef virtual const char *groupTitle() const { return m_title; } virtual void setGroupTitle( const char *newtitle ); virtual bool hasGroupTitle( ) const { return m_titleSet; } - virtual void addFile(const FileDef *def); + virtual void addFile(const FileDef *def); virtual bool addClass(const ClassDef *def); virtual bool addNamespace(const NamespaceDef *def); virtual void addGroup(const GroupDef *def); @@ -105,8 +105,8 @@ class GroupDefImpl : public DefinitionImpl, public GroupDef virtual PageSDict * getExamples() const { return m_exampleDict; } virtual bool hasDetailedDescription() const; virtual void sortSubGroups(); - - private: + + private: void addMemberListToGroup(MemberList *,bool (MemberDef::*)() const); MemberList *createMemberList(MemberListType lt); void addMemberToList(MemberListType lt,MemberDef *md); @@ -284,13 +284,13 @@ bool GroupDefImpl::addClass(const ClassDef *cd) //printf("i=%d\n",i); if (i>0) { - // add nested classes (e.g. A::B, A::C) after their parent (A) in + // add nested classes (e.g. A::B, A::C) after their parent (A) in // order of insertion QCString scope = qn.left(i); int j=m_classSDict->findAt(scope); if (j!=-1) { - while (j<(int)m_classSDict->count() && + while (j<(int)m_classSDict->count() && m_classSDict->at(j)->qualifiedName().left(i)==scope) { //printf("skipping over %s\n",classSDict->at(j)->qualifiedName().data()); @@ -319,7 +319,7 @@ bool GroupDefImpl::addNamespace(const NamespaceDef *def) if (m_namespaceSDict->find(def->name())==0) { if (sortBriefDocs) - m_namespaceSDict->inSort(def->name(),def); + m_namespaceSDict->inSort(def->name(),def); else m_namespaceSDict->append(def->name(),def); return TRUE; @@ -331,7 +331,7 @@ void GroupDefImpl::addDir(const DirDef *def) { if (def->isHidden()) return; if (Config_getBool(SORT_BRIEF_DOCS)) - m_dirList->inSort(def); + m_dirList->inSort(def); else m_dirList->append(def); } @@ -381,7 +381,7 @@ bool GroupDefImpl::insertMember(MemberDef *md,bool docOnly) MemberNameInfo *mni=0; if ((mni=(*m_allMemberNameInfoSDict)[md->name()])) { // member with this name already found - MemberNameInfoIterator srcMnii(*mni); + MemberNameInfoIterator srcMnii(*mni); const MemberInfo *srcMi; for ( ; (srcMi=srcMnii.current()) ; ++srcMnii ) { @@ -391,7 +391,7 @@ bool GroupDefImpl::insertMember(MemberDef *md,bool docOnly) bool sameScope = srcMd->getOuterScope()==md->getOuterScope() || // same class or namespace // both inside a file => definition and declaration do not have to be in the same file (srcMd->getOuterScope()->definitionType()==Definition::TypeFile && - md->getOuterScope()->definitionType()==Definition::TypeFile); + md->getOuterScope()->definitionType()==Definition::TypeFile); const ArgumentList &srcMdAl = srcMd->argumentList(); const ArgumentList &mdAl = md->argumentList(); @@ -400,20 +400,20 @@ bool GroupDefImpl::insertMember(MemberDef *md,bool docOnly) if (srcMd->isFunction() && md->isFunction() && // both are a function (tSrcMdAl.size()==tMdAl.size()) && // same number of template arguments - matchArguments2(srcMd->getOuterScope(),srcMd->getFileDef(),srcMdAl, - md->getOuterScope(),md->getFileDef(),mdAl, + matchArguments2(srcMd->getOuterScope(),srcMd->getFileDef(),&srcMdAl, + md->getOuterScope(),md->getFileDef(),&mdAl, TRUE ) && // matching parameters sameScope // both are found in the same scope ) { - if (srcMd->getGroupAlias()==0) + if (srcMd->getGroupAlias()==0) { - md->setGroupAlias(srcMd); + md->setGroupAlias(srcMd); } else if (md!=srcMd->getGroupAlias()) { - md->setGroupAlias(srcMd->getGroupAlias()); + md->setGroupAlias(srcMd->getGroupAlias()); } return FALSE; // member is the same as one that is already added } @@ -427,59 +427,59 @@ bool GroupDefImpl::insertMember(MemberDef *md,bool docOnly) m_allMemberNameInfoSDict->append(mni->memberName(),mni); } //printf("Added member!\n"); - m_allMemberList->append(md); + m_allMemberList->append(md); switch(md->memberType()) { - case MemberType_Variable: + case MemberType_Variable: if (!docOnly) { addMemberToList(MemberListType_decVarMembers,md); } addMemberToList(MemberListType_docVarMembers,md); break; - case MemberType_Function: + case MemberType_Function: if (!docOnly) { addMemberToList(MemberListType_decFuncMembers,md); } addMemberToList(MemberListType_docFuncMembers,md); break; - case MemberType_Typedef: + case MemberType_Typedef: if (!docOnly) { addMemberToList(MemberListType_decTypedefMembers,md); } addMemberToList(MemberListType_docTypedefMembers,md); break; - case MemberType_Enumeration: + case MemberType_Enumeration: if (!docOnly) { addMemberToList(MemberListType_decEnumMembers,md); } addMemberToList(MemberListType_docEnumMembers,md); break; - case MemberType_EnumValue: + case MemberType_EnumValue: if (!docOnly) { addMemberToList(MemberListType_decEnumValMembers,md); } addMemberToList(MemberListType_docEnumValMembers,md); break; - case MemberType_Define: + case MemberType_Define: if (!docOnly) { addMemberToList(MemberListType_decDefineMembers,md); } addMemberToList(MemberListType_docDefineMembers,md); break; - case MemberType_Signal: + case MemberType_Signal: if (!docOnly) { addMemberToList(MemberListType_decSignalMembers,md); } addMemberToList(MemberListType_docSignalMembers,md); break; - case MemberType_Slot: + case MemberType_Slot: if (md->protection()==Public) { if (!docOnly) @@ -505,21 +505,21 @@ bool GroupDefImpl::insertMember(MemberDef *md,bool docOnly) addMemberToList(MemberListType_docPriSlotMembers,md); } break; - case MemberType_Event: + case MemberType_Event: if (!docOnly) { addMemberToList(MemberListType_decEventMembers,md); } addMemberToList(MemberListType_docEventMembers,md); break; - case MemberType_Property: + case MemberType_Property: if (!docOnly) { addMemberToList(MemberListType_decPropMembers,md); } addMemberToList(MemberListType_docPropMembers,md); break; - case MemberType_Friend: + case MemberType_Friend: if (!docOnly) { addMemberToList(MemberListType_decFriendMembers,md); @@ -564,31 +564,31 @@ void GroupDefImpl::removeMember(MemberDef *md) removeMemberFromList(MemberListType_decVarMembers,md); removeMemberFromList(MemberListType_docVarMembers,md); break; - case MemberType_Function: + case MemberType_Function: removeMemberFromList(MemberListType_decFuncMembers,md); removeMemberFromList(MemberListType_docFuncMembers,md); break; - case MemberType_Typedef: + case MemberType_Typedef: removeMemberFromList(MemberListType_decTypedefMembers,md); removeMemberFromList(MemberListType_docTypedefMembers,md); break; - case MemberType_Enumeration: + case MemberType_Enumeration: removeMemberFromList(MemberListType_decEnumMembers,md); removeMemberFromList(MemberListType_docEnumMembers,md); break; - case MemberType_EnumValue: + case MemberType_EnumValue: removeMemberFromList(MemberListType_decEnumValMembers,md); removeMemberFromList(MemberListType_docEnumValMembers,md); break; - case MemberType_Define: + case MemberType_Define: removeMemberFromList(MemberListType_decDefineMembers,md); removeMemberFromList(MemberListType_docDefineMembers,md); break; - case MemberType_Signal: + case MemberType_Signal: removeMemberFromList(MemberListType_decSignalMembers,md); removeMemberFromList(MemberListType_docSignalMembers,md); break; - case MemberType_Slot: + case MemberType_Slot: if (md->protection()==Public) { removeMemberFromList(MemberListType_decPubSlotMembers,md); @@ -605,15 +605,15 @@ void GroupDefImpl::removeMember(MemberDef *md) removeMemberFromList(MemberListType_docPriSlotMembers,md); } break; - case MemberType_Event: + case MemberType_Event: removeMemberFromList(MemberListType_decEventMembers,md); removeMemberFromList(MemberListType_docEventMembers,md); break; - case MemberType_Property: + case MemberType_Property: removeMemberFromList(MemberListType_decPropMembers,md); removeMemberFromList(MemberListType_docPropMembers,md); break; - case MemberType_Friend: + case MemberType_Friend: removeMemberFromList(MemberListType_decFriendMembers,md); removeMemberFromList(MemberListType_docFriendMembers,md); break; @@ -691,7 +691,7 @@ int GroupDefImpl::numDocMembers() const m_exampleDict->count(); } -/*! Compute the HTML anchor names for all members in the group */ +/*! Compute the HTML anchor names for all members in the group */ void GroupDefImpl::computeAnchors() { //printf("GroupDefImpl::computeAnchors()\n"); @@ -843,7 +843,7 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) void GroupDefImpl::writeDetailedDescription(OutputList &ol,const QCString &title) { - if ((!briefDescription().isEmpty() && Config_getBool(REPEAT_BRIEF)) + if ((!briefDescription().isEmpty() && Config_getBool(REPEAT_BRIEF)) || !documentation().isEmpty() || !inbodyDocumentation().isEmpty() ) { @@ -1183,7 +1183,7 @@ void GroupDefImpl::writeSummaryLinks(OutputList &ol) const SrcLangExt lang = getLanguage(); for (eli.toFirst();(lde=eli.current());++eli) { - if ((lde->kind()==LayoutDocEntry::GroupClasses && m_classSDict->declVisible()) || + if ((lde->kind()==LayoutDocEntry::GroupClasses && m_classSDict->declVisible()) || (lde->kind()==LayoutDocEntry::GroupNamespaces && m_namespaceSDict->declVisible()) || (lde->kind()==LayoutDocEntry::GroupFiles && m_fileList->count()>0) || (lde->kind()==LayoutDocEntry::GroupNestedGroups && m_groupList->count()>0) || @@ -1191,7 +1191,7 @@ void GroupDefImpl::writeSummaryLinks(OutputList &ol) const ) { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; - QCString label = lde->kind()==LayoutDocEntry::GroupClasses ? "nested-classes" : + QCString label = lde->kind()==LayoutDocEntry::GroupClasses ? "nested-classes" : lde->kind()==LayoutDocEntry::GroupNamespaces ? "namespaces" : lde->kind()==LayoutDocEntry::GroupFiles ? "files" : lde->kind()==LayoutDocEntry::GroupNestedGroups ? "groups" : @@ -1266,84 +1266,84 @@ void GroupDefImpl::writeDocumentation(OutputList &ol) { switch (lde->kind()) { - case LayoutDocEntry::BriefDesc: + case LayoutDocEntry::BriefDesc: writeBriefDescription(ol); - break; - case LayoutDocEntry::MemberDeclStart: + break; + case LayoutDocEntry::MemberDeclStart: startMemberDeclarations(ol); - break; - case LayoutDocEntry::GroupClasses: + break; + case LayoutDocEntry::GroupClasses: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; writeClasses(ol,ls->title(lang)); } - break; - case LayoutDocEntry::GroupInlineClasses: + break; + case LayoutDocEntry::GroupInlineClasses: { writeInlineClasses(ol); } break; - case LayoutDocEntry::GroupNamespaces: + case LayoutDocEntry::GroupNamespaces: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; writeNamespaces(ol,ls->title(lang)); } - break; - case LayoutDocEntry::MemberGroups: + break; + case LayoutDocEntry::MemberGroups: writeMemberGroups(ol); - break; - case LayoutDocEntry::MemberDecl: + break; + case LayoutDocEntry::MemberDecl: { LayoutDocEntryMemberDecl *lmd = (LayoutDocEntryMemberDecl*)lde; writeMemberDeclarations(ol,lmd->type,lmd->title(lang)); } - break; - case LayoutDocEntry::MemberDeclEnd: + break; + case LayoutDocEntry::MemberDeclEnd: endMemberDeclarations(ol); break; - case LayoutDocEntry::DetailedDesc: + case LayoutDocEntry::DetailedDesc: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; writeDetailedDescription(ol,ls->title(lang)); } break; - case LayoutDocEntry::MemberDefStart: + case LayoutDocEntry::MemberDefStart: startMemberDocumentation(ol); - break; - case LayoutDocEntry::MemberDef: + break; + case LayoutDocEntry::MemberDef: { LayoutDocEntryMemberDef *lmd = (LayoutDocEntryMemberDef*)lde; writeMemberDocumentation(ol,lmd->type,lmd->title(lang)); } break; - case LayoutDocEntry::MemberDefEnd: + case LayoutDocEntry::MemberDefEnd: endMemberDocumentation(ol); break; - case LayoutDocEntry::GroupNestedGroups: + case LayoutDocEntry::GroupNestedGroups: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; writeNestedGroups(ol,ls->title(lang)); } break; - case LayoutDocEntry::GroupPageDocs: + case LayoutDocEntry::GroupPageDocs: writePageDocumentation(ol); break; - case LayoutDocEntry::GroupDirs: + case LayoutDocEntry::GroupDirs: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; writeDirs(ol,ls->title(lang)); } break; - case LayoutDocEntry::GroupFiles: + case LayoutDocEntry::GroupFiles: { LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde; writeFiles(ol,ls->title(lang)); } break; - case LayoutDocEntry::GroupGraph: + case LayoutDocEntry::GroupGraph: writeGroupGraph(ol); break; - case LayoutDocEntry::AuthorSection: + case LayoutDocEntry::AuthorSection: writeAuthorSection(ol); break; case LayoutDocEntry::ClassIncludes: @@ -1368,7 +1368,7 @@ void GroupDefImpl::writeDocumentation(OutputList &ol) case LayoutDocEntry::FileConstantGroups: case LayoutDocEntry::FileIncludes: case LayoutDocEntry::FileIncludeGraph: - case LayoutDocEntry::FileIncludedByGraph: + case LayoutDocEntry::FileIncludedByGraph: case LayoutDocEntry::FileSourceLink: case LayoutDocEntry::FileInlineClasses: case LayoutDocEntry::DirSubDirs: @@ -1382,7 +1382,7 @@ void GroupDefImpl::writeDocumentation(OutputList &ol) //---------------------------------------- end flexible part ------------------------------- - endFile(ol); + endFile(ol); ol.popGeneratorState(); @@ -1398,7 +1398,7 @@ void GroupDefImpl::writeMemberPages(OutputList &ol) { ol.pushGeneratorState(); ol.disableAllBut(OutputGenerator::Html); - + QListIterator mli(m_memberLists); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) @@ -1462,7 +1462,7 @@ void addClassToGroups(const Entry *root,ClassDef *cd) GroupDef *gd=0; if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { - if (gd->addClass(cd)) + if (gd->addClass(cd)) { cd->makePartOfGroup(gd); } @@ -1532,7 +1532,7 @@ void addGroupToGroups(const Entry *root,GroupDef *subGroup) /*! Add a member to the group with the highest priority */ void addMemberToGroups(const Entry *root,MemberDef *md) { - //printf("addMemberToGroups: Root %p = %s, md %p=%s groups=%d\n", + //printf("addMemberToGroups: Root %p = %s, md %p=%s groups=%d\n", // root, root->name.data(), md, md->name().data(), root->groups->count() ); // Search entry's group list for group with highest pri. @@ -1545,7 +1545,7 @@ void addMemberToGroups(const Entry *root,MemberDef *md) (gd=Doxygen::groupSDict->find(g.groupname)) && g.pri >= pri) { - if (fgd && gd!=fgd && g.pri==pri) + if (fgd && gd!=fgd && g.pri==pri) { warn(root->fileName.data(), root->startLine, "Member %s found in multiple %s groups! " @@ -1575,7 +1575,7 @@ void addMemberToGroups(const Entry *root,MemberDef *md) { bool moveit = FALSE; - // move member from one group to another if + // move member from one group to another if // - the new one has a higher priority // - the new entry has the same priority, but with docs where the old one had no docs if (md->getGroupPri()setGroupDef(fgd,pri,root->fileName,root->startLine, !root->doc.isEmpty()); ClassDef *cd = md->getClassDefOfAnonymousType(); - if (cd) + if (cd) { cd->setGroupDefForAllMembers(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0); } @@ -1741,12 +1741,12 @@ void GroupDefImpl::writeMemberDeclarations(OutputList &ol,MemberListType lt,cons static bool optimizeVhdl = Config_getBool(OPTIMIZE_OUTPUT_VHDL); MemberList * ml = getMemberList(lt); - if (optimizeVhdl && ml) + if (optimizeVhdl && ml) { VhdlDocGen::writeVhdlDeclarations(ml,ol,this,0,0,0); return; } - if (ml) + if (ml) { ml->writeDeclarations(ol,0,0,0,this,title,0); } @@ -1761,12 +1761,12 @@ void GroupDefImpl::writeMemberDocumentation(OutputList &ol,MemberListType lt,con void GroupDefImpl::removeMemberFromList(MemberListType lt,MemberDef *md) { MemberList *ml = getMemberList(lt); - if (ml) ml->remove(md); + if (ml) ml->remove(md); } -void GroupDefImpl::sortSubGroups() -{ - m_groupList->sort(); +void GroupDefImpl::sortSubGroups() +{ + m_groupList->sort(); } bool GroupDefImpl::isLinkableInProject() const diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index b157881..7458b23 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -686,7 +686,7 @@ void HtmlCodeGenerator::codify(const char *str) void HtmlCodeGenerator::docify(const char *str) { - m_t << getHtmlDirEmbeddingChar(getTextDirByConfig(str)); + //m_t << getHtmlDirEmbeddingChar(getTextDirByConfig(str)); if (str && m_streamSet) { diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 39b8f70..7672599 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -93,7 +93,7 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual int getGroupStartLine() const; virtual bool getGroupHasDocs() const; virtual QCString qualifiedName() const; - virtual QCString objCMethodName(bool localLink,bool showStatic) const; + virtual QCString objCMethodName(bool localLink,bool showStatic) const; virtual Protection protection() const; virtual Specifier virtualness(int count=0) const; virtual MemberType memberType() const; @@ -275,8 +275,8 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual void setPrototype(bool p,const QCString &df,int line, int column); virtual void setExplicitExternal(bool b,const QCString &df,int line,int column); virtual void setDeclFile(const QCString &df,int line,int column); - virtual void setArgumentList(const ArgumentList &al); - virtual void setDeclArgumentList(const ArgumentList &al); + virtual void moveArgumentList(std::unique_ptr al); + virtual void moveDeclArgumentList(std::unique_ptr al); virtual void setDefinitionTemplateParameterLists(const std::vector &lists); virtual void setTypeConstraints(const ArgumentList &al); virtual void setType(const char *t); @@ -324,7 +324,7 @@ class MemberDefImpl : public DefinitionImpl, public MemberDef virtual void warnIfUndocumentedParams() const; virtual void detectUndocumentedParams(bool hasParamCommand,bool hasReturnCommand) const; virtual MemberDef *createTemplateInstanceMember(const ArgumentList &formalArgs, - const ArgumentList &actualArgs) const; + const std::unique_ptr &actualArgs) const; virtual void findSectionsInDocumentation(); virtual void writeLink(OutputList &ol, const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd, @@ -378,7 +378,7 @@ MemberDef *createMemberDef(const char *defFileName,int defLine,int defColumn, class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef { public: - MemberDefAliasImpl(const Definition *newScope,const MemberDef *md) + MemberDefAliasImpl(const Definition *newScope,const MemberDef *md) : DefinitionAliasImpl(newScope,md), m_memberGroup(0) {} virtual ~MemberDefAliasImpl() {} virtual DefType definitionType() const { return TypeMember; } @@ -787,8 +787,8 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual void setPrototype(bool p,const QCString &df,int line, int column) {} virtual void setExplicitExternal(bool b,const QCString &df,int line,int column) {} virtual void setDeclFile(const QCString &df,int line,int column) {} - virtual void setArgumentList(const ArgumentList &al) {} - virtual void setDeclArgumentList(const ArgumentList &al) {} + virtual void moveArgumentList(std::unique_ptr al) {} + virtual void moveDeclArgumentList(std::unique_ptr al) {} virtual void setDefinitionTemplateParameterLists(const std::vector &lists) {} virtual void setTypeConstraints(const ArgumentList &al) {} virtual void setType(const char *t) {} @@ -823,7 +823,7 @@ class MemberDefAliasImpl : public DefinitionAliasImpl, public MemberDef virtual void addToSearchIndex() const {} virtual void findSectionsInDocumentation() {} virtual MemberDef *createTemplateInstanceMember(const ArgumentList &formalArgs, - const ArgumentList &actualArgs) const + const std::unique_ptr &actualArgs) const { return getMdAlias()->createTemplateInstanceMember(formalArgs,actualArgs); } virtual void incrementFlowKeyWordCount() {} @@ -1478,7 +1478,7 @@ void MemberDefImpl::IMPL::init(Definition *d, // convert function declaration arguments (if any) if (!args.isEmpty()) { - stringToArgumentList(d->getLanguage(),args,declArgList,&extraTypeChars); + declArgList = *stringToArgumentList(d->getLanguage(),args,&extraTypeChars); //printf("setDeclArgList %s to %s const=%d\n",args.data(), // argListToString(declArgList).data(),declArgList->constSpecifier); } @@ -2534,7 +2534,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, ol.docify(" [implementation]"); ol.endTypewriter(); } - + bool extractPrivate = Config_getBool(EXTRACT_PRIVATE); if (isProperty() && (isSettable() || isGettable() || @@ -2545,7 +2545,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, ol.startTypewriter(); ol.docify(" ["); QStrList sl; - + if (isGettable()) sl.append("get"); if (isProtectedGettable()) sl.append("protected get"); if (isSettable()) sl.append("set"); @@ -4143,7 +4143,7 @@ void MemberDefImpl::detectUndocumentedParams(bool hasParamCommand,bool hasReturn warn_doc_error(getDefFileName(),getDefLine(),"documented empty return type of %s", qualifiedName().data()); } - else if ( // see if return needs to documented + else if ( // see if return needs to documented m_impl->hasDocumentedReturnType || isVoidReturn || // void return type isFortranSubroutine || // fortran subroutine @@ -4328,21 +4328,25 @@ void MemberDefImpl::setNamespace(NamespaceDef *nd) } MemberDef *MemberDefImpl::createTemplateInstanceMember( - const ArgumentList &formalArgs,const ArgumentList &actualArgs) const + const ArgumentList &formalArgs,const std::unique_ptr &actualArgs) const { //printf(" Member %s %s %s\n",typeString(),name().data(),argsString()); - ArgumentList actualArgList; + std::unique_ptr actualArgList; if (!m_impl->defArgList.empty()) { - actualArgList = m_impl->defArgList; + actualArgList = std::make_unique(m_impl->defArgList); // replace formal arguments with actuals - for (Argument &arg : actualArgList) + for (Argument &arg : *actualArgList) { arg.type = substituteTemplateArgumentsInString(arg.type,formalArgs,actualArgs); } - actualArgList.trailingReturnType = - substituteTemplateArgumentsInString(actualArgList.trailingReturnType,formalArgs,actualArgs); + actualArgList->trailingReturnType = + substituteTemplateArgumentsInString(actualArgList->trailingReturnType,formalArgs,actualArgs); + } + else + { + actualArgList = std::make_unique(); } QCString methodName=name(); @@ -4357,10 +4361,10 @@ MemberDef *MemberDefImpl::createTemplateInstanceMember( methodName, substituteTemplateArgumentsInString(m_impl->args,formalArgs,actualArgs), m_impl->exception, m_impl->prot, - m_impl->virt, m_impl->stat, m_impl->related, m_impl->mtype, + m_impl->virt, m_impl->stat, m_impl->related, m_impl->mtype, ArgumentList(), ArgumentList(), "" ); - imd->setArgumentList(actualArgList); + imd->moveArgumentList(std::move(actualArgList)); imd->setDefinition(substituteTemplateArgumentsInString(m_impl->def,formalArgs,actualArgs)); imd->setBodyDef(getBodyDef()); imd->setBodySegment(getDefLine(),getStartBodyLine(),getEndBodyLine()); @@ -4789,14 +4793,14 @@ void MemberDefImpl::writeEnumDeclaration(OutputList &typeDecl, } } -void MemberDefImpl::setArgumentList(const ArgumentList &al) +void MemberDefImpl::moveArgumentList(std::unique_ptr al) { - m_impl->defArgList = al; + m_impl->defArgList = *al; } -void MemberDefImpl::setDeclArgumentList(const ArgumentList &al) +void MemberDefImpl::moveDeclArgumentList(std::unique_ptr al) { - m_impl->declArgList = al; + m_impl->declArgList = *al; } void MemberDefImpl::setTypeConstraints(const ArgumentList &al) @@ -5956,8 +5960,8 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) const MemberDef *cmdef = const_cast(mdef); ArgumentList &mdefAl = mdef->argumentList(); ArgumentList &mdecAl = mdec->argumentList(); - if (matchArguments2(cmdef->getOuterScope(),cmdef->getFileDef(),mdefAl, - cmdec->getOuterScope(),cmdec->getFileDef(),mdecAl, + if (matchArguments2(cmdef->getOuterScope(),cmdef->getFileDef(),&mdefAl, + cmdec->getOuterScope(),cmdec->getFileDef(),&mdecAl, TRUE ) ) /* match found */ @@ -5987,10 +5991,9 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) mdec->setDocsForDefinition(mdef->isDocsForDefinition()); if (mdefAl.hasParameters()) { - ArgumentList mdefAlComb; - stringToArgumentList(mdef->getLanguage(),mdef->argsString(),mdefAlComb); - transferArgumentDocumentation(mdefAl,mdefAlComb); - mdec->setArgumentList(mdefAlComb); + auto mdefAlComb = stringToArgumentList(mdef->getLanguage(),mdef->argsString()); + transferArgumentDocumentation(mdefAl,*mdefAlComb); + mdec->moveArgumentList(std::move(mdefAlComb)); } } else if (!mdec->documentation().isEmpty()) @@ -6000,10 +6003,9 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) mdef->setDocsForDefinition(mdec->isDocsForDefinition()); if (mdecAl.hasParameters()) { - ArgumentList mdecAlComb; - stringToArgumentList(mdec->getLanguage(),mdec->argsString(),mdecAlComb); - transferArgumentDocumentation(mdecAl,mdecAlComb); - mdef->setDeclArgumentList(mdecAlComb); + auto mdecAlComb = stringToArgumentList(mdec->getLanguage(),mdec->argsString()); + transferArgumentDocumentation(mdecAl,*mdecAlComb); + mdef->moveDeclArgumentList(std::move(mdecAlComb)); } } if (!mdef->inbodyDocumentation().isEmpty()) diff --git a/src/memberdef.h b/src/memberdef.h index a9103e1..4deb04a 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -19,6 +19,7 @@ #define MEMBERDEF_H #include +#include #include #include @@ -93,16 +94,16 @@ class MemberDef : virtual public Definition // grabbing the property read/write accessor names virtual const char *getReadAccessor() const = 0; virtual const char *getWriteAccessor() const = 0; - + // querying the grouping definition virtual Grouping::GroupPri_t getGroupPri() const = 0; virtual const char *getGroupFileName() const = 0; virtual int getGroupStartLine() const = 0; virtual bool getGroupHasDocs() const = 0; virtual QCString qualifiedName() const = 0; - virtual QCString objCMethodName(bool localLink,bool showStatic) const = 0; + virtual QCString objCMethodName(bool localLink,bool showStatic) const = 0; - // direct kind info + // direct kind info virtual Protection protection() const = 0; virtual Specifier virtualness(int count=0) const = 0; virtual MemberType memberType() const = 0; @@ -326,15 +327,15 @@ class MemberDef : virtual public Definition // example related members virtual bool addExample(const char *anchor,const char *name,const char *file) = 0; - + // prototype related members virtual void setPrototype(bool p,const QCString &df,int line, int column) = 0; virtual void setExplicitExternal(bool b,const QCString &df,int line,int column) = 0; virtual void setDeclFile(const QCString &df,int line,int column) = 0; // argument related members - virtual void setArgumentList(const ArgumentList &al) = 0; - virtual void setDeclArgumentList(const ArgumentList &al) = 0; + virtual void moveArgumentList(std::unique_ptr al) = 0; + virtual void moveDeclArgumentList(std::unique_ptr al) = 0; virtual void setDefinitionTemplateParameterLists(const std::vector &lists) = 0; virtual void setTypeConstraints(const ArgumentList &al) = 0; virtual void setType(const char *t) = 0; @@ -387,7 +388,7 @@ class MemberDef : virtual public Definition //----------------------------------------------------------------------------------- virtual MemberDef *createTemplateInstanceMember(const ArgumentList &formalArgs, - const ArgumentList &actualArgs) const = 0; + const std::unique_ptr &actualArgs) const = 0; virtual void findSectionsInDocumentation() = 0; virtual void addToSearchIndex() const = 0; diff --git a/src/pre.l b/src/pre.l index 351511b..e83a204 100644 --- a/src/pre.l +++ b/src/pre.l @@ -2805,10 +2805,8 @@ static void addDefine(yyscan_t yyscanner) Public,Normal,FALSE,Member,MemberType_Define,ArgumentList(),ArgumentList(),"") }; if (!state->defArgsStr.isEmpty()) { - ArgumentList argList; //printf("addDefine() state->defName='%s' state->defArgsStr='%s'\n",state->defName.data(),state->defArgsStr.data()); - stringToArgumentList(SrcLangExt_Cpp, state->defArgsStr,argList); - md->setArgumentList(argList); + md->moveArgumentList(stringToArgumentList(SrcLangExt_Cpp, state->defArgsStr)); } //printf("Setting initializer for '%s' to '%s'\n",state->defName.data(),state->defText.data()); int l=state->defLitText.find('\n'); diff --git a/src/scanner.l b/src/scanner.l index 25109bc..e25d268 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -4219,7 +4219,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) ")" { *yyextra->copyArgString+=*yytext; yyextra->fullArgString+=*yytext; - stringToArgumentList(yyextra->language, yyextra->fullArgString,yyextra->current->argList); + yyextra->current->argList = *stringToArgumentList(yyextra->language, yyextra->fullArgString); if (yyextra->insideJS) { fixArgumentListForJavaScript(yyextra->current->argList); @@ -4246,7 +4246,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { unput(yytext[i]); } - stringToArgumentList(yyextra->language, yyextra->fullArgString,yyextra->current->argList); + yyextra->current->argList = *stringToArgumentList(yyextra->language, yyextra->fullArgString); handleParametersCommentBlocks(yyscanner,yyextra->current->argList); BEGIN( yyextra->currentArgumentContext ); } @@ -4299,7 +4299,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } *yyextra->copyArgString+=*yytext; yyextra->fullArgString+=*yytext; - stringToArgumentList(yyextra->language, yyextra->fullArgString,yyextra->current->argList); + yyextra->current->argList = *stringToArgumentList(yyextra->language, yyextra->fullArgString); handleParametersCommentBlocks(yyscanner,yyextra->current->argList); BEGIN( yyextra->currentArgumentContext ); } @@ -4380,7 +4380,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) *yyextra->copyArgString+=*yytext; yyextra->fullArgString+=*yytext; //printf("end template list '%s'\n",yyextra->copyArgString->data()); - stringToArgumentList(yyextra->language, yyextra->fullArgString,*yyextra->currentArgumentList); + *yyextra->currentArgumentList = *stringToArgumentList(yyextra->language, yyextra->fullArgString); BEGIN( yyextra->currentArgumentContext ); } "(" { diff --git a/src/tagreader.cpp b/src/tagreader.cpp index 3a35a27..12010e8 100644 --- a/src/tagreader.cpp +++ b/src/tagreader.cpp @@ -1190,7 +1190,7 @@ void TagFileParser::buildMemberList(const std::shared_ptr &ce,QListargs = tmi->arglist; if (!me->args.isEmpty()) { - stringToArgumentList(SrcLangExt_Cpp,me->args,me->argList); + me->argList = *stringToArgumentList(SrcLangExt_Cpp,me->args); } if (tmi->enumValues.count()>0) { diff --git a/src/util.cpp b/src/util.cpp index 6d6112e..4324ffd 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "md5.h" @@ -475,18 +476,7 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName, ClassDef *getClass(const char *n) { if (n==0 || n[0]=='\0') return 0; - QCString name=n; - ClassDef *result = Doxygen::classSDict->find(name); - //if (result==0 && !exact) // also try generic and protocol versions - //{ - // result = Doxygen::classSDict->find(name+"-g"); - // if (result==0) - // { - // result = Doxygen::classSDict->find(name+"-p"); - // } - //} - //printf("getClass(%s)=%s\n",n,result?result->name().data():""); - return result; + return Doxygen::classSDict->find(n); } NamespaceDef *getResolvedNamespace(const char *name) @@ -540,7 +530,7 @@ const ClassDef *newResolveTypedef(const FileDef *fileScope, const MemberDef **pMemType, QCString *pTemplSpec, QCString *pResolvedType, - const ArgumentList *actTemplParams) + const std::unique_ptr &actTemplParams) { //printf("newResolveTypedef(md=%p,cachedVal=%p)\n",md,md->getCachedTypedefVal()); bool isCached = md->isTypedefValCached(); // value already cached @@ -567,7 +557,7 @@ const ClassDef *newResolveTypedef(const FileDef *fileScope, actTemplParams && !actTemplParams->empty()) { type = substituteTemplateArgumentsInString(type, - typeClass->templateArguments(),*actTemplParams); + typeClass->templateArguments(),actTemplParams); } QCString typedefValue = type; int tl=type.length(); @@ -1218,7 +1208,7 @@ static void getResolvedSymbol(const Definition *scope, const FileDef *fileScope, Definition *d, const QCString &explicitScopePart, - ArgumentList *actTemplParams, + const std::unique_ptr &actTemplParams, int &minDistance, const ClassDef *&bestMatch, const MemberDef *&bestTypedef, @@ -1388,16 +1378,17 @@ static const ClassDef *getResolvedClassRec(const Definition *scope, ) { //printf("[getResolvedClassRec(%s,%s)\n",scope?scope->name().data():"",n); + if (n==0 || *n=='\0') return 0; QCString name; QCString explicitScopePart; QCString strippedTemplateParams; name=stripTemplateSpecifiersFromScope (removeRedundantWhiteSpace(n),TRUE, &strippedTemplateParams); - ArgumentList actTemplParams; + std::unique_ptr actTemplParams; if (!strippedTemplateParams.isEmpty()) // template part that was stripped { - stringToArgumentList(scope->getLanguage(),strippedTemplateParams,actTemplParams); + actTemplParams = stringToArgumentList(scope->getLanguage(),strippedTemplateParams); } int qualifierIndex = computeQualifiedIndex(name); @@ -1423,16 +1414,12 @@ static const ClassDef *getResolvedClassRec(const Definition *scope, // stripped from the key used in the symbolMap, so that is not needed here. if (di==0) { - //di = Doxygen::symbolMap->find(name+"-g"); - //if (di==0) - //{ - di = Doxygen::symbolMap->find(name+"-p"); - if (di==0) - { - //printf("no such symbol!\n"); - return 0; - } - //} + di = Doxygen::symbolMap->find(name+"-p"); + if (di==0) + { + //printf("no such symbol!\n"); + return 0; + } } //printf("found symbol!\n"); @@ -1515,7 +1502,7 @@ static const ClassDef *getResolvedClassRec(const Definition *scope, int count=0; for (dli.toFirst();(d=dli.current());++dli,++count) // foreach definition { - getResolvedSymbol(scope,fileScope,d,explicitScopePart,&actTemplParams, + getResolvedSymbol(scope,fileScope,d,explicitScopePart,actTemplParams, minDistance,bestMatch,bestTypedef,bestTemplSpec, bestResolvedType); } @@ -1524,7 +1511,7 @@ static const ClassDef *getResolvedClassRec(const Definition *scope, { //printf(" name is unique\n"); Definition *d = (Definition *)di; - getResolvedSymbol(scope,fileScope,d,explicitScopePart,&actTemplParams, + getResolvedSymbol(scope,fileScope,d,explicitScopePart,actTemplParams, minDistance,bestMatch,bestTypedef,bestTemplSpec, bestResolvedType); } @@ -3173,34 +3160,46 @@ static bool matchArgument2( // new algorithm for argument matching -bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList &inSrcAl, - const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList &inDstAl, +bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList *srcAl, + const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList *dstAl, bool checkCV) { ASSERT(srcScope!=0 && dstScope!=0); - ArgumentList srcAl = inSrcAl; - ArgumentList dstAl = inDstAl; + if (srcAl==0 || dstAl==0) + { + bool match = srcAl==dstAl; + if (match) + { + MATCH + return TRUE; + } + else + { + NOMATCH + return FALSE; + } + } // handle special case with void argument - if ( srcAl.empty() && dstAl.size()==1 && dstAl.front().type=="void" ) + if ( srcAl->empty() && dstAl->size()==1 && dstAl->front().type=="void" ) { // special case for finding match between func() and func(void) Argument a; a.type = "void"; - srcAl.push_back(a); + const_cast(srcAl)->push_back(a); MATCH return TRUE; } - if ( dstAl.empty() && srcAl.size()==1 && srcAl.front().type=="void" ) + if ( dstAl->empty() && srcAl->size()==1 && srcAl->front().type=="void" ) { // special case for finding match between func(void) and func() Argument a; a.type = "void"; - dstAl.push_back(a); + const_cast(dstAl)->push_back(a); MATCH return TRUE; } - if (srcAl.size() != dstAl.size()) + if (srcAl->size() != dstAl->size()) { NOMATCH return FALSE; // different number of arguments -> no match @@ -3208,19 +3207,19 @@ bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,cons if (checkCV) { - if (srcAl.constSpecifier != dstAl.constSpecifier) + if (srcAl->constSpecifier != dstAl->constSpecifier) { NOMATCH return FALSE; // one member is const, the other not -> no match } - if (srcAl.volatileSpecifier != dstAl.volatileSpecifier) + if (srcAl->volatileSpecifier != dstAl->volatileSpecifier) { NOMATCH return FALSE; // one member is volatile, the other not -> no match } } - if (srcAl.refQualifier != dstAl.refQualifier) + if (srcAl->refQualifier != dstAl->refQualifier) { NOMATCH return FALSE; // one member is has a different ref-qualifier than the other @@ -3228,12 +3227,12 @@ bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,cons // so far the argument list could match, so we need to compare the types of // all arguments. - auto srcIt = srcAl.begin(); - auto dstIt = dstAl.begin(); - for (;srcIt!=srcAl.end() && dstIt!=dstAl.end();++srcIt,++dstIt) + auto srcIt = srcAl->begin(); + auto dstIt = dstAl->begin(); + for (;srcIt!=srcAl->end() && dstIt!=dstAl->end();++srcIt,++dstIt) { - Argument &srcA = *srcIt; - Argument &dstA = *dstIt; + Argument &srcA = const_cast(*srcIt); + Argument &dstA = const_cast(*dstIt); if (!matchArgument2(srcScope,srcFileScope,srcA, dstScope,dstFileScope,dstA) ) @@ -3413,11 +3412,10 @@ static void findMembersWithSpecificName(MemberName *mn, if (args && !md->isDefine() && qstrcmp(args,"()")!=0) { const ArgumentList &mdAl = md->argumentList(); - ArgumentList argList; - stringToArgumentList(md->getLanguage(),args,argList); + auto argList_p = stringToArgumentList(md->getLanguage(),args); match=matchArguments2( - md->getOuterScope(),fd,mdAl, - Doxygen::globalScope,fd,argList, + md->getOuterScope(),fd,&mdAl, + Doxygen::globalScope,fd,argList_p.get(), checkCV); } if (match && (forceTagFile==0 || md->getReference()==forceTagFile)) @@ -3540,10 +3538,10 @@ bool getDefs(const QCString &scName, { //printf(" Found fcd=%p\n",fcd); int mdist=maxInheritanceDepth; - ArgumentList argList; + std::unique_ptr argList; if (args) { - stringToArgumentList(fcd->getLanguage(),args,argList); + argList = stringToArgumentList(fcd->getLanguage(),args); } for (const auto &mmd : *mn) { @@ -3551,8 +3549,8 @@ bool getDefs(const QCString &scName, { const ArgumentList &mmdAl = mmd->argumentList(); bool match=args==0 || - matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),mmdAl, - fcd, fcd->getFileDef(),argList, + matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),&mmdAl, + fcd, fcd->getFileDef(),argList.get(), checkCV); //printf("match=%d\n",match); if (match) @@ -3656,12 +3654,12 @@ bool getDefs(const QCString &scName, { //printf("Global symbol\n"); MemberDef *fuzzy_mmd = 0; - ArgumentList argList; + std::unique_ptr argList; bool hasEmptyArgs = args && qstrcmp(args, "()") == 0; if (args) { - stringToArgumentList(SrcLangExt_Cpp, args, argList); + argList = stringToArgumentList(SrcLangExt_Cpp, args); } for (const auto &mmd : *mn) @@ -3679,8 +3677,8 @@ bool getDefs(const QCString &scName, } ArgumentList &mmdAl = mmd->argumentList(); - if (matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),mmdAl, - Doxygen::globalScope,mmd->getFileDef(),argList, + if (matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),&mmdAl, + Doxygen::globalScope,mmd->getFileDef(),argList.get(), checkCV ) ) @@ -3759,14 +3757,13 @@ bool getDefs(const QCString &scName, else if (mmd->getOuterScope()==fnd /* && mmd->isLinkable() */ ) { // namespace is found bool match=TRUE; - ArgumentList argList; if (args && qstrcmp(args,"()")!=0) { const ArgumentList &mmdAl = mmd->argumentList(); - stringToArgumentList(mmd->getLanguage(),args,argList); + auto argList_p = stringToArgumentList(mmd->getLanguage(),args); match=matchArguments2( - mmd->getOuterScope(),mmd->getFileDef(),mmdAl, - fnd,mmd->getFileDef(),argList, + mmd->getOuterScope(),mmd->getFileDef(),&mmdAl, + fnd,mmd->getFileDef(),argList_p.get(), checkCV); } if (match) @@ -5868,7 +5865,7 @@ QCString normalizeNonTemplateArgumentsInString( QCString substituteTemplateArgumentsInString( const QCString &name, const ArgumentList &formalArgs, - const ArgumentList &actualArgs) + const std::unique_ptr &actualArgs) { //printf("substituteTemplateArgumentsInString(name=%s formal=%s actualArg=%s)\n", // name.data(),argListToString(formalArgs).data(),argListToString(actualArgs).data()); @@ -5881,7 +5878,11 @@ QCString substituteTemplateArgumentsInString( { result += name.mid(p,i-p); QCString n = name.mid(i,l); - auto actIt = actualArgs.begin(); + ArgumentList::iterator actIt; + if (actualArgs) + { + actIt = actualArgs->begin(); + } // if n is a template argument, then we substitute it // for its template instance argument. @@ -5893,7 +5894,7 @@ QCString substituteTemplateArgumentsInString( { Argument formArg = *formIt; Argument actArg; - if (actIt!=actualArgs.end()) + if (actualArgs && actIt!=actualArgs->end()) { actArg = *actIt; } @@ -5914,7 +5915,7 @@ QCString substituteTemplateArgumentsInString( //printf(">> n='%s' formArg->name='%s' actArg->type='%s' actArg->name='%s'\n", // n.data(),formArg.name.data(),actIt!=actualArgs.end() ? actIt->type.data() : "",actIt!=actualArgs.end() ? actIt->name.data() : "" // ); - if (formArg.name==n && actIt!=actualArgs.end() && !actArg.type.isEmpty()) // base class is a template argument + if (formArg.name==n && actualArgs && actIt!=actualArgs->end() && !actArg.type.isEmpty()) // base class is a template argument { // replace formal argument with the actual argument of the instance if (!leftScopeMatch(actArg.type,n)) @@ -5939,7 +5940,7 @@ QCString substituteTemplateArgumentsInString( } } else if (formArg.name==n && - actIt==actualArgs.end() && + (actualArgs==nullptr || actIt==actualArgs->end()) && !formArg.defval.isEmpty() && formArg.defval!=name /* to prevent recursion */ ) @@ -5949,7 +5950,7 @@ QCString substituteTemplateArgumentsInString( } } else if (formArg.name==n && - actIt==actualArgs.end() && + (actualArgs==nullptr || actIt==actualArgs->end()) && !formArg.defval.isEmpty() && formArg.defval!=name /* to prevent recursion */ ) @@ -5957,7 +5958,7 @@ QCString substituteTemplateArgumentsInString( result += substituteTemplateArgumentsInString(formArg.defval,formalArgs,actualArgs)+" "; found=TRUE; } - if (actIt!=actualArgs.end()) + if (actualArgs && actIt!=actualArgs->end()) { actIt++; } @@ -5986,10 +5987,11 @@ QCString stripTemplateSpecifiersFromScope(const QCString &fullName, bool parentOnly, QCString *pLastScopeStripped) { + int i=fullName.find('<'); + if (i==-1) return fullName; QCString result; int p=0; int l=fullName.length(); - int i=fullName.find('<'); while (i!=-1) { //printf("1:result+=%s\n",fullName.mid(p,i-p).data()); @@ -6588,7 +6590,9 @@ bool checkExtension(const char *fName, const char *ext) QCString addHtmlExtensionIfMissing(const char *fName) { - if (QFileInfo(fName).extension(FALSE).isEmpty()) + if (fName==0) return fName; + const char *p = strchr(fName,'.'); + if (p) { return QCString(fName)+Doxygen::htmlFileExtension; } diff --git a/src/util.h b/src/util.h index 98223b1..7518330 100644 --- a/src/util.h +++ b/src/util.h @@ -22,6 +22,8 @@ * \brief A bunch of utility functions. */ +#include + #include #include #include "types.h" @@ -184,8 +186,8 @@ void writePageRef(OutputDocInterface &od,const char *cn,const char *mn); QCString getCanonicalTemplateSpec(const Definition *d,const FileDef *fs,const QCString& spec); -bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList &srcAl, - const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList &dstAl, +bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList *srcAl, + const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList *dstAl, bool checkCV ); @@ -308,7 +310,7 @@ QCString normalizeNonTemplateArgumentsInString( QCString substituteTemplateArgumentsInString( const QCString &name, const ArgumentList &formalArgs, - const ArgumentList &actualArgs); + const std::unique_ptr &actualArgs); //QList *copyArgumentLists(const QList *srcLists); @@ -410,7 +412,7 @@ const ClassDef *newResolveTypedef(const FileDef *fileScope, const MemberDef **pMemType=0, QCString *pTemplSpec=0, QCString *pResolvedType=0, - const ArgumentList *actTemplParams=0); + const std::unique_ptr &actTemplParams=std::unique_ptr()); QCString parseCommentAsText(const Definition *scope,const MemberDef *member,const QCString &doc,const QCString &fileName,int lineNr); -- cgit v0.12