Doxygen
Loading...
Searching...
No Matches
doxygen.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2015 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16// own header
17#include "doxygen.h"
18
19// standard includes
20#include <algorithm>
21#include <cerrno>
22#include <chrono>
23#include <cinttypes>
24#include <clocale>
25#include <cstdio>
26#include <cstdlib>
27#include <locale>
28#include <memory>
29#include <sys/stat.h>
30#include <unordered_map>
31
32// other includes
33#include "aliases.h"
34#include "arguments.h"
35#include "cite.h"
36#include "clangparser.h"
37#include "classlist.h"
38#include "cmdmapper.h"
39#include "code.h"
40#include "commentcnv.h"
41#include "conceptdef.h"
42#include "config.h"
43#include "debug.h"
44#include "declinfo.h"
45#include "defargs.h"
46#include "defgen.h"
47#include "dir.h"
48#include "dirdef.h"
49#include "docbookgen.h"
50#include "docparser.h"
51#include "docsets.h"
52#include "dot.h"
53#include "eclipsehelp.h"
54#include "emoji.h"
55#include "entry.h"
56#include "fileinfo.h"
57#include "filename.h"
58#include "fileparser.h"
59#include "formula.h"
60#include "fortrancode.h"
61#include "fortranscanner.h"
62#include "ftvhelp.h"
63#include "groupdef.h"
64#include "htags.h"
65#include "htmlgen.h"
66#include "htmlhelp.h"
67#include "index.h"
68#include "indexlist.h"
69#include "language.h"
70#include "latexgen.h"
71#include "layout.h"
72#include "lexcode.h"
73#include "lexscanner.h"
74#include "mangen.h"
75#include "markdown.h"
76#include "membergroup.h"
77#include "memberlist.h"
78#include "membername.h"
79#include "mermaid.h"
80#include "message.h"
81#include "moduledef.h"
82#include "msc.h"
83#include "namespacedef.h"
84#include "outputlist.h"
85#include "pagedef.h"
86#include "parserintf.h"
87#include "perlmodgen.h"
88#include "plantuml.h"
89#include "portable.h"
90#include "pre.h"
91#include "pycode.h"
92#include "pyscanner.h"
93#include "qhp.h"
94#include "reflist.h"
95#include "regex.h"
96#include "requirement.h"
97#include "rtfgen.h"
98#include "scanner.h"
99#include "searchindex_js.h"
100#include "settings.h"
101#include "singlecomment.h"
102#include "sitemap.h"
103#include "sqlcode.h"
104#include "sqlite3gen.h"
105#include "stlsupport.h"
106#include "stringutil.h"
107#include "symbolresolver.h"
108#include "tagreader.h"
109#include "threadpool.h"
110#include "trace.h"
111#include "util.h"
112#include "version.h"
113#include "vhdlcode.h"
114#include "vhdldocgen.h"
115#include "vhdljjparser.h"
116#include "xmlcode.h"
117#include "xmlgen.h"
118
119#include <sqlite3.h>
120
121#if USE_LIBCLANG
122#if defined(__GNUC__)
123#pragma GCC diagnostic push
124#pragma GCC diagnostic ignored "-Wshadow"
125#endif
126#include <clang/Basic/Version.h>
127#if defined(__GNUC__)
128#pragma GCC diagnostic pop
129#endif
130#endif
131
132// provided by the generated file resources.cpp
133extern void initResources();
134
135#if !defined(_WIN32) || defined(__CYGWIN__)
136#include <signal.h>
137#define HAS_SIGNALS
138#endif
139
140// globally accessible variables
152FileNameLinkedMap *Doxygen::includeNameLinkedMap = nullptr; // include names
158FileNameLinkedMap *Doxygen::plantUmlFileNameLinkedMap = nullptr;// plantuml files
159FileNameLinkedMap *Doxygen::mermaidFileNameLinkedMap = nullptr; // mermaid files
161StringMap Doxygen::tagDestinationMap; // all tag locations
162StringUnorderedSet Doxygen::tagFileSet; // all tag file names
163StringUnorderedSet Doxygen::expandAsDefinedSet; // all macros that should be expanded
164MemberGroupInfoMap Doxygen::memberGroupInfoMap; // dictionary of the member groups heading
165std::unique_ptr<PageDef> Doxygen::mainPage;
166std::unique_ptr<NamespaceDef> Doxygen::globalNamespaceDef;
168bool Doxygen::parseSourcesNeeded = false;
186std::mutex Doxygen::addExampleMutex;
188
189// locally accessible globals
190static std::multimap< std::string, const Entry* > g_classEntries;
192static OutputList *g_outputList = nullptr; // list of output generating objects
193static StringSet g_usingDeclarations; // used classes
194static bool g_successfulRun = false;
195static bool g_dumpSymbolMap = false;
197static bool g_singleComment=false;
198
199
200
201// keywords recognized as compounds
203{ "template class", "template struct", "class", "struct", "record", "union", "interface", "exception" };
204
232
234{
235 public:
237 void begin(const char *name)
238 {
239 msg("{}", name);
240 stats.emplace_back(name,0);
241 startTime = std::chrono::steady_clock::now();
242 }
243 void end()
244 {
245 std::chrono::steady_clock::time_point endTime = std::chrono::steady_clock::now();
246 stats.back().elapsed = static_cast<double>(std::chrono::duration_cast<
247 std::chrono::microseconds>(endTime - startTime).count())/1000000.0;
248 warn_flush();
249 }
250 void print()
251 {
252 bool restore=false;
254 {
256 restore=true;
257 }
258 msg("----------------------\n");
259 for (const auto &s : stats)
260 {
261 msg("Spent {:.6f} seconds in {}",s.elapsed,s.name);
262 }
263 if (restore) Debug::setFlag(Debug::Time);
264 }
265 private:
266 struct stat
267 {
268 const char *name;
269 double elapsed;
270 //stat() : name(nullptr),elapsed(0) {}
271 stat(const char *n, double el) : name(n),elapsed(el) {}
272 };
273 std::vector<stat> stats;
274 std::chrono::steady_clock::time_point startTime;
276
277
278static void addMemberDocs(const Entry *root,MemberDefMutable *md, const DString &funcDecl,
279 const ArgumentList *al,bool over_load,TypeSpecifier spec);
280static void findMember(const Entry *root,
281 const DString &relates,
282 const DString &type,
283 const DString &args,
284 DString funcDecl,
285 bool overloaded,
286 bool isFunc
287 );
288
295
296
297static bool findClassRelation(
298 const Entry *root,
299 Definition *context,
300 ClassDefMutable *cd,
301 const BaseInfo *bi,
302 const TemplateNameMap &templateNames,
303 /*bool insertUndocumented*/
305 bool isArtificial
306 );
307
308//----------------------------------------------------------------------
309
310template<class Def>
311static void addIncludeFile(Def *def,FileDef *ifd,const Entry *root)
312{
313 AUTO_TRACE();
314 if (
315 (!root->doc.stripWhiteSpace().empty() ||
316 !root->brief.stripWhiteSpace().empty() ||
317 Config_getBool(EXTRACT_ALL)
318 ) && root->protection!=Protection::Private
319 )
320 {
321 AUTO_TRACE_ADD("includefile={}",root->includeFile);
322 //printf(">>>>>> includeFile=%s\n",qPrint(root->includeFile));
323
324 bool local=Config_getBool(FORCE_LOCAL_INCLUDES);
325 DString includeFile = root->includeFile;
326 if (!includeFile.empty() && includeFile.at(0)=='"')
327 {
328 local = true;
329 includeFile=includeFile.mid(1,includeFile.length()-2);
330 }
331 else if (!includeFile.empty() && includeFile.at(0)=='<')
332 {
333 local = false;
334 includeFile=includeFile.mid(1,includeFile.length()-2);
335 }
336
337 bool ambig = false;
338 FileDef *fd=nullptr;
339 // see if we need to include a verbatim copy of the header file
340 //printf("root->includeFile=%s\n",qPrint(root->includeFile));
341 if (!includeFile.empty() &&
342 (fd=Doxygen::inputNameLinkedMap->findFileDef(includeFile,ambig))==nullptr
343 )
344 { // explicit request
345 DString text;
346 text.sprintf("the name '%s' supplied as "
347 "the argument of the \\class, \\struct, \\record, \\union, or \\headerfile command ",
348 qPrint(includeFile)
349 );
350 if (ambig) // name is ambiguous
351 {
352 text+="matches the following input files:\n";
354 text+="\n";
355 text+="Please use a more specific name by "
356 "including a (larger) part of the path!";
357 }
358 else // name is not an input file
359 {
360 text+="is not an input file";
361 }
362 warn(root->fileName,root->startLine, "{}", text);
363 }
364 else if (includeFile.empty() && ifd &&
365 // see if the file extension makes sense
366 EntryType::guessSection(ifd->name()).isHeader())
367 { // implicit assumption
368 fd=ifd;
369 }
370
371 // if a file is found, we mark it as a source file.
372 if (fd)
373 {
374 DString iName = !root->includeName.empty() ?
375 root->includeName : includeFile;
376 if (!iName.empty()) // user specified include file
377 {
378 if (iName.at(0)=='<') local=false; // explicit override
379 else if (iName.at(0)=='"') local=true;
380 if (iName.at(0)=='"' || iName.at(0)=='<')
381 {
382 iName=iName.mid(1,iName.length()-2); // strip quotes or brackets
383 }
384 if (iName.empty())
385 {
386 iName=fd->name();
387 }
388 }
389 else if (!Config_getList(STRIP_FROM_INC_PATH).empty())
390 {
392 }
393 else // use name of the file containing the class definition
394 {
395 iName=fd->name();
396 }
397 AUTO_TRACE_ADD("iName={}",iName);
398 if (fd->generateSourceFile()) // generate code for header
399 {
400 def->setIncludeFile(fd,iName,local,!root->includeName.empty());
401 }
402 else // put #include in the class documentation without link
403 {
404 def->setIncludeFile(nullptr,iName,local,true);
405 }
406 }
407 }
408}
409
410
411//----------------------------------------------------------------------------
412
414 FileDef *fileScope,const TagInfo *tagInfo);
415static void resolveTemplateInstanceInType(const Entry *root,const Definition *scope,const MemberDef *md);
416
417static void addPageToContext(PageDef *pd,Entry *root)
418{
419 if (root->parent()) // add the page to it's scope
420 {
421 DString scope = root->parent()->name;
422 if (root->parent()->section.isPackageDoc())
423 {
424 scope=substitute(scope,".","::");
425 }
426 scope = stripAnonymousNamespaceScope(scope);
427 scope+="::"+pd->name();
429 if (d)
430 {
431 pd->setPageScope(d);
432 }
433 }
434}
435
436static void addRelatedPage(Entry *root)
437{
438 GroupDef *gd=nullptr;
439 for (const Grouping &g : root->groups)
440 {
441 if (!g.groupname.empty() && (gd=Doxygen::groupLinkedMap->find(g.groupname))) break;
442 }
443 //printf("---> addRelatedPage() %s gd=%p\n",qPrint(root->name),gd);
444 DString doc=root->doc+root->inbodyDocs;
445
446 PageDef *pd = addRelatedPage(root->name, // name
447 root->args, // ptitle
448 doc, // doc
449 root->docFile, // fileName
450 root->docLine, // docLine
451 root->startLine, // startLine
452 root->sli, // sli
453 gd, // gd
454 root->tagInfo(), // tagInfo
455 false, // xref
456 root->lang // lang
457 );
458 if (pd)
459 {
460 pd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
462 pd->setLocalToc(root->localToc);
463 addPageToContext(pd,root);
464 }
465}
466
467static void buildGroupListFiltered(const Entry *root,bool additional, bool includeExternal)
468{
469 if (root->section.isGroupDoc() && !root->name.empty() &&
470 ((!includeExternal && root->tagInfo()==nullptr) ||
471 ( includeExternal && root->tagInfo()!=nullptr))
472 )
473 {
474 AUTO_TRACE("additional={} includeExternal={}",additional,includeExternal);
475 if ((root->groupDocType==Entry::GROUPDOC_NORMAL && !additional) ||
476 (root->groupDocType!=Entry::GROUPDOC_NORMAL && additional))
477 {
479 AUTO_TRACE_ADD("Processing group '{}':'{}' gd={}", root->type,root->name,(void*)gd);
480
481 if (gd)
482 {
483 if ( !gd->hasGroupTitle() )
484 {
485 gd->setGroupTitle( root->type );
486 }
487 else if ( root->type.length() > 0 && root->name != root->type && gd->groupTitle() != root->type )
488 {
489 warn( root->fileName,root->startLine,
490 "group {}: ignoring title \"{}\" that does not match old title \"{}\"",
491 root->name, root->type, gd->groupTitle() );
492 }
493 gd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
494 gd->setDocumentation( root->doc, root->docFile, root->docLine );
495 gd->setInbodyDocumentation( root->inbodyDocs, root->inbodyFile, root->inbodyLine );
497 gd->setRefItems(root->sli);
499 gd->setLanguage(root->lang);
501 {
502 root->commandOverrides.apply_groupGraph([&](bool b) { gd->overrideGroupGraph(b); });
503 }
504 addIncludeFile(gd,nullptr,root);
505 }
506 else
507 {
508 if (root->tagInfo())
509 {
510 gd = Doxygen::groupLinkedMap->add(root->name,
511 std::unique_ptr<GroupDef>(
512 createGroupDef(root->fileName,root->startLine,root->name,root->type,root->tagInfo()->fileName)));
513 gd->setReference(root->tagInfo()->tagName);
514 }
515 else
516 {
517 gd = Doxygen::groupLinkedMap->add(root->name,
518 std::unique_ptr<GroupDef>(
519 createGroupDef(root->fileName,root->startLine,root->name,root->type)));
520 }
521 gd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
522 // allow empty docs for group
523 gd->setDocumentation(!root->doc.empty() ? root->doc : DString(" "),root->docFile,root->docLine,false);
524 gd->setInbodyDocumentation( root->inbodyDocs, root->inbodyFile, root->inbodyLine );
526 gd->setRefItems(root->sli);
528 gd->setLanguage(root->lang);
529 addIncludeFile(gd,nullptr,root);
531 {
532 root->commandOverrides.apply_groupGraph([&](bool b) { gd->overrideGroupGraph(b); });
533 }
534 }
535 }
536 }
537 for (const auto &e : root->children()) buildGroupListFiltered(e.get(),additional,includeExternal);
538}
539
540static void buildGroupList(const Entry *root)
541{
542 // --- first process only local groups
543 // first process the @defgroups blocks
544 buildGroupListFiltered(root,false,false);
545 // then process the @addtogroup, @weakgroup blocks
546 buildGroupListFiltered(root,true,false);
547
548 // --- then also process external groups
549 // first process the @defgroups blocks
550 buildGroupListFiltered(root,false,true);
551 // then process the @addtogroup, @weakgroup blocks
552 buildGroupListFiltered(root,true,true);
553}
554
555static void findGroupScope(const Entry *root)
556{
557 if (root->section.isGroupDoc() && !root->name.empty() &&
558 root->parent() && !root->parent()->name.empty())
559 {
561 if (gd)
562 {
563 DString scope = root->parent()->name;
564 if (root->parent()->section.isPackageDoc())
565 {
566 scope=substitute(scope,".","::");
567 }
568 scope = stripAnonymousNamespaceScope(scope);
569 scope+="::"+gd->name();
571 if (d)
572 {
573 gd->setGroupScope(d);
574 }
575 }
576 }
577 for (const auto &e : root->children()) findGroupScope(e.get());
578}
579
580static void organizeSubGroupsFiltered(const Entry *root,bool additional)
581{
582 if (root->section.isGroupDoc() && !root->name.empty())
583 {
584 AUTO_TRACE("additional={}",additional);
585 if ((root->groupDocType==Entry::GROUPDOC_NORMAL && !additional) ||
586 (root->groupDocType!=Entry::GROUPDOC_NORMAL && additional))
587 {
589 if (gd)
590 {
591 AUTO_TRACE_ADD("adding {} to group {}",root->name,gd->name());
592 addGroupToGroups(root,gd);
593 }
594 }
595 }
596 for (const auto &e : root->children()) organizeSubGroupsFiltered(e.get(),additional);
597}
598
599static void organizeSubGroups(const Entry *root)
600{
601 //printf("Defining groups\n");
602 // first process the @defgroups blocks
603 organizeSubGroupsFiltered(root,false);
604 //printf("Additional groups\n");
605 // then process the @addtogroup, @weakgroup blocks
606 organizeSubGroupsFiltered(root,true);
607}
608
609//----------------------------------------------------------------------
610
611static void buildFileList(const Entry *root)
612{
613 if ((root->section.isFileDoc() || (root->section.isFile() && Config_getBool(EXTRACT_ALL))) &&
614 !root->name.empty() && !root->tagInfo() // skip any file coming from tag files
615 )
616 {
617 bool ambig = false;
619 if (!fd || ambig)
620 {
621 bool save_ambig = ambig;
622 // use the directory of the file to see if the described file is in the same
623 // directory as the describing file.
624 DString fn = root->fileName;
625 size_t newIndex=fn.rfind('/');
626 if (newIndex==DString::npos)
627 {
628 fn = root->name;
629 }
630 else
631 {
632 fn = fn.left(newIndex)+"/"+root->name;
633 }
635 if (!fd) ambig = save_ambig;
636 }
637 //printf("**************** root->name=%s fd=%p\n",qPrint(root->name),(void*)fd);
638 if (fd && !ambig)
639 {
640 //printf("Adding documentation!\n");
641 // using false in setDocumentation is small hack to make sure a file
642 // is documented even if a \file command is used without further
643 // documentation
644 fd->setDocumentation(root->doc,root->docFile,root->docLine,false);
645 fd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
647 fd->setRefItems(root->sli);
649 addIncludeFile(fd,fd,root);
650 root->commandOverrides.apply_includeGraph ([&](bool b) { fd->overrideIncludeGraph(b); });
651 root->commandOverrides.apply_includedByGraph([&](bool b) { fd->overrideIncludedByGraph(b); });
652 for (const Grouping &g : root->groups)
653 {
654 GroupDef *gd=nullptr;
656 {
657 if (!gd->containsFile(fd))
658 {
659 gd->addFile(fd);
660 fd->makePartOfGroup(gd);
661 //printf("File %s: in group %s\n",qPrint(fd->name()),qPrint(gd->name()));
662 }
663 }
664 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
665 {
666 warn(root->fileName, root->startLine,
667 "Found non-existing group '{}' for the command '{}', ignoring command",
669 );
670 }
671 }
672 }
673 else
674 {
675 DString text(4096, DString::ExplicitSize);
676 text.sprintf("the name '%s' supplied as "
677 "the argument in the \\file statement ",
678 qPrint(root->name));
679 if (ambig) // name is ambiguous
680 {
681 text+="matches the following input files:\n";
683 text+="\n";
684 text+="Please use a more specific name by "
685 "including a (larger) part of the path!";
686 }
687 else // name is not an input file
688 {
689 text+="is not an input file";
690 }
691 warn(root->fileName,root->startLine,"{}", text);
692 }
693 }
694 for (const auto &e : root->children()) buildFileList(e.get());
695}
696
698{
699 size_t l = s.length();
700 int count=0;
701 int round=0;
702 DString result;
703 for (size_t i=0;i<l;i++)
704 {
705 char c=s.at(i);
706 if (c=='(') round++;
707 else if (c==')' && round>0) round--;
708 else if (c=='<' && round==0) count++;
709 if (count==0)
710 {
711 result+=c;
712 }
713 if (c=='>' && round==0 && count>0) count--;
714 }
715 //printf("stripTemplateSpecifiers(%s)=%s\n",qPrint(s),qPrint(result));
716 return result;
717}
718
719/*! returns the Definition object belonging to the first \a level levels of
720 * full qualified name \a name. Creates an artificial scope if the scope is
721 * not found and set the parent/child scope relation if the scope is found.
722 */
723[[maybe_unused]]
724static Definition *buildScopeFromQualifiedName(const DString &name_,SrcLangExt lang,const TagInfo *tagInfo)
725{
726 DString name = stripTemplateSpecifiers(name_);
727 name.stripPrefix("::");
728 int level = name.contains("::");
729 //printf("buildScopeFromQualifiedName(%s) level=%d\n",qPrint(name),level);
730 int i=0, p=0, l=0;
732 DString fullScope;
733 while (i<level)
734 {
735 int idx=getScopeFragment(name,p,&l);
736 if (idx==-1) return prevScope;
737 DString nsName = name.mid(idx,l);
738 if (nsName.empty()) return prevScope;
739 if (!fullScope.empty()) fullScope+="::";
740 fullScope+=nsName;
742 DefinitionMutable *innerScope = toDefinitionMutable(nd);
743 ClassDef *cd=nullptr;
744 if (nd==nullptr) cd = getClass(fullScope);
745 if (nd==nullptr && cd) // scope is a class
746 {
747 innerScope = toDefinitionMutable(cd);
748 }
749 else if (nd==nullptr && cd==nullptr && fullScope.find('<')==DString::npos) // scope is not known and could be a namespace!
750 {
751 // introduce bogus namespace
752 //printf("++ adding dummy namespace %s to %s tagInfo=%p\n",qPrint(nsName),qPrint(prevScope->name()),(void*)tagInfo);
753 NamespaceDefMutable *newNd=
755 Doxygen::namespaceLinkedMap->add(fullScope,
757 "[generated]",1,1,fullScope,
758 tagInfo?tagInfo->tagName:DString(),
759 tagInfo?tagInfo->fileName:DString())));
760 if (newNd)
761 {
762 newNd->setLanguage(lang);
763 newNd->setArtificial(true);
764 // add namespace to the list
765 innerScope = newNd;
766 }
767 }
768 else // scope is a namespace
769 {
770 }
771 if (innerScope)
772 {
773 // make the parent/child scope relation
774 DefinitionMutable *prevScopeMutable = toDefinitionMutable(prevScope);
775 if (prevScopeMutable)
776 {
777 prevScopeMutable->addInnerCompound(toDefinition(innerScope));
778 }
779 innerScope->setOuterScope(prevScope);
780 }
781 else // current scope is a class, so return only the namespace part...
782 {
783 return prevScope;
784 }
785 // proceed to the next scope fragment
786 p=idx+l+2;
787 prevScope=toDefinition(innerScope);
788 i++;
789 }
790 return prevScope;
791}
792
794 FileDef *fileScope,const TagInfo *tagInfo)
795{
796 //printf("<findScopeFromQualifiedName(%s,%s)\n",startScope ? qPrint(startScope->name()) : 0, qPrint(n));
797 Definition *resultScope=toDefinition(startScope);
798 if (resultScope==nullptr) resultScope=Doxygen::globalScope;
800 int l1 = 0;
801 int i1 = getScopeFragment(scope,0,&l1);
802 if (i1==-1)
803 {
804 //printf(">no fragments!\n");
805 return resultScope;
806 }
807 int p=i1+l1,l2=0,i2=0;
808 while ((i2=getScopeFragment(scope,p,&l2))!=-1)
809 {
810 DString nestedNameSpecifier = scope.mid(i1,l1);
811 Definition *orgScope = resultScope;
812 //printf(" nestedNameSpecifier=%s\n",qPrint(nestedNameSpecifier));
813 resultScope = const_cast<Definition*>(resultScope->findInnerCompound(nestedNameSpecifier));
814 //printf(" resultScope=%p\n",resultScope);
815 if (resultScope==nullptr)
816 {
817 if (orgScope==Doxygen::globalScope && fileScope && !fileScope->getUsedNamespaces().empty())
818 // also search for used namespaces
819 {
820 for (const auto &nd : fileScope->getUsedNamespaces())
821 {
823 if (mnd)
824 {
825 resultScope = findScopeFromQualifiedName(toNamespaceDefMutable(nd),n,fileScope,tagInfo);
826 if (resultScope!=nullptr) break;
827 }
828 }
829 if (resultScope)
830 {
831 // for a nested class A::I in used namespace N, we get
832 // N::A::I while looking for A, so we should compare
833 // resultScope->name() against scope.left(i2+l2)
834 //printf(" -> result=%s scope=%s\n",qPrint(resultScope->name()),qPrint(scope));
835 if (rightScopeMatch(resultScope->name(),scope.left(i2+l2)))
836 {
837 break;
838 }
839 goto nextFragment;
840 }
841 }
842
843 // also search for used classes. Complication: we haven't been able
844 // to put them in the right scope yet, because we are still resolving
845 // the scope relations!
846 // Therefore loop through all used classes and see if there is a right
847 // scope match between the used class and nestedNameSpecifier.
848 for (const auto &usedName : g_usingDeclarations)
849 {
850 //printf("Checking using class %s\n",qPrint(usedName));
851 if (rightScopeMatch(usedName,nestedNameSpecifier))
852 {
853 // ui.currentKey() is the fully qualified name of nestedNameSpecifier
854 // so use this instead.
855 DString fqn = usedName + scope.mid(p);
856 resultScope = buildScopeFromQualifiedName(fqn,startScope->getLanguage(),nullptr);
857 //printf("Creating scope from fqn=%s result %p\n",qPrint(fqn),resultScope);
858 if (resultScope)
859 {
860 //printf("> Match! resultScope=%s\n",qPrint(resultScope->name()));
861 return resultScope;
862 }
863 }
864 }
865
866 //printf("> name %s not found in scope %s\n",qPrint(nestedNameSpecifier),qPrint(orgScope->name()));
867 return nullptr;
868 }
869 nextFragment:
870 i1=i2;
871 l1=l2;
872 p=i2+l2;
873 }
874 //printf(">findScopeFromQualifiedName scope %s\n",qPrint(resultScope->name()));
875 return resultScope;
876}
877
878std::unique_ptr<ArgumentList> getTemplateArgumentsFromName(
879 const DString &name,
880 const ArgumentLists &tArgLists)
881{
882 // for each scope fragment, check if it is a template and advance through
883 // the list if so.
884 size_t i=0, p=0;
885 auto alIt = tArgLists.begin();
886 while ((i=name.find("::",p))!=DString::npos && alIt!=tArgLists.end())
887 {
888 NamespaceDef *nd = Doxygen::namespaceLinkedMap->find(name.left(i));
889 if (nd==nullptr)
890 {
891 ClassDef *cd = getClass(name.left(i));
892 if (cd)
893 {
894 if (!cd->templateArguments().empty())
895 {
896 ++alIt;
897 }
898 }
899 }
900 p=i+2;
901 }
902 return alIt!=tArgLists.end() ?
903 std::make_unique<ArgumentList>(*alIt) :
904 std::unique_ptr<ArgumentList>();
905}
906
907static
909{
911
912 if (specifier.isStruct())
914 else if (specifier.isRecord())
916 else if (specifier.isUnion())
917 sec=ClassDef::Union;
918 else if (specifier.isCategory())
920 else if (specifier.isInterface())
922 else if (specifier.isProtocol())
924 else if (specifier.isException())
926 else if (specifier.isService())
928 else if (specifier.isSingleton())
930
931 if (section.isUnionDoc())
932 sec=ClassDef::Union;
933 else if (section.isStructDoc())
935 else if (section.isRecordDoc())
937 else if (section.isInterfaceDoc())
939 else if (section.isProtocolDoc())
941 else if (section.isCategoryDoc())
943 else if (section.isExceptionDoc())
945 else if (section.isServiceDoc())
947 else if (section.isSingletonDoc())
949
950 return sec;
951}
952
953
954static void addClassToContext(const Entry *root)
955{
956 AUTO_TRACE("name={}",root->name);
957 FileDef *fd = root->fileDef();
958
959 DString scName;
960 if (root->parent()->section.isScope())
961 {
962 scName=root->parent()->name;
963 }
964 // name without parent's scope
965 DString fullName = root->name;
966
967 // strip off any template parameters (but not those for specializations)
968 if (size_t idx=fullName.find('>'); idx!=DString::npos && root->lang==SrcLangExt::CSharp) // mangle A<S,T>::N as A-2-g::N
969 {
970 fullName = mangleCSharpGenericName(fullName.left(idx+1))+fullName.mid(idx+1);
971 }
972 fullName=stripTemplateSpecifiersFromScope(fullName);
973
974 // name with scope (if not present already)
975 DString qualifiedName = fullName;
976 if (!scName.empty() && !leftScopeMatch(scName,fullName))
977 {
978 qualifiedName.prepend(scName+"::");
979 }
980
981 // see if we already found the class before
982 ClassDefMutable *cd = getClassMutable(qualifiedName);
983
984 AUTO_TRACE_ADD("Found class with name '{}', qualifiedName '{}'", cd ? cd->name() : root->name, qualifiedName);
985
986 if (cd)
987 {
988 fullName=cd->name();
989 AUTO_TRACE_ADD("Existing class '{}'",cd->name());
990 //if (cd->templateArguments()==0)
991 //{
992 // //printf("existing ClassDef tempArgList=%p specScope=%s\n",root->tArgList,qPrint(root->scopeSpec));
993 // cd->setTemplateArguments(tArgList);
994 //}
995
996 cd->setDocumentation(root->doc,root->docFile,root->docLine);
997 cd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
998 root->commandOverrides.apply_collaborationGraph([&](bool b ) { cd->overrideCollaborationGraph(b); });
999 root->commandOverrides.apply_inheritanceGraph ([&](CLASS_GRAPH_t gt) { cd->overrideInheritanceGraph(gt); });
1000
1001 if (!root->spec.isForwardDecl() && cd->isForwardDeclared())
1002 {
1003 cd->setDefFile(root->fileName,root->startLine,root->startColumn);
1004 if (root->bodyLine!=-1)
1005 {
1006 cd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
1007 cd->setBodyDef(fd);
1008 }
1009 }
1010
1011 if (cd->templateArguments().empty() || (cd->isForwardDeclared() && !root->spec.isForwardDecl()))
1012 {
1013 // this happens if a template class declared with @class is found
1014 // before the actual definition or if a forward declaration has different template
1015 // parameter names.
1016 std::unique_ptr<ArgumentList> tArgList = getTemplateArgumentsFromName(cd->name(),root->tArgLists);
1017 if (tArgList)
1018 {
1019 cd->setTemplateArguments(*tArgList);
1020 }
1021 }
1022 if (cd->requiresClause().empty() && !root->req.empty())
1023 {
1024 cd->setRequiresClause(root->req);
1025 }
1026
1028
1029 cd->setMetaData(root->metaData);
1030 }
1031 else // new class
1032 {
1034
1035 DString className;
1036 DString namespaceName;
1037 extractNamespaceName(fullName,className,namespaceName);
1038
1039 AUTO_TRACE_ADD("New class: fullname '{}' namespace '{}' name='{}' brief='{}' docs='{}'",
1040 fullName, namespaceName, className, Trace::trunc(root->brief), Trace::trunc(root->doc));
1041
1042 DString tagName;
1043 DString refFileName;
1044 const TagInfo *tagInfo = root->tagInfo();
1045 if (tagInfo)
1046 {
1047 tagName = tagInfo->tagName;
1048 refFileName = tagInfo->fileName;
1049 if (fullName.find("::")!=DString::npos)
1050 // symbols imported via tag files may come without the parent scope,
1051 // so we artificially create it here
1052 {
1053 buildScopeFromQualifiedName(fullName,root->lang,tagInfo);
1054 }
1055 }
1056 std::unique_ptr<ArgumentList> tArgList;
1057 size_t i=0;
1058 if ((root->lang==SrcLangExt::CSharp || root->lang==SrcLangExt::Java) &&
1059 (i=fullName.find('<'))!=DString::npos)
1060 {
1061 // a Java/C# generic class looks like a C++ specialization, so we need to split the
1062 // name and template arguments here
1063 tArgList = stringToArgumentList(root->lang,fullName.mid(i));
1064 if (i!=DString::npos && root->lang==SrcLangExt::CSharp) // in C# A, A<T>, and A<T,S> are different classes, so we need some way to disguish them using this name mangling
1065 // A -> A
1066 // A<T> -> A-1-g
1067 // A<T,S> -> A-2-g
1068 {
1069 fullName=mangleCSharpGenericName(fullName);
1070 }
1071 else
1072 {
1073 fullName=fullName.left(i);
1074 }
1075 }
1076 else
1077 {
1078 tArgList = getTemplateArgumentsFromName(fullName,root->tArgLists);
1079 }
1080 // add class to the list
1081 cd = toClassDefMutable(
1082 Doxygen::classLinkedMap->add(fullName,
1083 createClassDef(tagInfo?tagName:root->fileName,root->startLine,root->startColumn,
1084 fullName,sec,tagName,refFileName,true,root->spec.isEnum()) ));
1085 if (cd)
1086 {
1087 AUTO_TRACE_ADD("New class '{}' type={} #tArgLists={} tagInfo={} hidden={} artificial={}",
1088 fullName,cd->compoundTypeString(),root->tArgLists.size(),
1089 fmt::ptr(tagInfo),root->hidden,root->artificial);
1090 cd->setDocumentation(root->doc,root->docFile,root->docLine); // copy docs to definition
1091 cd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
1092 cd->setLanguage(root->lang);
1093 cd->setId(root->id);
1094 cd->setHidden(root->hidden);
1095 cd->setArtificial(root->artificial);
1096 cd->setClassSpecifier(root->spec);
1097 if ((root->lang==SrcLangExt::CSharp || root->lang==SrcLangExt::Java) && !root->args.empty())
1098 {
1100 }
1101 cd->addQualifiers(root->qualifiers);
1102 cd->setTypeConstraints(root->typeConstr);
1103 root->commandOverrides.apply_collaborationGraph([&](bool b ) { cd->overrideCollaborationGraph(b); });
1104 root->commandOverrides.apply_inheritanceGraph ([&](CLASS_GRAPH_t gt) { cd->overrideInheritanceGraph(gt); });
1105
1106 if (tArgList)
1107 {
1108 cd->setTemplateArguments(*tArgList);
1109 }
1110 cd->setRequiresClause(root->req);
1111 cd->setProtection(root->protection);
1112 cd->setIsStatic(root->isStatic);
1113
1114 // file definition containing the class cd
1115 cd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
1116 cd->setBodyDef(fd);
1117
1118 cd->setMetaData(root->metaData);
1119
1120 cd->insertUsedFile(fd);
1121 }
1122 else
1123 {
1124 AUTO_TRACE_ADD("Class {} not added, already exists as alias", fullName);
1125 }
1126 }
1127
1128 if (cd)
1129 {
1131 if (!root->subGrouping) cd->setSubGrouping(false);
1132 if (!root->spec.isForwardDecl())
1133 {
1134 if (cd->hasDocumentation())
1135 {
1136 addIncludeFile(cd,fd,root);
1137 }
1138 if (fd && root->section.isCompound())
1139 {
1140 AUTO_TRACE_ADD("Inserting class {} in file {} (root->fileName='{}')", cd->name(), fd->name(), root->fileName);
1141 cd->setFileDef(fd);
1142 fd->insertClass(cd);
1143 }
1144 }
1145 addClassToGroups(root,cd);
1147 cd->setRefItems(root->sli);
1148 cd->setRequirementReferences(root->rqli);
1149 }
1150}
1151
1152//----------------------------------------------------------------------
1153// build a list of all classes mentioned in the documentation
1154// and all classes that have a documentation block before their definition.
1155static void buildClassList(const Entry *root)
1156{
1157 if ((root->section.isCompound() || root->section.isObjcImpl()) && !root->name.empty())
1158 {
1159 AUTO_TRACE();
1160 addClassToContext(root);
1161 }
1162 for (const auto &e : root->children()) buildClassList(e.get());
1163}
1164
1165static void buildClassDocList(const Entry *root)
1166{
1167 if ((root->section.isCompoundDoc()) && !root->name.empty())
1168 {
1169 AUTO_TRACE();
1170 addClassToContext(root);
1171 }
1172 for (const auto &e : root->children()) buildClassDocList(e.get());
1173}
1174
1175//----------------------------------------------------------------------
1176// build a list of all classes mentioned in the documentation
1177// and all classes that have a documentation block before their definition.
1178
1179static void addConceptToContext(const Entry *root)
1180{
1181 AUTO_TRACE();
1182 FileDef *fd = root->fileDef();
1183
1184 DString scName;
1185 if (root->parent()->section.isScope())
1186 {
1187 scName=root->parent()->name;
1188 }
1189
1190 // name with scope (if not present already)
1191 DString qualifiedName = root->name;
1192 if (!scName.empty() && !leftScopeMatch(qualifiedName,scName))
1193 {
1194 qualifiedName.prepend(scName+"::");
1195 }
1196
1197 // see if we already found the concept before
1198 ConceptDefMutable *cd = getConceptMutable(qualifiedName);
1199
1200 AUTO_TRACE_ADD("Found concept with name '{}' (qualifiedName='{}')", cd ? cd->name() : root->name, qualifiedName);
1201
1202 if (cd)
1203 {
1204 qualifiedName=cd->name();
1205 AUTO_TRACE_ADD("Existing concept '{}'",cd->name());
1206
1207 cd->setDocumentation(root->doc,root->docFile,root->docLine);
1208 cd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
1209
1210 addIncludeFile(cd,fd,root);
1211 }
1212 else // new concept
1213 {
1214 DString className;
1215 DString namespaceName;
1216 extractNamespaceName(qualifiedName,className,namespaceName);
1217
1218 AUTO_TRACE_ADD("New concept: fullname '{}' namespace '{}' name='{}' brief='{}' docs='{}'",
1219 qualifiedName,namespaceName,className,root->brief,root->doc);
1220
1221 DString tagName;
1222 DString refFileName;
1223 const TagInfo *tagInfo = root->tagInfo();
1224 if (tagInfo)
1225 {
1226 tagName = tagInfo->tagName;
1227 refFileName = tagInfo->fileName;
1228 if (qualifiedName.find("::")!=DString::npos)
1229 // symbols imported via tag files may come without the parent scope,
1230 // so we artificially create it here
1231 {
1232 buildScopeFromQualifiedName(qualifiedName,root->lang,tagInfo);
1233 }
1234 }
1235 std::unique_ptr<ArgumentList> tArgList = getTemplateArgumentsFromName(qualifiedName,root->tArgLists);
1236 // add concept to the list
1238 Doxygen::conceptLinkedMap->add(qualifiedName,
1239 createConceptDef(tagInfo?tagName:root->fileName,root->startLine,root->startColumn,
1240 qualifiedName,tagName,refFileName)));
1241 if (cd)
1242 {
1243 AUTO_TRACE_ADD("New concept '{}' #tArgLists={} tagInfo={}",
1244 qualifiedName,root->tArgLists.size(),fmt::ptr(tagInfo));
1245 cd->setDocumentation(root->doc,root->docFile,root->docLine); // copy docs to definition
1246 cd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
1247 cd->setLanguage(root->lang);
1248 cd->setId(root->id);
1249 cd->setHidden(root->hidden);
1250 cd->setGroupId(root->mGrpId);
1251 if (tArgList)
1252 {
1253 cd->setTemplateArguments(*tArgList);
1254 }
1255 cd->setInitializer(root->initializer.str());
1256 // file definition containing the class cd
1257 cd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
1258 cd->setBodyDef(fd);
1260 cd->setRefItems(root->sli);
1261 cd->setRequirementReferences(root->rqli);
1262 addIncludeFile(cd,fd,root);
1263
1264 // also add namespace to the correct structural context
1265 Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,qualifiedName,nullptr,tagInfo);
1267 {
1269 if (dm)
1270 {
1271 dm->addInnerCompound(cd);
1272 }
1273 cd->setOuterScope(d);
1274 }
1275 for (const auto &ce : root->children())
1276 {
1277 //printf("Concept %s has child %s\n",qPrint(root->name),qPrint(ce->section.to_string()));
1278 if (ce->section.isConceptDocPart())
1279 {
1280 cd->addSectionsToDefinition(ce->anchors);
1281 cd->setRefItems(ce->sli);
1282 cd->setRequirementReferences(ce->rqli);
1283 if (!ce->brief.empty())
1284 {
1285 cd->addDocPart(ce->brief,ce->startLine,ce->startColumn);
1286 //printf(" brief=[[\n%s\n]] line=%d,col=%d\n",qPrint(ce->brief),ce->startLine,ce->startColumn);
1287 }
1288 if (!ce->doc.empty())
1289 {
1290 cd->addDocPart(ce->doc,ce->startLine,ce->startColumn);
1291 //printf(" doc=[[\n%s\n]] line=%d,col=%d\n",qPrint(ce->doc),ce->startLine,ce->startColumn);
1292 }
1293 }
1294 else if (ce->section.isConceptCodePart())
1295 {
1296 cd->addCodePart(ce->initializer.str(),ce->startLine,ce->startColumn);
1297 //printf(" code=[[\n%s\n]] line=%d,col=%d\n",qPrint(ce->initializer.str()),ce->startLine,ce->startColumn);
1298 }
1299 }
1300 }
1301 else
1302 {
1303 AUTO_TRACE_ADD("Concept '{}' not added, already exists (as alias)", qualifiedName);
1304 }
1305 }
1306
1307 if (cd)
1308 {
1310 for (const auto &ce : root->children())
1311 {
1312 if (ce->section.isConceptDocPart())
1313 {
1314 cd->addSectionsToDefinition(ce->anchors);
1315 }
1316 }
1317 if (fd)
1318 {
1319 AUTO_TRACE_ADD("Inserting concept '{}' in file '{}' (root->fileName='{}')", cd->name(), fd->name(), root->fileName);
1320 cd->setFileDef(fd);
1321 fd->insertConcept(cd);
1322 }
1323 addConceptToGroups(root,cd);
1325 cd->setRefItems(root->sli);
1326 cd->setRequirementReferences(root->rqli);
1327 }
1328}
1329
1330static void findModuleDocumentation(const Entry *root)
1331{
1332 if (root->section.isModuleDoc())
1333 {
1334 AUTO_TRACE();
1336 }
1337 for (const auto &e : root->children()) findModuleDocumentation(e.get());
1338}
1339
1340static void buildConceptList(const Entry *root)
1341{
1342 if (root->section.isConcept())
1343 {
1344 AUTO_TRACE();
1345 addConceptToContext(root);
1346 }
1347 for (const auto &e : root->children()) buildConceptList(e.get());
1348}
1349
1350static void buildConceptDocList(const Entry *root)
1351{
1352 if (root->section.isConceptDoc())
1353 {
1354 AUTO_TRACE();
1355 addConceptToContext(root);
1356 }
1357 for (const auto &e : root->children()) buildConceptDocList(e.get());
1358}
1359
1360// This routine is to allow @ingroup X @{ concept A; concept B; @} to work
1361// (same also works for variable and functions because of logic in MemberGroup::insertMember)
1363{
1364 AUTO_TRACE();
1365 for (const auto &cd : *Doxygen::conceptLinkedMap)
1366 {
1367 if (cd->groupId()!=DOX_NOGROUP)
1368 {
1369 for (const auto &ocd : *Doxygen::conceptLinkedMap)
1370 {
1371 if (cd!=ocd && cd->groupId()==ocd->groupId() &&
1372 !cd->partOfGroups().empty() && ocd->partOfGroups().empty())
1373 {
1374 ConceptDefMutable *ocdm = toConceptDefMutable(ocd.get());
1375 if (ocdm)
1376 {
1377 for (const auto &gd : cd->partOfGroups())
1378 {
1379 if (gd)
1380 {
1381 AUTO_TRACE_ADD("making concept '{}' part of group '{}'",ocdm->name(),gd->name());
1382 ocdm->makePartOfGroup(gd);
1383 gd->addConcept(ocd.get());
1384 }
1385 }
1386 }
1387 }
1388 }
1389 }
1390 }
1391}
1392
1393//----------------------------------------------------------------------
1394
1396{
1397 ClassDefSet visitedClasses;
1398
1399 bool done=false;
1400 //int iteration=0;
1401 while (!done)
1402 {
1403 done=true;
1404 //++iteration;
1405 struct ClassAlias
1406 {
1407 ClassAlias(const DString &name,std::unique_ptr<ClassDef> cd,DefinitionMutable *ctx) :
1408 aliasFullName(name),aliasCd(std::move(cd)), aliasContext(ctx) {}
1409 DString aliasFullName;
1410 std::unique_ptr<ClassDef> aliasCd;
1411 DefinitionMutable *aliasContext;
1412 };
1413 std::vector<ClassAlias> aliases;
1414 for (const auto &icd : *Doxygen::classLinkedMap)
1415 {
1416 ClassDefMutable *cd = toClassDefMutable(icd.get());
1417 if (cd && visitedClasses.find(icd.get())==visitedClasses.end())
1418 {
1419 DString name = stripAnonymousNamespaceScope(icd->name());
1420 //printf("processing=%s, iteration=%d\n",qPrint(cd->name()),iteration);
1421 // also add class to the correct structural context
1423 name,icd->getFileDef(),nullptr);
1424 if (d)
1425 {
1426 //printf("****** adding %s to scope %s in iteration %d\n",qPrint(cd->name()),qPrint(d->name()),iteration);
1428 if (dm)
1429 {
1430 dm->addInnerCompound(cd);
1431 }
1432 cd->setOuterScope(d);
1433
1434 // for inline namespace add an alias of the class to the outer scope
1436 {
1438 //printf("nd->isInline()=%d\n",nd->isInline());
1439 if (nd && nd->isInline())
1440 {
1441 d = d->getOuterScope();
1442 if (d)
1443 {
1444 dm = toDefinitionMutable(d);
1445 if (dm)
1446 {
1447 auto aliasCd = createClassDefAlias(d,cd);
1448 DString aliasFullName = d->qualifiedName()+"::"+aliasCd->localName();
1449 aliases.emplace_back(aliasFullName,std::move(aliasCd),dm);
1450 //printf("adding %s to %s as %s\n",qPrint(aliasCd->name()),qPrint(d->name()),qPrint(aliasFullName));
1451 }
1452 }
1453 }
1454 else
1455 {
1456 break;
1457 }
1458 }
1459
1460 visitedClasses.insert(icd.get());
1461 done=false;
1462 }
1463 //else
1464 //{
1465 // printf("****** ignoring %s: scope not (yet) found in iteration %d\n",qPrint(cd->name()),iteration);
1466 //}
1467 }
1468 }
1469 // add aliases
1470 for (auto &alias : aliases)
1471 {
1472 ClassDef *aliasCd = Doxygen::classLinkedMap->add(alias.aliasFullName,std::move(alias.aliasCd));
1473 if (aliasCd)
1474 {
1475 alias.aliasContext->addInnerCompound(aliasCd);
1476 }
1477 }
1478 }
1479
1480 //give warnings for unresolved compounds
1481 for (const auto &icd : *Doxygen::classLinkedMap)
1482 {
1483 ClassDefMutable *cd = toClassDefMutable(icd.get());
1484 if (cd && visitedClasses.find(icd.get())==visitedClasses.end())
1485 {
1487 /// create the scope artificially
1488 // anyway, so we can at least relate scopes properly.
1489 Definition *d = buildScopeFromQualifiedName(name,cd->getLanguage(),nullptr);
1490 if (d && d!=cd && !cd->getDefFileName().empty())
1491 // avoid recursion in case of redundant scopes, i.e: namespace N { class N::C {}; }
1492 // for this case doxygen assumes the existence of a namespace N::N in which C is to be found!
1493 // also avoid warning for stuff imported via a tagfile.
1494 {
1496 if (dm)
1497 {
1498 dm->addInnerCompound(cd);
1499 }
1500 cd->setOuterScope(d);
1501 // A specialization can only be written for a template that has been declared before, so a missing
1502 // scope means that declaration is outside the input - e.g. `template<> struct std::hash<MyClass>`.
1503 if (cd->localName().find('<')==DString::npos)
1504 {
1505 warn(cd->getDefFileName(),cd->getDefLine(),
1506 "Incomplete input: scope for class {} not found!{}",name,
1507 name.startsWith("std::") ? " Try enabling BUILTIN_STL_SUPPORT." : ""
1508 );
1509 }
1510 }
1511 }
1512 }
1513}
1514
1516{
1517 //bool inlineGroupedClasses = Config_getBool(INLINE_GROUPED_CLASSES);
1518 //if (!inlineGroupedClasses) return;
1519 //printf("** distributeClassGroupRelations()\n");
1520
1521 ClassDefSet visitedClasses;
1522 for (const auto &cd : *Doxygen::classLinkedMap)
1523 {
1524 //printf("Checking %s\n",qPrint(cd->name()));
1525 // distribute the group to nested classes as well
1526 if (visitedClasses.find(cd.get())==visitedClasses.end() && !cd->partOfGroups().empty())
1527 {
1528 //printf(" Candidate for merging\n");
1529 GroupDef *gd = cd->partOfGroups().front();
1530 for (auto &ncd : cd->getClasses())
1531 {
1533 if (ncdm && ncdm->partOfGroups().empty())
1534 {
1535 //printf(" Adding %s to group '%s'\n",qPrint(ncd->name()),
1536 // gd->groupTitle());
1537 ncdm->makePartOfGroup(gd);
1538 gd->addClass(ncdm);
1539 }
1540 }
1541 visitedClasses.insert(cd.get()); // only visit every class once
1542 }
1543 }
1544}
1545
1546//----------------------------------------------------------------------
1547
1548template<typename Container>
1550 const Container *cd,
1551 const MemberDef *enumTypeMember,
1552 MemberListType mlFilter)
1553{
1554 if (md && md->isEnumerate() && md->name().startsWith("@")) // anonymous enum type
1555 {
1556 MemberList *eiml = cd->getMemberList(mlFilter);
1557 if (eiml)
1558 {
1559 for (const auto &eimd : *eiml)
1560 {
1561 DString vtype = eimd->typeString();
1562 if (vtype.find(md->name())!=DString::npos)
1563 {
1565 if (mimd)
1566 {
1567 mimd->setAnonymousEnumType(enumTypeMember);
1568 break;
1569 }
1570 }
1571 }
1572 }
1573 }
1574}
1575
1576static ClassDefMutable *createTagLessInstance(const Definition *root,const ClassDef *templ,const DString &fieldName,bool hasNamedVariable)
1577{
1578 DString fullName;
1579 if (Config_getEnum(TAGLESS_NAMESTYLE)==TAGLESS_NAMESTYLE_t::flat)
1580 {
1581 // "flat" style: refer to the anonymous compound via its flattened scope and
1582 // member names, e.g. 'struct A { struct { int x; } y; };' yields 'A.y'.
1583 // This matches the pre-1.18 naming and is friendlier for consumers of the
1584 // XML output that cannot handle type names starting with '[' (e.g. mkdoxy).
1585 fullName = removeAnonymousScopes(templ->name());
1586 if (fullName.endsWith("::")) fullName = fullName.left(fullName.length()-2);
1587 // add the field name as a suffix to make the name unique again; the
1588 // separator is only added when there is a flattened scope left (a
1589 // file-scope anonymous compound has none and would otherwise get a
1590 // leading '.').
1591 if (!fullName.empty()) fullName += ".";
1592 fullName += fieldName;
1593 }
1594 else // "marker" style (the default)
1595 {
1596 DString n = templ->name();
1597 // replace e.g. X::@1343:@4343::Y -> X::[struct]::Y
1598 if (size_t sn = n.find('@'); sn!=DString::npos)
1599 {
1600 const char *p = n.data()+sn;
1601 char c;
1602 while ((c=*p))
1603 {
1604 if (!isdigit(c) && c!='@' && c!=':') break;
1605 p++;
1606 }
1607 n = n.left(sn)+"["+templ->compoundTypeString().str()+"]"+p;
1608 }
1609 // add field name to the class name to make it unique again, e.g. X::[struct]::Y.m
1610 fullName = n+"."+fieldName;
1611 }
1612
1613 //printf("** adding class %s based on %s in %s\n",qPrint(fullName),qPrint(templ->name()),qPrint(root->name()));
1615 Doxygen::classLinkedMap->add(fullName,
1617 templ->getDefLine(),
1618 templ->getDefColumn(),
1619 fullName,
1620 templ->compoundType())));
1621 if (cd)
1622 {
1623 //printf("cd->name()=%s displayName=%s\n",qPrint(cd->name()),qPrint(cd->displayName()));
1624 cd->setDocumentation(templ->documentation(),templ->docFile(),templ->docLine()); // copy docs to definition
1625 cd->setBriefDescription(templ->briefDescription(),templ->briefFile(),templ->briefLine());
1626 cd->setLanguage(templ->getLanguage());
1627 cd->setBodySegment(templ->getDefLine(),templ->getStartBodyLine(),templ->getEndBodyLine());
1628 cd->setBodyDef(templ->getBodyDef());
1629
1630 if (hasNamedVariable)
1631 {
1632 cd->setHasNamedVariable(true);
1633 if (root!=Doxygen::globalScope)
1634 {
1635 DefinitionMutable *outerScope = toDefinitionMutable(const_cast<Definition*>(root));
1636 if (root && root->definitionType()==Definition::TypeFile)
1637 {
1638 FileDef *fd = toFileDef(const_cast<Definition*>(root));
1639 fd->insertClass(cd);
1640 cd->setFileDef(fd);
1642 }
1643 else if (outerScope)
1644 {
1645 outerScope->addInnerCompound(cd);
1646 cd->setOuterScope(const_cast<Definition*>(root));
1647 }
1648 }
1649 }
1650 else
1651 {
1652 cd->setArtificial(true);
1653 }
1654
1655 for (auto &gd : root->partOfGroups())
1656 {
1657 cd->makePartOfGroup(gd);
1658 gd->addClass(cd);
1659 }
1660
1661 auto addMember = [&](const MemberDef *md) -> MemberDefMutable*
1662 {
1663 auto newMd = createMemberDef(md->getDefFileName(),md->getDefLine(),md->getDefColumn(),
1664 md->typeString(),md->name(),md->argsString(),md->excpString(),
1665 md->protection(),md->virtualness(),md->isStatic(),Relationship::Member,
1666 md->memberType(),
1667 ArgumentList(),ArgumentList(),"");
1668 MemberDefMutable *imd = toMemberDefMutable(newMd.get());
1669 imd->setDefinition(md->definition());
1670 imd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
1671 imd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
1672 imd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
1673 imd->setMemberSpecifiers(md->getMemberSpecifiers());
1674 imd->setId(md->id());
1675 imd->addQualifiers(md->getQualifiers());
1676 imd->setVhdlSpecifiers(md->getVhdlSpecifiers());
1677 imd->setMemberGroupId(md->getMemberGroupId());
1678 imd->setInitializer(md->initializer());
1679 imd->setRequiresClause(md->requiresClause());
1680 imd->setMaxInitLines(md->initializerLines());
1681 imd->setBitfields(md->bitfieldString());
1682 imd->setLanguage(md->getLanguage());
1683 imd->setAnchor();
1684 MemberName *mn = Doxygen::memberNameLinkedMap->add(md->name());
1685 mn->push_back(std::move(newMd));
1686 return imd;
1687 };
1688
1689 static auto memberListPairs = std::array<std::pair<MemberListType,MemberListType>,3>{{
1690 { MemberListType::PubAttribs(), MemberListType::PubTypes() },
1691 { MemberListType::ProAttribs(), MemberListType::ProTypes() },
1692 { MemberListType::PriAttribs(), MemberListType::PriTypes() }
1693 }};
1694 for (auto [attribs,types] : memberListPairs)
1695 {
1696 MemberList *ml = templ->getMemberList(attribs);
1697 if (ml)
1698 {
1699 for (const auto &md : *ml)
1700 {
1701 //printf(" Member attribute %s def=%s\n",qPrint(md->name()),qPrint(md->definition()));
1702 MemberDefMutable *imd = addMember(md);
1703 if (!hasNamedVariable && root) // we have an anonymous struct/union without associated member variable,
1704 // so we also need to create a new member to show in the outer scope's detailed section.
1705 // e.g. struct S { union { int a; int b; }; }; needs S::a and S::b as members
1706 {
1707 MemberDefMutable *dimd = addMember(md);
1708 // link the detailed member to the original member
1711 if (root && root->definitionType()==Definition::TypeClass && dimd)
1712 {
1713 ClassDefMutable *cm = toClassDefMutable(const_cast<Definition*>(root));
1714 if (cm)
1715 {
1716 //printf(" Member attribute %s added to class %s\n",qPrint(md->name()),qPrint(cm->name()));
1717 dimd->setMemberClass(cm);
1718 cm->insertMember(dimd);
1719 associateVariableWithAnonymousEnumType(md,cm,dimd,attribs);
1720 }
1721 }
1722 else if (root && root->definitionType()==Definition::TypeFile && dimd)
1723 {
1724 FileDef *fd = toFileDef(const_cast<Definition*>(root));
1725 if (fd)
1726 {
1727 //printf(" Member attribute %s added to file %s\n",qPrint(md->name()),qPrint(fd->name()));
1728 dimd->setOuterScope(fd);
1729 dimd->setFileDef(fd);
1730 fd->insertMember(dimd);
1731 associateVariableWithAnonymousEnumType(md,fd,dimd,attribs);
1732 }
1733 }
1734 else if (root && root->definitionType()==Definition::TypeNamespace && dimd)
1735 {
1736 NamespaceDefMutable *ndm = toNamespaceDefMutable(const_cast<Definition*>(root));
1737 if (ndm)
1738 {
1739 //printf(" Member attribute %s added to namespace %s\n",qPrint(md->name()),qPrint(ndm->name()));
1740 dimd->setOuterScope(ndm);
1741 dimd->setNamespace(ndm);
1742 ndm->insertMember(dimd);
1743 associateVariableWithAnonymousEnumType(md,ndm,dimd,attribs);
1744 }
1745 }
1746 }
1747
1748 imd->setMemberClass(cd);
1749 cd->insertMember(imd);
1750 associateVariableWithAnonymousEnumType(md,cd,imd,attribs);
1751 }
1752 }
1753 ml = templ->getMemberList(types);
1754 if (ml)
1755 {
1756 for (const auto &md : *ml)
1757 {
1758 //printf(" Member type %s def=%s\n",qPrint(md->name()),qPrint(md->definition()));
1759 MemberDefMutable *mdm = addMember(md);
1760 mdm->setMemberClass(cd);
1761 cd->insertMember(mdm);
1763 associateVariableWithAnonymousEnumType(md,cd,mdm,attribs);
1764 if (md->isEnumerate() && md->name().startsWith("@")) // anonymous enum type
1765 {
1766 for (const auto &emd : md->enumFieldList())
1767 {
1768 //printf(" enum field %s\n",qPrint(emd->name()));
1769 MemberDefMutable *emdm = addMember(emd);
1770 mdm->insertEnumField(emdm);
1771 emdm->setEnumScope(md);
1772 emdm->setMemberClass(cd);
1773 cd->insertMember(emdm);
1775 associateVariableWithAnonymousEnumType(md,cd,emdm,attribs);
1776 }
1777 }
1778 }
1779 }
1780 }
1781 }
1782 return cd;
1783}
1784
1785template<typename Container, typename TagContainer>
1786static void processTagLessClasses(const Definition *root,
1787 const Container *def,
1788 const TagContainer *tagParent,
1789 MemberListType varFilter,
1790 MemberListType typeFilter,
1791 const DString &prefix,int count);
1792
1793template<typename Container, typename TagContainer>
1795 const Container *def,
1796 const TagContainer *tagParent,
1797 MemberListType varFilter,
1798 MemberListType typeFilter,
1799 const DString &prefix,int count)
1800{
1801 AUTO_TRACE("count={} name={}\n",count,def->name());
1802 if (tagParent)
1803 {
1804 MemberList *ml = def->getMemberList(varFilter);
1805 if (ml)
1806 {
1807 int pos=0;
1808 // make a copy of the member list, since we may add new members to the list while iterating over it
1809 std::vector<MemberDef *> members;
1810 for (const auto &md : *ml)
1811 {
1812 members.push_back(md);
1813 }
1814 for (const auto &md : members)
1815 {
1816 MemberDefMutable *pmdm = nullptr;
1817 if (tagParent!=def)
1818 {
1819 // associate the variable of the anonymous type with the type member
1820 MemberList *pml = tagParent->getMemberList(varFilter);
1821 if (pml)
1822 {
1823 for (const auto &pmd : *pml)
1824 {
1825 if (pmd->name()==md->name())
1826 {
1827 pmdm = toMemberDefMutable(pmd);
1828 }
1829 }
1830 }
1831 }
1832 else
1833 {
1834 pmdm = toMemberDefMutable(md);
1835 }
1836 bool hasNamedVariable = pmdm==nullptr || !pmdm->isAnonymous();
1837
1838 DString type = md->typeString();
1839 //printf(" member %s: type='%s' outerScope='%s'\n",qPrint(md->name()),qPrint(type),qPrint(md->getOuterScope()?md->getOuterScope()->name():"<null>"));
1840 if ((def->definitionType()!=Definition::TypeFile || md->getOuterScope()==Doxygen::globalScope) && // parse namespace members only if def is a namespace
1841 (type.find("::@")!=DString::npos || type.find(" @")!=DString::npos)) // member of tag less struct/union
1842 {
1843 // make a copy of the class list, since we may add new members to the list while iterating over it
1844 std::vector<const ClassDef *> candidates;
1845 for (const auto &icd : def->getClasses())
1846 {
1847 candidates.push_back(icd);
1848 }
1849 for (const auto &icd : candidates)
1850 {
1851 //printf(" comparing '%s'<->'%s'\n",qPrint(type),qPrint(icd->name()));
1852 if (type.find(icd->name())!=DString::npos) // matching tag less struct/union
1853 {
1854 DString name = md->name();
1855 if (md->isAnonymous()) name = "__unnamed" + DString().setNum(pos++)+"__"; // TODO: remove dead code
1856 if (!prefix.empty()) name.prepend(prefix+".");
1857 //printf(" found %s in scope %s\n",qPrint(name),qPrint(def->name()));
1858 ClassDefMutable *ncd = createTagLessInstance(root,icd,name,hasNamedVariable);
1859 if (ncd)
1860 {
1861 processTagLessClasses(ncd,icd,ncd,MemberListType::PubAttribs(),MemberListType::PubTypes(),name,count+1);
1862 //printf(" addTagged %s to %s\n",qPrint(ncd->name()),qPrint(tagParent->name()));
1863 ncd->setTaglessParent(icd);
1864 if (pmdm)
1865 {
1866 pmdm->setClassDefOfAnonymousType(ncd);
1867 }
1868 }
1869 }
1870 else
1871 {
1872 //printf(" no match for %s in %s\n",qPrint(icd->name()),qPrint(type));
1873 }
1874 }
1875 }
1876 }
1877 }
1878 // associate the variable of the anonymous enum type with the type member
1879 ml = def->getMemberList(typeFilter);
1880 if (ml)
1881 {
1882 for (const auto &md : *ml)
1883 {
1884 MemberListType mlFilter = def->definitionType()==Definition::TypeClass ? varFilter : MemberListType::DecVarMembers();
1885 associateVariableWithAnonymousEnumType(md,def,md,mlFilter);
1886 }
1887 }
1888 }
1889}
1890
1891/** Look through the members of class \a cd and its public members.
1892 * If there is a member m of a tag less struct/union,
1893 * then we create a duplicate of the struct/union with the name of the
1894 * member to identify it.
1895 * So if cd has name S, then the tag less struct/union will get name S.m
1896 * Since tag less structs can be nested we need to call this function
1897 * recursively. Later on we need to patch the member types so we keep
1898 * track of the hierarchy of classes we create.
1899 */
1900template<typename Container, typename TagContainer>
1901static void processTagLessClasses(const Definition *root,
1902 const Container *def,
1903 const TagContainer *tagParent,
1904 MemberListType varFilter,
1905 MemberListType typeFilter,
1906 const DString &prefix,int count)
1907{
1908 if (varFilter==MemberListType::PubAttribs()) // also handle protected and private members
1909 {
1910 processTagLessClassesForList(root,def,tagParent,MemberListType::PubAttribs(),MemberListType::PubTypes(),prefix,count);
1911 processTagLessClassesForList(root,def,tagParent,MemberListType::ProAttribs(),MemberListType::ProTypes(),prefix,count);
1912 processTagLessClassesForList(root,def,tagParent,MemberListType::PriAttribs(),MemberListType::PriTypes(),prefix,count);
1913 }
1914 else
1915 {
1916 processTagLessClassesForList(root,def,tagParent,varFilter,typeFilter,prefix,count);
1917 }
1918}
1919
1920template<typename Container>
1921static void findTagLessClasses(std::set<const Definition *> &candidates,const Container *cd)
1922{
1923 for (const auto &icd : cd->getClasses())
1924 {
1925 // process all non-anonymous inner classes, but skip aliases (e.g. from inline namespaces),
1926 // as these share the members of the aliased class, which is processed already
1927 if (!icd->isAlias() && icd->name().find('@')==DString::npos)
1928 {
1929 findTagLessClasses(candidates,icd);
1930 }
1931 }
1932
1933 candidates.insert(cd);
1934}
1935
1937{
1938 std::set<const Definition *> candidates;
1939 for (auto &cd : *Doxygen::classLinkedMap)
1940 {
1941 if (cd->isAlias()) continue;
1942 Definition *scope = cd->getOuterScope();
1943 //printf(" scope=%s for class %s\n",qPrint(scope?scope->name():"<null>"),qPrint(cd->name()));
1944 if (scope && scope->definitionType()==Definition::TypeNamespace) // class that is not nested
1945 {
1946 const NamespaceDef *nd = toNamespaceDef(scope);
1947 if (nd && nd==Doxygen::globalScope) // class at global namespace
1948 {
1949 const FileDef *fd = cd->getFileDef();
1950 if (fd)
1951 {
1952 findTagLessClasses(candidates,fd);
1953 }
1954 }
1955 else if (nd) // class in a namespace
1956 {
1957 findTagLessClasses(candidates,nd);
1958 }
1959 }
1960 }
1961
1962 // since processTagLessClasses is potentially adding classes to Doxygen::classLinkedMap
1963 // we need to call it outside of the loop above, otherwise the iterator gets invalidated!
1964 for (const auto &d : candidates)
1965 {
1966 //printf("------ processing tag-less classes for %s\n",qPrint(d->name()));
1967 if (d->definitionType()==Definition::TypeNamespace)
1968 {
1969 const NamespaceDef *nd = toNamespaceDef(d);
1970 processTagLessClasses(nd,nd,nd,MemberListType::DecVarMembers(),MemberListType::DecEnumMembers(),"",0);
1971 }
1972 else if (d->definitionType()==Definition::TypeFile)
1973 {
1974 const FileDef *fd = toFileDef(d);
1975 processTagLessClasses(fd,fd,fd,MemberListType::DecVarMembers(),MemberListType::DecEnumMembers(),"",0);
1976 }
1977 else if (d->definitionType()==Definition::TypeClass)
1978 {
1979 const ClassDef *cd = toClassDef(d);
1980 processTagLessClasses(cd,cd,cd,MemberListType::PubAttribs(),MemberListType::PubTypes(),"",0);
1981 }
1982 }
1983}
1984
1985
1986//----------------------------------------------------------------------
1987// build a list of all namespaces mentioned in the documentation
1988// and all namespaces that have a documentation block before their definition.
1989static void buildNamespaceList(const Entry *root)
1990{
1991 if (
1992 (root->section.isNamespace() ||
1993 root->section.isNamespaceDoc() ||
1994 root->section.isPackageDoc()
1995 ) &&
1996 !root->name.empty()
1997 )
1998 {
1999 AUTO_TRACE("name={}",root->name);
2000
2001 DString fName = root->name;
2002 if (root->section.isPackageDoc())
2003 {
2004 fName=substitute(fName,".","::");
2005 }
2006
2007 DString fullName = stripAnonymousNamespaceScope(fName);
2008 if (!fullName.empty())
2009 {
2010 AUTO_TRACE_ADD("Found namespace {} in {} at line {}",root->name,root->fileName,root->startLine);
2012 if (ndi) // existing namespace
2013 {
2015 if (nd) // non-inline namespace
2016 {
2017 AUTO_TRACE_ADD("Existing namespace");
2018 nd->setDocumentation(root->doc,root->docFile,root->docLine);
2019 nd->setName(fullName); // change name to match docs
2021 nd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2022 if (nd->getLanguage()==SrcLangExt::Unknown)
2023 {
2024 nd->setLanguage(root->lang);
2025 }
2026 if (root->tagInfo()==nullptr && nd->isReference() && !(root->doc.empty() && root->brief.empty()))
2027 // if we previously found namespace nd in a tag file and now we find a
2028 // documented namespace with the same name in the project, then remove
2029 // the tag file reference
2030 {
2031 nd->setReference("");
2032 nd->setFileName(fullName);
2033 }
2034 nd->setMetaData(root->metaData);
2035
2036 // file definition containing the namespace nd
2037 FileDef *fd=root->fileDef();
2038 if (nd->isArtificial())
2039 {
2040 nd->setArtificial(false); // found namespace explicitly, so cannot be artificial
2041 nd->setDefFile(root->fileName,root->startLine,root->startColumn);
2042 }
2043 // insert the namespace in the file definition
2044 if (fd) fd->insertNamespace(nd);
2045 addNamespaceToGroups(root,nd);
2046 nd->setRefItems(root->sli);
2047 nd->setRequirementReferences(root->rqli);
2048 addIncludeFile(nd,fd,root);
2049 }
2050 }
2051 else // fresh namespace
2052 {
2053 DString tagName;
2054 DString tagFileName;
2055 const TagInfo *tagInfo = root->tagInfo();
2056 if (tagInfo)
2057 {
2058 tagName = tagInfo->tagName;
2059 tagFileName = tagInfo->fileName;
2060 }
2061 AUTO_TRACE_ADD("new namespace {} lang={} tagName={}",fullName,root->lang,tagName);
2062 // add namespace to the list
2064 Doxygen::namespaceLinkedMap->add(fullName,
2065 createNamespaceDef(tagInfo?tagName:root->fileName,root->startLine,
2066 root->startColumn,fullName,tagName,tagFileName,
2067 root->type,root->spec.isPublished())));
2068 if (nd)
2069 {
2070 nd->setDocumentation(root->doc,root->docFile,root->docLine); // copy docs to definition
2071 nd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2073 nd->setHidden(root->hidden);
2074 nd->setArtificial(root->artificial);
2075 nd->setLanguage(root->lang);
2076 nd->setId(root->id);
2077 nd->setMetaData(root->metaData);
2078 nd->setInline(root->spec.isInline());
2079 nd->setExported(root->exported);
2080
2081 addNamespaceToGroups(root,nd);
2082 nd->setRefItems(root->sli);
2083 nd->setRequirementReferences(root->rqli);
2084
2085 // file definition containing the namespace nd
2086 FileDef *fd=root->fileDef();
2087 // insert the namespace in the file definition
2088 if (fd) fd->insertNamespace(nd);
2089
2090 // the empty string test is needed for extract all case
2091 nd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2092 nd->insertUsedFile(fd);
2093 nd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
2094 nd->setBodyDef(fd);
2095 addIncludeFile(nd,fd,root);
2096
2097 // also add namespace to the correct structural context
2098 Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,fullName,nullptr,tagInfo);
2099 AUTO_TRACE_ADD("adding namespace {} to context {}",nd->name(),d ? d->name() : DString("<none>"));
2100 if (d==nullptr) // we didn't find anything, create the scope artificially
2101 // anyway, so we can at least relate scopes properly.
2102 {
2103 d = buildScopeFromQualifiedName(fullName,nd->getLanguage(),tagInfo);
2105 if (dm)
2106 {
2107 dm->addInnerCompound(nd);
2108 }
2109 nd->setOuterScope(d);
2110 // TODO: Due to the order in which the tag file is written
2111 // a nested class can be found before its parent!
2112 }
2113 else
2114 {
2116 if (dm)
2117 {
2118 dm->addInnerCompound(nd);
2119 }
2120 nd->setOuterScope(d);
2121 // in case of d is an inline namespace, alias insert nd in the part scope of d.
2123 {
2124 NamespaceDef *pnd = toNamespaceDef(d);
2125 if (pnd && pnd->isInline())
2126 {
2127 d = d->getOuterScope();
2128 if (d)
2129 {
2130 dm = toDefinitionMutable(d);
2131 if (dm)
2132 {
2133 auto aliasNd = createNamespaceDefAlias(d,nd);
2134 dm->addInnerCompound(aliasNd.get());
2135 DString aliasName = aliasNd->name();
2136 AUTO_TRACE_ADD("adding alias {} to {}",aliasName,d->name());
2137 Doxygen::namespaceLinkedMap->add(aliasName,std::move(aliasNd));
2138 }
2139 }
2140 else
2141 {
2142 break;
2143 }
2144 }
2145 else
2146 {
2147 break;
2148 }
2149 }
2150 }
2151 }
2152 }
2153 }
2154 }
2155 for (const auto &e : root->children()) buildNamespaceList(e.get());
2156}
2157
2158//----------------------------------------------------------------------
2159
2161 const DString &name)
2162{
2163 NamespaceDef *usingNd =nullptr;
2164 for (auto &und : unl)
2165 {
2166 DString uScope=und->name()+"::";
2167 usingNd = getResolvedNamespace(uScope+name);
2168 if (usingNd!=nullptr) break;
2169 }
2170 return usingNd;
2171}
2172
2173static void findUsingDirectives(const Entry *root)
2174{
2175 if (root->section.isUsingDir())
2176 {
2177 AUTO_TRACE("Found using directive {} at line {} of {}",root->name,root->startLine,root->fileName);
2178 DString name=substitute(root->name,".","::");
2179 if (name.endsWith("::"))
2180 {
2181 name=name.left(name.length()-2);
2182 }
2183 if (!name.empty())
2184 {
2185 NamespaceDef *usingNd = nullptr;
2186 NamespaceDefMutable *nd = nullptr;
2187 FileDef *fd = root->fileDef();
2188 DString nsName;
2189
2190 // see if the using statement was found inside a namespace or inside
2191 // the global file scope.
2192 if (root->parent() && root->parent()->section.isNamespace() &&
2193 (fd==nullptr || fd->getLanguage()!=SrcLangExt::Java) // not a .java file
2194 )
2195 {
2196 nsName=stripAnonymousNamespaceScope(root->parent()->name);
2197 if (!nsName.empty())
2198 {
2199 nd = getResolvedNamespaceMutable(nsName);
2200 }
2201 }
2202
2203 // find the scope in which the 'using' namespace is defined by prepending
2204 // the possible scopes in which the using statement was found, starting
2205 // with the most inner scope and going to the most outer scope (i.e.
2206 // file scope).
2207 int scopeOffset = static_cast<int>(nsName.length());
2208 do
2209 {
2210 DString scope=scopeOffset>0 ?
2211 nsName.left(scopeOffset)+"::" : DString();
2212 usingNd = getResolvedNamespace(scope+name);
2213 //printf("Trying with scope='%s' usingNd=%p\n",(scope+qPrint(name)),usingNd);
2214 if (scopeOffset==0)
2215 {
2216 scopeOffset=-1;
2217 }
2218 else
2219 {
2220 size_t o = nsName.rfind("::",scopeOffset-1);
2221 scopeOffset = o!=DString::npos ? static_cast<int>(o) : 0;
2222 }
2223 } while (scopeOffset>=0 && usingNd==nullptr);
2224
2225 if (usingNd==nullptr && nd) // not found, try used namespaces in this scope
2226 // or in one of the parent namespace scopes
2227 {
2228 const NamespaceDefMutable *pnd = nd;
2229 while (pnd && usingNd==nullptr)
2230 {
2231 // also try with one of the used namespaces found earlier
2233
2234 // goto the parent
2235 Definition *s = pnd->getOuterScope();
2237 {
2239 }
2240 else
2241 {
2242 pnd = nullptr;
2243 }
2244 }
2245 }
2246 if (usingNd==nullptr && fd) // still nothing, also try used namespace in the
2247 // global scope
2248 {
2249 usingNd = findUsedNamespace(fd->getUsedNamespaces(),name);
2250 }
2251
2252 //printf("%s -> %s\n",qPrint(name),usingNd?qPrint(usingNd->name()):"<none>");
2253
2254 // add the namespace the correct scope
2255 if (usingNd)
2256 {
2257 //printf("using fd=%p nd=%p\n",fd,nd);
2258 if (nd)
2259 {
2260 //printf("Inside namespace %s\n",qPrint(nd->name()));
2261 nd->addUsingDirective(usingNd);
2262 }
2263 else if (fd)
2264 {
2265 //printf("Inside file %s\n",qPrint(fd->name()));
2266 fd->addUsingDirective(usingNd);
2267 }
2268 }
2269 else // unknown namespace, but add it anyway.
2270 {
2271 AUTO_TRACE_ADD("new unknown namespace {} lang={} hidden={}",name,root->lang,root->hidden);
2272 // add namespace to the list
2275 createNamespaceDef(root->fileName,root->startLine,root->startColumn,name)));
2276 if (nd)
2277 {
2278 nd->setDocumentation(root->doc,root->docFile,root->docLine); // copy docs to definition
2279 nd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2281 nd->setHidden(root->hidden);
2282 nd->setArtificial(true);
2283 nd->setLanguage(root->lang);
2284 nd->setId(root->id);
2285 nd->setMetaData(root->metaData);
2286 nd->setInline(root->spec.isInline());
2287 nd->setExported(root->exported);
2288
2289 for (const Grouping &g : root->groups)
2290 {
2291 GroupDef *gd=nullptr;
2293 gd->addNamespace(nd);
2294 }
2295
2296 // insert the namespace in the file definition
2297 if (fd)
2298 {
2299 fd->insertNamespace(nd);
2300 fd->addUsingDirective(nd);
2301 }
2302
2303 // the empty string test is needed for extract all case
2304 nd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2305 nd->insertUsedFile(fd);
2306 nd->setRefItems(root->sli);
2307 nd->setRequirementReferences(root->rqli);
2308 }
2309 }
2310 }
2311 }
2312 for (const auto &e : root->children()) findUsingDirectives(e.get());
2313}
2314
2315//----------------------------------------------------------------------
2316
2317static void buildListOfUsingDecls(const Entry *root)
2318{
2319 if (root->section.isUsingDecl() &&
2320 !root->parent()->section.isCompound() // not a class/struct member
2321 )
2322 {
2323 DString name = substitute(root->name,".","::");
2324 g_usingDeclarations.insert(name.str());
2325 }
2326 for (const auto &e : root->children()) buildListOfUsingDecls(e.get());
2327}
2328
2329
2330static void findUsingDeclarations(const Entry *root,bool filterPythonPackages)
2331{
2332 if (root->section.isUsingDecl() &&
2333 !root->parent()->section.isCompound() && // not a class/struct member
2334 (!filterPythonPackages || (root->lang==SrcLangExt::Python && root->fileName.endsWith("__init__.py")))
2335 )
2336 {
2337 AUTO_TRACE("Found using declaration '{}' at line {} of {} inside section {}",
2338 root->name,root->startLine,root->fileName,root->parent()->section);
2339 if (!root->name.empty())
2340 {
2341 const Definition *usingDef = nullptr;
2342 NamespaceDefMutable *nd = nullptr;
2343 FileDef *fd = root->fileDef();
2344 DString scName;
2345
2346 // see if the using statement was found inside a namespace or inside
2347 // the global file scope.
2348 if (root->parent()->section.isNamespace())
2349 {
2350 scName=root->parent()->name;
2351 if (!scName.empty())
2352 {
2353 nd = getResolvedNamespaceMutable(scName);
2354 }
2355 }
2356
2357 // Assume the using statement was used to import a class.
2358 // Find the scope in which the 'using' namespace is defined by prepending
2359 // the possible scopes in which the using statement was found, starting
2360 // with the most inner scope and going to the most outer scope (i.e.
2361 // file scope).
2362
2363 DString name = substitute(root->name,".","::"); //Java/C# scope->internal
2364
2365 SymbolResolver resolver;
2366 const Definition *scope = nd;
2367 if (nd==nullptr) scope = fd;
2368 usingDef = resolver.resolveSymbol(scope,name);
2369
2370 //printf("usingDef(scope=%s,name=%s)=%s\n",qPrint(nd?nd->qualifiedName():""),qPrint(name),usingDef?qPrint(usingDef->qualifiedName()):"nullptr");
2371
2372 if (!usingDef)
2373 {
2374 usingDef = getClass(name); // try direct lookup, this is needed to get
2375 // builtin STL classes to properly resolve, e.g.
2376 // vector -> std::vector
2377 }
2378 if (!usingDef)
2379 {
2380 usingDef = Doxygen::hiddenClassLinkedMap->find(name); // check if it is already hidden
2381 }
2382#if 0
2383 if (!usingDef)
2384 {
2385 AUTO_TRACE_ADD("New using class '{}' (sec={})! #tArgLists={}",
2386 name,root->section,root->tArgLists.size());
2389 createClassDef( "<using>",1,1, name, ClassDef::Class)));
2390 if (usingCd)
2391 {
2392 usingCd->setArtificial(true);
2393 usingCd->setLanguage(root->lang);
2394 usingDef = usingCd;
2395 }
2396 }
2397#endif
2398 else
2399 {
2400 AUTO_TRACE_ADD("Found used type '{}' in scope='{}'",
2401 usingDef->name(), nd ? nd->name(): fd ? fd->name() : DString("<unknown>"));
2402 }
2403
2404 if (usingDef)
2405 {
2406 if (nd)
2407 {
2408 nd->addUsingDeclaration(usingDef);
2409 }
2410 else if (fd)
2411 {
2412 fd->addUsingDeclaration(usingDef);
2413 }
2414 }
2415 }
2416 }
2417 for (const auto &e : root->children()) findUsingDeclarations(e.get(),filterPythonPackages);
2418}
2419
2420//----------------------------------------------------------------------
2421
2423{
2424 root->commandOverrides.apply_callGraph ([&](bool b) { md->overrideCallGraph(b); });
2425 root->commandOverrides.apply_callerGraph ([&](bool b) { md->overrideCallerGraph(b); });
2426 root->commandOverrides.apply_referencedByRelation([&](bool b) { md->overrideReferencedByRelation(b); });
2427 root->commandOverrides.apply_referencesRelation ([&](bool b) { md->overrideReferencesRelation(b); });
2428 root->commandOverrides.apply_inlineSource ([&](bool b) { md->overrideInlineSource(b); });
2429 root->commandOverrides.apply_enumValues ([&](bool b) { md->overrideEnumValues(b); });
2430}
2431
2432//----------------------------------------------------------------------
2433
2435 const DString &fileName,const DString &memName)
2436{
2437 AUTO_TRACE("creating new member {} for class {}",memName,cd->name());
2438 const ArgumentList &templAl = md->templateArguments();
2439 const ArgumentList &al = md->argumentList();
2440 auto newMd = createMemberDef(
2441 fileName,root->startLine,root->startColumn,
2442 md->typeString(),memName,md->argsString(),
2443 md->excpString(),root->protection,root->virt,
2444 md->isStatic(),Relationship::Member,md->memberType(),
2445 templAl,al,root->metaData
2446 );
2447 auto newMmd = toMemberDefMutable(newMd.get());
2448 newMmd->setMemberClass(cd);
2449 cd->insertMember(newMd.get());
2450 if (!root->doc.empty() || !root->brief.empty())
2451 {
2452 newMmd->setDocumentation(root->doc,root->docFile,root->docLine);
2453 newMmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2454 newMmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
2455 }
2456 else
2457 {
2458 newMmd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
2459 newMmd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
2460 newMmd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
2461 }
2462 newMmd->setDefinition(md->definition());
2463 applyMemberOverrideOptions(root,newMmd);
2464 newMmd->addQualifiers(root->qualifiers);
2465 newMmd->setBitfields(md->bitfieldString());
2466 newMmd->addSectionsToDefinition(root->anchors);
2467 newMmd->setBodySegment(md->getDefLine(),md->getStartBodyLine(),md->getEndBodyLine());
2468 newMmd->setBodyDef(md->getBodyDef());
2469 newMmd->setInitializer(md->initializer());
2470 newMmd->setRequiresClause(md->requiresClause());
2471 newMmd->setMaxInitLines(md->initializerLines());
2472 newMmd->setMemberGroupId(root->mGrpId);
2473 newMmd->setMemberSpecifiers(md->getMemberSpecifiers());
2474 newMmd->setVhdlSpecifiers(md->getVhdlSpecifiers());
2475 newMmd->setLanguage(root->lang);
2476 newMmd->setId(root->id);
2478 mn->push_back(std::move(newMd));
2479}
2480
2481static std::unordered_map<std::string,std::vector<ClassDefMutable*>> g_usingClassMap;
2482
2483static void findUsingDeclImports(const Entry *root)
2484{
2485 if (root->section.isUsingDecl() &&
2486 root->parent()->section.isCompound() // in a class/struct member
2487 )
2488 {
2489 AUTO_TRACE("Found using declaration '{}' inside section {}", root->name, root->parent()->section);
2490 DString fullName=removeRedundantWhiteSpace(root->parent()->name);
2491 fullName=stripAnonymousNamespaceScope(fullName);
2492 fullName=stripTemplateSpecifiersFromScope(fullName);
2493 ClassDefMutable *cd = getClassMutable(fullName);
2494 if (cd)
2495 {
2496 AUTO_TRACE_ADD("found class '{}'",cd->name());
2497 size_t i=root->name.rfind("::");
2498 if (i!=DString::npos)
2499 {
2500 DString scope=root->name.left(i);
2501 DString memName=root->name.mid(i+2);
2502 SymbolResolver resolver;
2503 const ClassDef *bcd = resolver.resolveClass(cd,scope); // todo: file in fileScope parameter
2504 AUTO_TRACE_ADD("name={} scope={} bcd={}",scope,cd?cd->name():"<none>",bcd?bcd->name():"<none>");
2505 if (bcd && bcd!=cd)
2506 {
2507 AUTO_TRACE_ADD("found class '{}' memName='{}'",bcd->name(),memName);
2509 const MemberNameInfo *mni = mnlm.find(memName);
2510 if (mni)
2511 {
2512 for (auto &mi : *mni)
2513 {
2514 const MemberDef *md = mi->memberDef();
2515 if (md && md->protection()!=Protection::Private)
2516 {
2517 AUTO_TRACE_ADD("found member '{}'",mni->memberName());
2518 DString fileName = root->fileName;
2519 if (fileName.empty() && root->tagInfo())
2520 {
2521 fileName = root->tagInfo()->tagName;
2522 }
2523 if (!cd->containsOverload(md))
2524 {
2525 createUsingMemberImportForClass(root,cd,md,fileName,memName);
2526 // also insert the member into copies of the class
2527 auto it = g_usingClassMap.find(cd->qualifiedName().str());
2528 if (it != g_usingClassMap.end())
2529 {
2530 for (const auto &copyCd : it->second)
2531 {
2532 createUsingMemberImportForClass(root,copyCd,md,fileName,memName);
2533 }
2534 }
2535 }
2536 }
2537 }
2538 }
2539 }
2540 }
2541 }
2542 }
2543 else if (root->section.isUsingDecl() &&
2544 (root->parent()->section.isNamespace() || root->parent()->section.isEmpty()) && // namespace or global member
2545 root->lang==SrcLangExt::Cpp // do we also want this for e.g. Fortran? (see test case 095)
2546 )
2547 {
2548 AUTO_TRACE("Found using declaration '{}' inside section {}", root->name, root->parent()->section);
2549 Definition *scope = nullptr;
2550 NamespaceDefMutable *nd = nullptr;
2551 FileDef *fd = root->parent()->fileDef();
2552 if (!root->parent()->name.empty())
2553 {
2554 DString fullName=removeRedundantWhiteSpace(root->parent()->name);
2555 fullName=stripAnonymousNamespaceScope(fullName);
2557 scope = nd;
2558 }
2559 else
2560 {
2561 scope = fd;
2562 }
2563 if (scope)
2564 {
2565 AUTO_TRACE_ADD("found scope '{}'",scope->name());
2566 SymbolResolver resolver;
2567 const Definition *def = resolver.resolveSymbol(root->name.startsWith("::") ? nullptr : scope,root->name);
2568 if (def && def->definitionType()==Definition::TypeMember)
2569 {
2570 size_t i=root->name.rfind("::");
2571 DString memName;
2572 if (i!=DString::npos)
2573 {
2574 memName = root->name.right(root->name.length()-i-2);
2575 }
2576 else
2577 {
2578 memName = root->name;
2579 }
2580 const MemberDef *md = toMemberDef(def);
2581 AUTO_TRACE_ADD("found member '{}' for name '{}'",md->qualifiedName(),root->name);
2582 DString fileName = root->fileName;
2583 if (fileName.empty() && root->tagInfo())
2584 {
2585 fileName = root->tagInfo()->tagName;
2586 }
2587 const ArgumentList &templAl = md->templateArguments();
2588 const ArgumentList &al = md->argumentList();
2589
2590 auto newMd = createMemberDef(
2591 fileName,root->startLine,root->startColumn,
2592 md->typeString(),memName,md->argsString(),
2593 md->excpString(),root->protection,root->virt,
2594 md->isStatic(),Relationship::Member,md->memberType(),
2595 templAl,al,root->metaData
2596 );
2597 auto newMmd = toMemberDefMutable(newMd.get());
2598 if (nd)
2599 {
2600 newMmd->setNamespace(nd);
2601 nd->insertMember(newMd.get());
2602 }
2603 if (fd)
2604 {
2605 newMmd->setFileDef(fd);
2606 fd->insertMember(newMd.get());
2607 }
2608 if (!root->doc.empty() || !root->brief.empty())
2609 {
2610 newMmd->setDocumentation(root->doc,root->docFile,root->docLine);
2611 newMmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2612 newMmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
2613 }
2614 else
2615 {
2616 newMmd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
2617 newMmd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
2618 newMmd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
2619 }
2620 newMmd->setDefinition(md->definition());
2621 applyMemberOverrideOptions(root,newMmd);
2622 newMmd->addQualifiers(root->qualifiers);
2623 newMmd->setBitfields(md->bitfieldString());
2624 newMmd->addSectionsToDefinition(root->anchors);
2625 newMmd->setBodySegment(md->getDefLine(),md->getStartBodyLine(),md->getEndBodyLine());
2626 newMmd->setBodyDef(md->getBodyDef());
2627 newMmd->setInitializer(md->initializer());
2628 newMmd->setRequiresClause(md->requiresClause());
2629 newMmd->setMaxInitLines(md->initializerLines());
2630 newMmd->setMemberGroupId(root->mGrpId);
2631 newMmd->setMemberSpecifiers(md->getMemberSpecifiers());
2632 newMmd->setVhdlSpecifiers(md->getVhdlSpecifiers());
2633 newMmd->setLanguage(root->lang);
2634 newMmd->setId(root->id);
2636 mn->push_back(std::move(newMd));
2637#if 0 // insert an alias instead of a copy
2638 const MemberDef *md = toMemberDef(def);
2639 AUTO_TRACE_ADD("found member '{}' for name '{}'",md->qualifiedName(),root->name);
2640 auto aliasMd = createMemberDefAlias(nd,md);
2641 DString aliasFullName = nd->qualifiedName()+"::"+aliasMd->localName();
2642 if (nd && aliasMd.get())
2643 {
2644 nd->insertMember(aliasMd.get());
2645 }
2646 if (fd && aliasMd.get())
2647 {
2648 fd->insertMember(aliasMd.get());
2649 }
2650 MemberName *mn = Doxygen::memberNameLinkedMap->add(aliasFullName);
2651 mn->push_back(std::move(aliasMd));
2652#endif
2653 }
2654 else if (def && def->definitionType()==Definition::TypeClass)
2655 {
2656 const ClassDef *cd = toClassDef(def);
2657 DString copyFullName;
2658 if (nd==nullptr)
2659 {
2660 copyFullName = cd->localName();
2661 }
2662 else
2663 {
2664 copyFullName = nd->qualifiedName()+"::"+cd->localName();
2665 }
2666 if (Doxygen::classLinkedMap->find(copyFullName)==nullptr)
2667 {
2669 Doxygen::classLinkedMap->add(copyFullName,
2670 cd->deepCopy(copyFullName)));
2671 AUTO_TRACE_ADD("found class '{}' for name '{}' copy '{}' obj={}",cd->qualifiedName(),root->name,copyFullName,(void*)ncdm);
2672 g_usingClassMap[cd->qualifiedName().str()].push_back(ncdm);
2673 if (ncdm)
2674 {
2675 if (nd) ncdm->moveTo(nd);
2676 if ((!root->doc.empty() || !root->brief.empty())) // use docs at using statement
2677 {
2678 ncdm->setDocumentation(root->doc,root->docFile,root->docLine);
2679 ncdm->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2680 }
2681 else // use docs from used class
2682 {
2683 ncdm->setDocumentation(cd->documentation(),cd->docFile(),cd->docLine());
2685 }
2686 if (nd)
2687 {
2688 nd->addInnerCompound(ncdm);
2689 nd->addUsingDeclaration(ncdm);
2690 }
2691 if (fd)
2692 {
2693 if (ncdm) ncdm->setFileDef(fd);
2694 fd->insertClass(ncdm);
2695 fd->addUsingDeclaration(ncdm);
2696 }
2697 }
2698 }
2699#if 0 // insert an alias instead of a copy
2700 auto aliasCd = createClassDefAlias(nd,cd);
2701 DString aliasFullName;
2702 if (nd==nullptr)
2703 {
2704 aliasFullName = aliasCd->localName();
2705 }
2706 else
2707 {
2708 aliasFullName = nd->qualifiedName()+"::"+aliasCd->localName();
2709 }
2710 AUTO_TRACE_ADD("found class '{}' for name '{}' aliasFullName='{}'",cd->qualifiedName(),root->name,aliasFullName);
2711 auto acd = Doxygen::classLinkedMap->add(aliasFullName,std::move(aliasCd));
2712 if (nd && acd)
2713 {
2714 nd->addInnerCompound(acd);
2715 }
2716 if (fd && acd)
2717 {
2718 fd->insertClass(acd);
2719 }
2720#endif
2721 }
2722 else if (scope)
2723 {
2724 AUTO_TRACE_ADD("no symbol with name '{}' in scope {}",root->name,scope->name());
2725 }
2726 }
2727 }
2728 for (const auto &e : root->children()) findUsingDeclImports(e.get());
2729}
2730
2731//----------------------------------------------------------------------
2732
2734{
2735 FileDefSet visitedFiles;
2736 // then recursively add using directives found in #include files
2737 // to files that have not been visited.
2738 for (const auto &fn : *Doxygen::inputNameLinkedMap)
2739 {
2740 for (const auto &fd : *fn)
2741 {
2742 //printf("----- adding using directives for file %s\n",qPrint(fd->name()));
2743 fd->addIncludedUsingDirectives(visitedFiles);
2744 }
2745 }
2746}
2747
2748//----------------------------------------------------------------------
2749
2751 const Entry *root,
2752 ClassDefMutable *cd,
2753 MemberType mtype,
2754 const DString &type,
2755 const DString &name,
2756 const DString &args,
2757 Protection prot,
2758 Relationship related)
2759{
2761 DString scopeSeparator="::";
2762 SrcLangExt lang = cd->getLanguage();
2763 if (lang==SrcLangExt::Java || lang==SrcLangExt::CSharp)
2764 {
2765 qualScope = substitute(qualScope,"::",".");
2766 scopeSeparator=".";
2767 }
2768 AUTO_TRACE("class variable: file='{}' type='{}' scope='{}' name='{}' args='{}' prot={} mtype={} lang={} init='{}'",
2769 root->fileName, type, qualScope, name, args, root->protection, mtype, lang, root->initializer.str());
2770
2771 DString def;
2772 if (!type.empty())
2773 {
2774 if (related!=Relationship::Member || mtype==MemberType::Friend || Config_getBool(HIDE_SCOPE_NAMES))
2775 {
2776 if (root->spec.isAlias()) // turn 'typedef B A' into 'using A'
2777 {
2778 if (lang==SrcLangExt::Python)
2779 {
2780 def="type "+name+args;
2781 }
2782 else
2783 {
2784 def="using "+name;
2785 }
2786 }
2787 else
2788 {
2789 def=type+" "+name+args;
2790 }
2791 }
2792 else
2793 {
2794 if (root->spec.isAlias()) // turn 'typedef B C::A' into 'using C::A'
2795 {
2796 if (lang==SrcLangExt::Python)
2797 {
2798 def="type "+qualScope+scopeSeparator+name+args;
2799 }
2800 else
2801 {
2802 def="using "+qualScope+scopeSeparator+name;
2803 }
2804 }
2805 else
2806 {
2807 def=type+" "+qualScope+scopeSeparator+name+args;
2808 }
2809 }
2810 }
2811 else
2812 {
2813 if (Config_getBool(HIDE_SCOPE_NAMES))
2814 {
2815 def=name+args;
2816 }
2817 else
2818 {
2819 def=qualScope+scopeSeparator+name+args;
2820 }
2821 }
2822 def.stripPrefix("static ");
2823
2824 // see if the member is already found in the same scope
2825 // (this may be the case for a static member that is initialized
2826 // outside the class)
2828 if (mn)
2829 {
2830 for (const auto &imd : *mn)
2831 {
2832 //printf("md->getClassDef()=%p cd=%p type=[%s] md->typeString()=[%s]\n",
2833 // md->getClassDef(),cd,qPrint(type),md->typeString());
2834 MemberDefMutable *md = toMemberDefMutable(imd.get());
2835 if (md &&
2836 md->getClassDef()==cd &&
2837 ((lang==SrcLangExt::Python && type.empty() && !md->typeString().empty()) ||
2839 // member already in the scope
2840 {
2841
2842 if (root->lang==SrcLangExt::ObjC &&
2843 root->mtype==MethodTypes::Property &&
2844 md->memberType()==MemberType::Variable)
2845 { // Objective-C 2.0 property
2846 // turn variable into a property
2847 md->setProtection(root->protection);
2848 cd->reclassifyMember(md,MemberType::Property);
2849 }
2850 addMemberDocs(root,md,def,nullptr,false,root->spec);
2851 AUTO_TRACE_ADD("Member already found!");
2852 return md;
2853 }
2854 }
2855 }
2856
2857 DString fileName = root->fileName;
2858 if (fileName.empty() && root->tagInfo())
2859 {
2860 fileName = root->tagInfo()->tagName;
2861 }
2862
2863 // new member variable, typedef or enum value
2864 auto md = createMemberDef(
2865 fileName,root->startLine,root->startColumn,
2866 type,name,args,root->exception,
2867 prot,Specifier::Normal,root->isStatic,related,
2868 mtype,!root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList(),
2869 ArgumentList(), root->metaData);
2870 auto mmd = toMemberDefMutable(md.get());
2871 mmd->setTagInfo(root->tagInfo());
2872 mmd->setMemberClass(cd); // also sets outer scope (i.e. getOuterScope())
2873 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
2874 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2875 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
2876 mmd->setDefinition(def);
2877 mmd->setBitfields(root->bitfields);
2878 mmd->addSectionsToDefinition(root->anchors);
2879 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
2880 mmd->setInitializer(root->initializer.str());
2881 mmd->setMaxInitLines(root->initLines);
2882 mmd->setMemberGroupId(root->mGrpId);
2883 mmd->setMemberSpecifiers(root->spec);
2884 mmd->setVhdlSpecifiers(root->vhdlSpec);
2885 mmd->setReadAccessor(root->read);
2886 mmd->setWriteAccessor(root->write);
2888 mmd->setHidden(root->hidden);
2889 mmd->setArtificial(root->artificial);
2890 mmd->setLanguage(root->lang);
2891 mmd->setId(root->id);
2892 addMemberToGroups(root,md.get());
2894 mmd->setBodyDef(root->fileDef());
2895 mmd->addQualifiers(root->qualifiers);
2896 addIncludeFile(mmd,root->fileDef(),root);
2897
2898 AUTO_TRACE_ADD("Adding new member '{}' to class '{}'",name,cd->name());
2899 cd->insertMember(md.get());
2900 mmd->setRefItems(root->sli);
2901 mmd->setRequirementReferences(root->rqli);
2902
2903 cd->insertUsedFile(root->fileDef());
2904 root->markAsProcessed();
2905
2906 if (mtype==MemberType::Typedef)
2907 {
2908 resolveTemplateInstanceInType(root,cd,md.get());
2909 }
2910
2911 // add the member to the global list
2912 MemberDef *result = md.get();
2914 mn->push_back(std::move(md));
2915
2916 return result;
2917}
2918
2919//----------------------------------------------------------------------
2920
2922 const Entry *root,
2923 MemberType mtype,
2924 const DString &scope,
2925 const DString &type,
2926 const DString &name,
2927 const DString &args)
2928{
2929 AUTO_TRACE("global variable: file='{}' type='{}' scope='{}' name='{}' args='{}' prot={} mtype={} lang={} init='{}'",
2930 root->fileName, type, scope, name, args, root->protection, mtype, root->lang, root->initializer.str());
2931
2932 FileDef *fd = root->fileDef();
2933
2934 // see if we have a typedef that should hide a struct or union
2935 if (mtype==MemberType::Typedef && Config_getBool(TYPEDEF_HIDES_STRUCT))
2936 {
2937 DString ttype = type;
2938 ttype.stripPrefix("typedef ");
2939 if (ttype.stripPrefix("struct ") || ttype.stripPrefix("record ") || ttype.stripPrefix("union "))
2940 {
2941 static const reg::Ex re(R"(\a\w*)");
2942 reg::Match match;
2943 const std::string &typ = ttype.str();
2944 if (reg::search(typ,match,re))
2945 {
2946 DString typeValue = match.str();
2947 ClassDefMutable *cd = getClassMutable(typeValue);
2948 if (cd)
2949 {
2950 // this typedef should hide compound name cd, so we
2951 // change the name that is displayed from cd.
2952 cd->setClassName(name);
2953 cd->setDocumentation(root->doc,root->docFile,root->docLine);
2954 cd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
2955 return nullptr;
2956 }
2957 }
2958 }
2959 }
2960
2961 // see if the function is inside a namespace
2962 NamespaceDefMutable *nd = nullptr;
2963 if (!scope.empty())
2964 {
2965 if (scope.find('@')!=DString::npos) return nullptr; // anonymous scope!
2966 nd = getResolvedNamespaceMutable(scope);
2967 }
2968 DString def;
2969
2970 // determine the definition of the global variable
2971 if (nd && !nd->isAnonymous() &&
2972 !Config_getBool(HIDE_SCOPE_NAMES)
2973 )
2974 // variable is inside a namespace, so put the scope before the name
2975 {
2976 SrcLangExt lang = nd->getLanguage();
2978
2979 if (!type.empty())
2980 {
2981 if (root->spec.isAlias()) // turn 'typedef B NS::A' into 'using NS::A'
2982 {
2983 if (lang==SrcLangExt::Python)
2984 {
2985 def="type "+nd->name()+sep+name+args;
2986 }
2987 else
2988 {
2989 def="using "+nd->name()+sep+name;
2990 }
2991 }
2992 else // normal member
2993 {
2994 def=type+" "+nd->name()+sep+name+args;
2995 }
2996 }
2997 else
2998 {
2999 def=nd->name()+sep+name+args;
3000 }
3001 }
3002 else
3003 {
3004 if (!type.empty() && !root->name.empty())
3005 {
3006 if (name.at(0)=='@') // dummy variable representing anonymous union
3007 {
3008 def=type;
3009 }
3010 else
3011 {
3012 if (root->spec.isAlias()) // turn 'typedef B A' into 'using A'
3013 {
3014 if (root->lang==SrcLangExt::Python)
3015 {
3016 def="type "+root->name+args;
3017 }
3018 else
3019 {
3020 def="using "+root->name;
3021 }
3022 }
3023 else // normal member
3024 {
3025 def=type+" "+name+args;
3026 }
3027 }
3028 }
3029 else
3030 {
3031 def=name+args;
3032 }
3033 }
3034 def.stripPrefix("static ");
3035
3037 if (mn)
3038 {
3039 //DString nscope=removeAnonymousScopes(scope);
3040 //NamespaceDef *nd=nullptr;
3041 //if (!nscope.empty())
3042 if (!scope.empty())
3043 {
3044 nd = getResolvedNamespaceMutable(scope);
3045 }
3046 for (const auto &imd : *mn)
3047 {
3048 MemberDefMutable *md = toMemberDefMutable(imd.get());
3049 if (md &&
3050 ((nd==nullptr && md->getNamespaceDef()==nullptr && md->getFileDef() &&
3051 root->fileName==md->getFileDef()->absFilePath()
3052 ) // both variable names in the same file
3053 || (nd!=nullptr && md->getNamespaceDef()==nd) // both in same namespace
3054 )
3055 && !md->isDefine() // function style #define's can be "overloaded" by typedefs or variables
3056 && !md->isEnumerate() // in C# an enum value and enum can have the same name
3057 )
3058 // variable already in the scope
3059 {
3060 bool isPHPArray = md->getLanguage()==SrcLangExt::PHP &&
3061 md->argsString()!=args &&
3062 args.find('[')!=DString::npos;
3063 bool staticsInDifferentFiles =
3064 root->isStatic && md->isStatic() &&
3065 root->fileName!=md->getDefFileName();
3066
3067 if (md->getFileDef() &&
3068 !isPHPArray && // not a php array
3069 !staticsInDifferentFiles
3070 )
3071 // not a php array variable
3072 {
3073 AUTO_TRACE_ADD("variable already found: scope='{}'",md->getOuterScope()->name());
3074 addMemberDocs(root,md,def,nullptr,false,root->spec);
3075 md->setRefItems(root->sli);
3076 md->setRequirementReferences(root->rqli);
3077 // if md is a variable forward declaration and root is the definition that
3078 // turn md into the definition
3079 if (!root->explicitExternal && md->isExternal())
3080 {
3081 md->setDeclFile(md->getDefFileName(),md->getDefLine(),md->getDefColumn());
3082 md->setExplicitExternal(false,root->fileName,root->startLine,root->startColumn);
3083 }
3084 // if md is the definition and root point at a declaration, then add the
3085 // declaration info
3086 else if (root->explicitExternal && !md->isExternal())
3087 {
3088 md->setDeclFile(root->fileName,root->startLine,root->startColumn);
3089 }
3090 return md;
3091 }
3092 }
3093 }
3094 }
3095
3096 DString fileName = root->fileName;
3097 if (fileName.empty() && root->tagInfo())
3098 {
3099 fileName = root->tagInfo()->tagName;
3100 }
3101
3102 AUTO_TRACE_ADD("new variable, namespace='{}'",nd?nd->name():DString("<global>"));
3103 // new global variable, enum value or typedef
3104 auto md = createMemberDef(
3105 fileName,root->startLine,root->startColumn,
3106 type,name,args,DString(),
3107 root->protection, Specifier::Normal,root->isStatic,Relationship::Member,
3108 mtype,!root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList(),
3109 root->argList, root->metaData);
3110 auto mmd = toMemberDefMutable(md.get());
3111 mmd->setTagInfo(root->tagInfo());
3112 mmd->setMemberSpecifiers(root->spec);
3113 mmd->setVhdlSpecifiers(root->vhdlSpec);
3114 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
3115 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
3116 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
3117 mmd->addSectionsToDefinition(root->anchors);
3118 mmd->setInitializer(root->initializer.str());
3119 mmd->setMaxInitLines(root->initLines);
3120 mmd->setMemberGroupId(root->mGrpId);
3121 mmd->setDefinition(def);
3122 mmd->setLanguage(root->lang);
3123 mmd->setId(root->id);
3125 mmd->setExplicitExternal(root->explicitExternal,fileName,root->startLine,root->startColumn);
3126 mmd->addQualifiers(root->qualifiers);
3127 //md->setOuterScope(fd);
3128 if (!root->explicitExternal)
3129 {
3130 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
3131 mmd->setBodyDef(fd);
3132 }
3133 addMemberToGroups(root,md.get());
3134 addIncludeFile(mmd,fd,root);
3136
3137 mmd->setRefItems(root->sli);
3138 mmd->setRequirementReferences(root->rqli);
3139 if (nd && !nd->isAnonymous())
3140 {
3141 mmd->setNamespace(nd);
3142 nd->insertMember(md.get());
3143 }
3144
3145 // add member to the file (we do this even if we have already inserted
3146 // it into the namespace.
3147 if (fd)
3148 {
3149 mmd->setFileDef(fd);
3150 fd->insertMember(md.get());
3151 }
3152
3153 root->markAsProcessed();
3154
3155 if (mtype==MemberType::Typedef)
3156 {
3157 resolveTemplateInstanceInType(root,nd,md.get());
3158 }
3159
3160 // add member definition to the list of globals
3161 MemberDef *result = md.get();
3163 mn->push_back(std::move(md));
3164
3165
3166
3167 return result;
3168}
3169
3170/*! See if the return type string \a type is that of a function pointer
3171 * \returns -1 if this is not a function pointer variable or
3172 * the index at which the closing brace of (...*name) was found.
3173 */
3174static int findFunctionPtr(const std::string &type,SrcLangExt lang, int *pLength=nullptr)
3175{
3176 AUTO_TRACE("type='{}' lang={}",type,lang);
3177 if (lang == SrcLangExt::Fortran || lang == SrcLangExt::VHDL)
3178 {
3179 return -1; // Fortran and VHDL do not have function pointers
3180 }
3181
3182 static const reg::Ex re(R"(\‍([^)]*[*&^][^)]*\))");
3183 reg::Match match;
3184 size_t i=std::string::npos;
3185 size_t l=0;
3186 if (reg::search(type,match,re)) // contains (...*...) or (...&...) or (...^...)
3187 {
3188 i = match.position();
3189 l = match.length();
3190 }
3191 if (i!=std::string::npos)
3192 {
3193 size_t di = type.find("decltype(");
3194 if (di!=std::string::npos && di<i)
3195 {
3196 i = std::string::npos;
3197 }
3198 }
3199 size_t bb=type.find('<');
3200 size_t be=type.rfind('>');
3201 bool templFp = false;
3202 if (be!=std::string::npos) {
3203 size_t cc_ast = type.find("::*");
3204 size_t cc_amp = type.find("::&");
3205 templFp = (cc_ast != std::string::npos && cc_ast>be) || (cc_amp != std::string::npos && cc_amp>be); // hack to find, e.g 'B<X>(A<int>::*)'
3206 }
3207
3208 if (!type.empty() && // return type is non-empty
3209 i!=std::string::npos && // contains (...*...)
3210 type.find("operator")==std::string::npos && // not an operator
3211 (type.find(")(")==std::string::npos || type.find("typedef ")!=std::string::npos) &&
3212 // not a function pointer return type
3213 (!((bb!=std::string::npos && bb<i) && (be!=std::string::npos && i<be)) || templFp) // bug665855: avoid treating "typedef A<void (T*)> type" as a function pointer
3214 )
3215 {
3216 if (pLength) *pLength=static_cast<int>(l);
3217 //printf("findFunctionPtr=%d\n",(int)i);
3218 AUTO_TRACE_EXIT("result={}",i);
3219 return static_cast<int>(i);
3220 }
3221 else
3222 {
3223 //printf("findFunctionPtr=%d\n",-1);
3224 AUTO_TRACE_EXIT("result=-1");
3225 return -1;
3226 }
3227}
3228
3229//--------------------------------------------------------------------------------------
3230
3231/*! Returns true iff \a type is a class within scope \a context.
3232 * Used to detect variable declarations that look like function prototypes.
3233 */
3234static bool isVarWithConstructor(const Entry *root)
3235{
3236 bool result = false;
3237 bool typeIsClass = false;
3238 bool typePtrType = false;
3239 DString type;
3240 Definition *ctx = nullptr;
3241 FileDef *fd = root->fileDef();
3242 SymbolResolver resolver(fd);
3243
3244 AUTO_TRACE("isVarWithConstructor({})",root->name);
3245 if (root->parent()->section.isCompound())
3246 { // inside a class
3247 result=false;
3248 AUTO_TRACE_EXIT("inside class: result={}",result);
3249 return result;
3250 }
3251 else if ((fd != nullptr) && (fd->name().endsWith(".c") || fd->name().endsWith(".h")))
3252 { // inside a .c file
3253 result=false;
3254 AUTO_TRACE_EXIT("inside C file: result={}",result);
3255 return result;
3256 }
3257 if (root->type.empty())
3258 {
3259 result=false;
3260 AUTO_TRACE_EXIT("no type: result={}",result);
3261 return result;
3262 }
3263 if (!root->parent()->name.empty())
3264 {
3266 }
3267 type = root->type;
3268 // remove qualifiers
3269 type.findAndRemoveWord("const");
3270 type.findAndRemoveWord("static");
3271 type.findAndRemoveWord("volatile");
3272 typePtrType = type.find('*')!=DString::npos || type.find('&')!=DString::npos;
3273 if (!typePtrType)
3274 {
3275 typeIsClass = resolver.resolveClass(ctx,type)!=nullptr;
3276 if (size_t ti=type.find('<'); !typeIsClass && ti!=DString::npos)
3277 {
3278 typeIsClass=resolver.resolveClass(ctx,type.left(ti))!=nullptr;
3279 }
3280 }
3281 if (typeIsClass) // now we still have to check if the arguments are
3282 // types or values. Since we do not have complete type info
3283 // we need to rely on heuristics :-(
3284 {
3285 if (root->argList.empty())
3286 {
3287 result=false; // empty arg list -> function prototype.
3288 AUTO_TRACE_EXIT("empty arg list: result={}",result);
3289 return result;
3290 }
3291 for (const Argument &a : root->argList)
3292 {
3293 static const reg::Ex initChars(R"([\d"'&*!^]+)");
3294 reg::Match match;
3295 if (!a.name.empty() || !a.defval.empty())
3296 {
3297 std::string name = a.name.str();
3298 if (reg::search(name,match,initChars) && match.position()==0)
3299 {
3300 result=true;
3301 }
3302 else
3303 {
3304 result=false; // arg has (type,name) pair -> function prototype
3305 }
3306 AUTO_TRACE_EXIT("function prototype: result={}",result);
3307 return result;
3308 }
3309 if (!a.type.empty() &&
3310 (a.type.at(a.type.length()-1)=='*' ||
3311 a.type.at(a.type.length()-1)=='&'))
3312 // type ends with * or & => pointer or reference
3313 {
3314 result=false;
3315 AUTO_TRACE_EXIT("pointer or reference: result={}",result);
3316 return result;
3317 }
3318 if (a.type.empty() || resolver.resolveClass(ctx,a.type)!=nullptr)
3319 {
3320 result=false; // arg type is a known type
3321 AUTO_TRACE_EXIT("known type: result={}",result);
3322 return result;
3323 }
3324 if (checkIfTypedef(ctx,fd,a.type))
3325 {
3326 result=false; // argument is a typedef
3327 AUTO_TRACE_EXIT("typedef: result={}",result);
3328 return result;
3329 }
3330 std::string atype = a.type.str();
3331 if (reg::search(atype,match,initChars) && match.position()==0)
3332 {
3333 result=true; // argument type starts with typical initializer char
3334 AUTO_TRACE_EXIT("argument with init char: result={}",result);
3335 return result;
3336 }
3337 std::string resType=resolveTypeDef(ctx,a.type).str();
3338 if (resType.empty()) resType=atype;
3339 static const reg::Ex idChars(R"(\a\w*)");
3340 if (reg::search(resType,match,idChars) && match.position()==0) // resType starts with identifier
3341 {
3342 resType=match.str();
3343 if (resType=="int" || resType=="long" ||
3344 resType=="float" || resType=="double" ||
3345 resType=="char" || resType=="void" ||
3346 resType=="signed" || resType=="unsigned" ||
3347 resType=="const" || resType=="volatile" )
3348 {
3349 result=false; // type keyword -> function prototype
3350 AUTO_TRACE_EXIT("type keyword: result={}",result);
3351 return result;
3352 }
3353 }
3354 }
3355 result=true;
3356 }
3357
3358 AUTO_TRACE_EXIT("end: result={}",result);
3359 return result;
3360}
3361
3362//--------------------------------------------------------------------------------------
3363
3364/*! Searches for the end of a template in prototype \a s starting from
3365 * character position \a startPos. If the end was found the position
3366 * of the closing > is returned, otherwise -1 is returned.
3367 *
3368 * Handles exotic cases such as
3369 * \code
3370 * Class<(id<0)>
3371 * Class<bits<<2>
3372 * Class<"<">
3373 * Class<'<'>
3374 * Class<(")<")>
3375 * \endcode
3376 */
3377static int findEndOfTemplate(const DString &s,size_t startPos)
3378{
3379 // locate end of template
3380 size_t e=startPos;
3381 int brCount=1;
3382 int roundCount=0;
3383 size_t len = s.length();
3384 bool insideString=false;
3385 bool insideChar=false;
3386 char pc = 0;
3387 while (e<len && brCount!=0)
3388 {
3389 char c=s.at(e);
3390 switch(c)
3391 {
3392 case '<':
3393 if (!insideString && !insideChar)
3394 {
3395 if (e<len-1 && s.at(e+1)=='<')
3396 e++;
3397 else if (roundCount==0)
3398 brCount++;
3399 }
3400 break;
3401 case '>':
3402 if (!insideString && !insideChar)
3403 {
3404 if (e<len-1 && s.at(e+1)=='>')
3405 e++;
3406 else if (roundCount==0)
3407 brCount--;
3408 }
3409 break;
3410 case '(':
3411 if (!insideString && !insideChar)
3412 roundCount++;
3413 break;
3414 case ')':
3415 if (!insideString && !insideChar)
3416 roundCount--;
3417 break;
3418 case '"':
3419 if (!insideChar)
3420 {
3421 if (insideString && pc!='\\')
3422 insideString=false;
3423 else
3424 insideString=true;
3425 }
3426 break;
3427 case '\'':
3428 if (!insideString)
3429 {
3430 if (insideChar && pc!='\\')
3431 insideChar=false;
3432 else
3433 insideChar=true;
3434 }
3435 break;
3436 }
3437 pc = c;
3438 e++;
3439 }
3440 return brCount==0 ? static_cast<int>(e) : -1;
3441}
3442
3443//--------------------------------------------------------------------------------------
3444
3445static void addVariable(const Entry *root,int isFuncPtr=-1)
3446{
3447 bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE);
3448
3449 AUTO_TRACE("VARIABLE_SEC: type='{}' name='{}' args='{}' bodyLine={} endBodyLine={} mGrpId={} relates='{}'",
3450 root->type, root->name, root->args, root->bodyLine, root->endBodyLine, root->mGrpId, root->relates);
3451 //printf("root->parent->name=%s\n",qPrint(root->parent->name));
3452
3453 DString type = root->type;
3454 DString name = root->name;
3455 DString args = root->args;
3456 if (type.empty() && name.find("operator")==DString::npos &&
3457 (name.find('*')!=DString::npos || name.find('&')!=DString::npos))
3458 {
3459 // recover from parse error caused by redundant braces
3460 // like in "int *(var[10]);", which is parsed as
3461 // type="" name="int *" args="(var[10])"
3462
3463 type=name;
3464 std::string sargs = args.str();
3465 static const reg::Ex reName(R"(\a\w*)");
3466 reg::Match match;
3467 if (reg::search(sargs,match,reName))
3468 {
3469 name = match.str(); // e.g. 'var' in '(var[10])'
3470 sargs = match.suffix().str(); // e.g. '[10]) in '(var[10])'
3471 size_t j = sargs.find(')');
3472 if (j!=std::string::npos) args=sargs.substr(0,j); // extract, e.g '[10]' from '[10])'
3473 }
3474 }
3475 else
3476 {
3477 int i=isFuncPtr;
3478 if (i==-1 && (root->spec.isAlias())==0) i=findFunctionPtr(type.str(),root->lang); // for typedefs isFuncPtr is not yet set
3479 AUTO_TRACE_ADD("functionPtr={}",i!=-1?"yes":"no");
3480 if (i>=0) // function pointer
3481 {
3482 size_t ii = i;
3483 size_t ai = type.find('[',ii);
3484 if (ai!=DString::npos && ai>ii) // function pointer array
3485 {
3486 args.prepend(type.mid(ai));
3487 type=type.left(ai);
3488 }
3489 else if (type.find(')',ii)!=DString::npos) // function ptr, not variable like "int (*bla)[10]"
3490 {
3491 type=type.left(type.length()-1);
3492 args.prepend(") ");
3493 }
3494 }
3495 }
3496 AUTO_TRACE_ADD("after correction: type='{}' name='{}' args='{}'",type,name,args);
3497
3498 DString scope;
3499 name=removeRedundantWhiteSpace(name);
3500
3501 // find the scope of this variable
3502 int index = computeQualifiedIndex(name);
3503 // grouped members are stored with full scope
3504 bool qualifiedGroupMember = index!=-1 && root->parent()->section.isGroupDoc() && root->parent()->tagInfo();
3505 // A specialization of a variable template that lives in a namespace, i.e.
3506 // `template<class T> constexpr bool std::ranges::enable_view<MyView<T>> = true;`.
3507 // Its scope has to be spelled out, so it must not be mistaken for the definition of a static
3508 // data member, which is declared in its class as well and is therefore picked up from there.
3509 bool variableTemplateSpecialization = index!=-1 && !root->tArgLists.empty() &&
3510 name.mid(index+2).find('<')!=DString::npos &&
3511 getClass(name.left(index))==nullptr;
3512 if (qualifiedGroupMember || variableTemplateSpecialization)
3513 {
3514 Definition *d = buildScopeFromQualifiedName(name.left(index+2),root->lang,root->tagInfo());
3515 if (variableTemplateSpecialization)
3516 // the scope may have been made up for this specialization, but it holds a documented member
3517 // now, which is only reachable through a page of its own
3518 {
3519 for (Definition *s=d; s && s!=Doxygen::globalScope; s=s->getOuterScope())
3520 {
3522 if (ndm && ndm->isArtificial()) ndm->setArtificial(false);
3523 }
3524 }
3525 scope=name.left(index);
3526 name=name.mid(index+2);
3527 }
3528 else
3529 {
3530 Entry *p = root->parent();
3531 while (p->section.isScope())
3532 {
3533 DString scopeName = p->name;
3534 if (!scopeName.empty())
3535 {
3536 scope.prepend(scopeName);
3537 break;
3538 }
3539 p=p->parent();
3540 }
3541 }
3542
3543 DString type_s = type;
3544 type=type.stripWhiteSpace();
3545 ClassDefMutable *cd=nullptr;
3546 bool isRelated=false;
3547 bool isMemberOf=false;
3548
3549 DString classScope=stripAnonymousNamespaceScope(scope);
3550 if (root->lang==SrcLangExt::CSharp)
3551 {
3552 classScope=mangleCSharpGenericName(classScope);
3553 }
3554 else
3555 {
3556 classScope=stripTemplateSpecifiersFromScope(classScope,false);
3557 }
3558 DString annScopePrefix=scope.left(scope.length()-classScope.length());
3559
3560
3561 // Look for last :: not part of template specifier
3562 int p=-1;
3563 for (size_t i=0;i<name.length()-1;i++)
3564 {
3565 if (name[i]==':' && name[i+1]==':')
3566 {
3567 p=static_cast<int>(i);
3568 }
3569 else if (name[i]=='<') // skip over template parts,
3570 // i.e. A::B<C::D> => p=1 and
3571 // A<B::C>::D => p=8
3572 {
3573 int e = findEndOfTemplate(name,i+1);
3574 if (e!=-1) i=static_cast<int>(e);
3575 }
3576 }
3577
3578 if (p!=-1) // found it
3579 {
3580 if (isTypeAClassFriend(type))
3581 {
3582 cd=getClassMutable(scope);
3583 if (cd)
3584 {
3585 addVariableToClass(root, // entry
3586 cd, // class to add member to
3587 MemberType::Friend, // type of member
3588 type, // type value as string
3589 name, // name of the member
3590 args, // arguments as string
3591 Protection::Public, // protection
3592 Relationship::Member // related to a class
3593 );
3594 }
3595 }
3596 if (root->bodyLine!=-1 && root->endBodyLine!=-1) // store the body location for later use
3597 {
3598 Doxygen::staticInitMap.emplace(name.str(),BodyInfo{root->startLine,root->bodyLine,root->endBodyLine});
3599 }
3600
3601
3602 AUTO_TRACE_ADD("static variable {} body=[{}..{}]",name,root->bodyLine,root->endBodyLine);
3603 return; /* skip this member, because it is a
3604 * static variable definition (always?), which will be
3605 * found in a class scope as well, but then we know the
3606 * correct protection level, so only then it will be
3607 * inserted in the correct list!
3608 */
3609 }
3610
3611 MemberType mtype = MemberType::Variable;
3612 if (type=="@")
3613 mtype=MemberType::EnumValue;
3614 else if (type_s.startsWith("typedef "))
3615 mtype=MemberType::Typedef;
3616 else if (type_s.startsWith("friend ") || type_s=="friend")
3617 mtype=MemberType::Friend;
3618 else if (root->mtype==MethodTypes::Property)
3619 mtype=MemberType::Property;
3620 else if (root->mtype==MethodTypes::Event)
3621 mtype=MemberType::Event;
3622 else if (type.find("sequence<") != DString::npos)
3623 mtype=sliceOpt ? MemberType::Sequence : MemberType::Typedef;
3624 else if (type.find("dictionary<") != DString::npos)
3625 mtype=sliceOpt ? MemberType::Dictionary : MemberType::Typedef;
3626
3627 if (!root->relates.empty()) // related variable
3628 {
3629 isRelated=true;
3630 isMemberOf=(root->relatesType==RelatesType::MemberOf);
3631 if (getClass(root->relates)==nullptr && !scope.empty())
3632 scope=mergeScopes(scope,root->relates);
3633 else
3634 scope=root->relates;
3635 }
3636
3637 cd=getClassMutable(scope);
3638 if (cd==nullptr && classScope!=scope) cd=getClassMutable(classScope);
3639 if (cd)
3640 {
3641 Relationship relationship = isMemberOf ? Relationship::Foreign :
3642 isRelated ? Relationship::Related :
3643 Relationship::Member ;
3644
3645 addVariableToClass(root, // entry
3646 cd, // class to add member to
3647 mtype, // member type
3648 type, // type value as string
3649 name, // name of the member
3650 args, // arguments as string
3651 root->protection,
3652 relationship
3653 );
3654
3655 }
3656 else if (!name.empty()) // global variable
3657 {
3658 addVariableToFile(root,mtype,scope,type,name,args);
3659 }
3660
3661}
3662
3663//----------------------------------------------------------------------
3664// Searches the Entry tree for typedef documentation sections.
3665// If found they are stored in their class or in the global list.
3666static void buildTypedefList(const Entry *root)
3667{
3668 //printf("buildVarList(%s)\n",qPrint(rootNav->name()));
3669 if (!root->name.empty() &&
3670 root->section.isVariable() &&
3671 root->type.find("typedef ")!=DString::npos // its a typedef
3672 )
3673 {
3674 AUTO_TRACE();
3675 DString rname = removeRedundantWhiteSpace(root->name);
3676 DString scope;
3677 int index = computeQualifiedIndex(rname);
3678 if (index!=-1 && root->parent()->section.isGroupDoc() && root->parent()->tagInfo())
3679 // grouped members are stored with full scope
3680 {
3681 buildScopeFromQualifiedName(rname.left(index+2),root->lang,root->tagInfo());
3682 scope=rname.left(index);
3683 rname=rname.mid(index+2);
3684 }
3685 else
3686 {
3687 scope=root->parent()->name; //stripAnonymousNamespaceScope(root->parent->name);
3688 }
3692 bool found=false;
3693 if (mn) // symbol with the same name already found
3694 {
3695 for (auto &imd : *mn)
3696 {
3697 if (!imd->isTypedef())
3698 continue;
3699
3700 DString rtype = root->type;
3701 rtype.stripPrefix("typedef ");
3702
3703 // merge the typedefs only if they're not both grouped, and both are
3704 // either part of the same class, part of the same namespace, or both
3705 // are global (i.e., neither in a class or a namespace)
3706 bool notBothGrouped = root->groups.empty() || imd->getGroupDef()==nullptr; // see example #100
3707 bool bothSameScope = (!cd && !nd) || (cd && imd->getClassDef() == cd) || (nd && imd->getNamespaceDef() == nd);
3708 //printf("imd->isTypedef()=%d imd->typeString()=%s root->type=%s\n",imd->isTypedef(),
3709 // qPrint(imd->typeString()),qPrint(root->type));
3710 if (notBothGrouped && bothSameScope && imd->typeString()==rtype)
3711 {
3712 MemberDefMutable *md = toMemberDefMutable(imd.get());
3713 if (md)
3714 {
3715 md->setDocumentation(root->doc,root->docFile,root->docLine);
3717 md->setDocsForDefinition(!root->proto);
3718 md->setBriefDescription(root->brief,root->briefFile,root->briefLine);
3720 md->setRefItems(root->sli);
3721 md->setRequirementReferences(root->rqli);
3722 md->addQualifiers(root->qualifiers);
3723
3724 // merge ingroup specifiers
3725 if (md->getGroupDef()==nullptr && !root->groups.empty())
3726 {
3727 addMemberToGroups(root,md);
3728 }
3729 else if (md->getGroupDef()!=nullptr && root->groups.empty())
3730 {
3731 //printf("existing member is grouped, new member not\n");
3732 }
3733 else if (md->getGroupDef()!=nullptr && !root->groups.empty())
3734 {
3735 //printf("both members are grouped\n");
3736 }
3737 found=true;
3738 break;
3739 }
3740 }
3741 }
3742 }
3743 if (found)
3744 {
3745 AUTO_TRACE_ADD("typedef '{}' already found",rname);
3746 // mark the entry as processed, as we copied everything from it elsewhere
3747 // also, otherwise, due to containing `typedef` it may later get treated
3748 // as a function typedef in filterMemberDocumentation, which is incorrect
3749 root->markAsProcessed();
3750 }
3751 else
3752 {
3753 AUTO_TRACE_ADD("new typedef '{}'",rname);
3754 addVariable(root);
3755 }
3756
3757 }
3758 for (const auto &e : root->children())
3759 if (!e->section.isEnum())
3760 buildTypedefList(e.get());
3761}
3762
3763//----------------------------------------------------------------------
3764// Searches the Entry tree for sequence documentation sections.
3765// If found they are stored in the global list.
3766static void buildSequenceList(const Entry *root)
3767{
3768 if (!root->name.empty() &&
3769 root->section.isVariable() &&
3770 root->type.find("sequence<")!=DString::npos // it's a sequence
3771 )
3772 {
3773 AUTO_TRACE();
3774 addVariable(root);
3775 }
3776 for (const auto &e : root->children())
3777 if (!e->section.isEnum())
3778 buildSequenceList(e.get());
3779}
3780
3781//----------------------------------------------------------------------
3782// Searches the Entry tree for dictionary documentation sections.
3783// If found they are stored in the global list.
3784static void buildDictionaryList(const Entry *root)
3785{
3786 if (!root->name.empty() &&
3787 root->section.isVariable() &&
3788 root->type.find("dictionary<")!=DString::npos // it's a dictionary
3789 )
3790 {
3791 AUTO_TRACE();
3792 addVariable(root);
3793 }
3794 for (const auto &e : root->children())
3795 if (!e->section.isEnum())
3796 buildDictionaryList(e.get());
3797}
3798
3799//----------------------------------------------------------------------
3800// Searches the Entry tree for Variable documentation sections.
3801// If found they are stored in their class or in the global list.
3802
3803static void buildVarList(const Entry *root)
3804{
3805 //printf("buildVarList(%s) section=%08x\n",qPrint(rootNav->name()),rootNav->section());
3806 int isFuncPtr=-1;
3807 if (!root->name.empty() &&
3808 (root->type.empty() || g_compoundKeywords.find(root->type.str())==g_compoundKeywords.end()) &&
3809 (
3810 (root->section.isVariable() && // it's a variable
3811 root->type.find("typedef ")==DString::npos // and not a typedef
3812 ) ||
3813 (root->section.isFunction() && // or maybe a function pointer variable
3814 (isFuncPtr=findFunctionPtr(root->type.str(),root->lang))!=-1
3815 ) ||
3816 (root->section.isFunction() && // class variable initialized by constructor
3818 )
3819 )
3820 ) // documented variable
3821 {
3822 AUTO_TRACE();
3823 addVariable(root,isFuncPtr);
3824 }
3825 for (const auto &e : root->children())
3826 if (!e->section.isEnum())
3827 buildVarList(e.get());
3828}
3829
3830//----------------------------------------------------------------------
3831// Searches the Entry tree for Interface sections (UNO IDL only).
3832// If found they are stored in their service or in the global list.
3833//
3834
3836 const Entry *root,
3837 ClassDefMutable *cd,
3838 DString const& rname)
3839{
3840 FileDef *fd = root->fileDef();
3841 enum MemberType type = root->section.isExportedInterface() ? MemberType::Interface : MemberType::Service;
3842 DString fileName = root->fileName;
3843 if (fileName.empty() && root->tagInfo())
3844 {
3845 fileName = root->tagInfo()->tagName;
3846 }
3847 auto md = createMemberDef(
3848 fileName, root->startLine, root->startColumn, root->type, rname,
3849 "", "", root->protection, root->virt, root->isStatic, Relationship::Member,
3850 type, ArgumentList(), root->argList, root->metaData);
3851 auto mmd = toMemberDefMutable(md.get());
3852 mmd->setTagInfo(root->tagInfo());
3853 mmd->setMemberClass(cd);
3854 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
3855 mmd->setDocsForDefinition(false);
3856 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
3857 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
3858 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
3859 mmd->setMemberSpecifiers(root->spec);
3860 mmd->setVhdlSpecifiers(root->vhdlSpec);
3861 mmd->setMemberGroupId(root->mGrpId);
3862 mmd->setTypeConstraints(root->typeConstr);
3863 mmd->setLanguage(root->lang);
3864 mmd->setBodyDef(fd);
3865 mmd->setFileDef(fd);
3866 mmd->addSectionsToDefinition(root->anchors);
3867 DString const def = root->type + " " + rname;
3868 mmd->setDefinition(def);
3870 mmd->addQualifiers(root->qualifiers);
3871 addIncludeFile(mmd,fd,root);
3872
3873 AUTO_TRACE("Interface member: fileName='{}' type='{}' name='{}' mtype='{}' prot={} virt={} state={} proto={} def='{}'",
3874 fileName,root->type,rname,type,root->protection,root->virt,root->isStatic,root->proto,def);
3875
3876 // add member to the class cd
3877 cd->insertMember(md.get());
3878 // also add the member as a "base" (to get nicer diagrams)
3879 // "optional" interface/service get Protected which turns into dashed line
3880 BaseInfo base(rname,
3881 root->spec.isOptional() ? Protection::Protected : Protection::Public, Specifier::Normal);
3882 TemplateNameMap templateNames;
3883 findClassRelation(root,cd,cd,&base,templateNames,DocumentedOnly,true) ||
3884 findClassRelation(root,cd,cd,&base,templateNames,Undocumented,true);
3885 // add file to list of used files
3886 cd->insertUsedFile(fd);
3887
3888 addMemberToGroups(root,md.get());
3890 root->markAsProcessed();
3891 mmd->setRefItems(root->sli);
3892 mmd->setRequirementReferences(root->rqli);
3893
3894 // add member to the global list of all members
3896 mn->push_back(std::move(md));
3897}
3898
3899static void buildInterfaceAndServiceList(const Entry *root)
3900{
3901 if (root->section.isExportedInterface() || root->section.isIncludedService())
3902 {
3903 AUTO_TRACE("Exported interface/included service: type='{}' scope='{}' name='{}' args='{}'"
3904 " relates='{}' relatesType='{}' file='{}' line={} bodyLine={} #tArgLists={}"
3905 " mGrpId={} spec={} proto={} docFile='{}'",
3906 root->type, root->parent()->name, root->name, root->args,
3907 root->relates, root->relatesType, root->fileName, root->startLine, root->bodyLine, root->tArgLists.size(),
3908 root->mGrpId, root->spec, root->proto, root->docFile);
3909
3910 DString rname = removeRedundantWhiteSpace(root->name);
3911
3912 if (!rname.empty())
3913 {
3914 DString scope = root->parent()->name;
3915 ClassDefMutable *cd = getClassMutable(scope);
3916 ASSERT(cd);
3917 if (cd && ((ClassDef::Interface == cd->compoundType()) ||
3918 (ClassDef::Service == cd->compoundType()) ||
3920 {
3922 }
3923 else
3924 {
3925 ASSERT(false); // was checked by scanner.l
3926 }
3927 }
3928 else if (rname.empty())
3929 {
3930 warn(root->fileName,root->startLine,
3931 "Illegal member name found.");
3932 }
3933 }
3934 // can only have these in IDL anyway
3935 switch (root->lang)
3936 {
3937 case SrcLangExt::Unknown: // fall through (root node always is Unknown)
3938 case SrcLangExt::IDL:
3939 for (const auto &e : root->children()) buildInterfaceAndServiceList(e.get());
3940 break;
3941 default:
3942 return; // nothing to do here
3943 }
3944}
3945
3946
3947//----------------------------------------------------------------------
3948// Searches the Entry tree for Function sections.
3949// If found they are stored in their class or in the global list.
3950
3951static void addMethodToClass(const Entry *root,ClassDefMutable *cd,
3952 const DString &rtype,const DString &rname,const DString &rargs,
3953 bool isFriend,
3954 Protection protection,bool stat,Specifier virt,TypeSpecifier spec,
3955 const DString &relates
3956 )
3957{
3958 FileDef *fd=root->fileDef();
3959
3960 DString type = rtype;
3961 DString args = rargs;
3962
3964 name.stripPrefix("::");
3965
3966 MemberType mtype = MemberType::Function;
3967 if (isFriend) mtype=MemberType::Friend;
3968 else if (root->mtype==MethodTypes::Signal) mtype=MemberType::Signal;
3969 else if (root->mtype==MethodTypes::Slot) mtype=MemberType::Slot;
3970 else if (root->mtype==MethodTypes::DCOP) mtype=MemberType::DCOP;
3971
3972 // strip redundant template specifier for constructors
3973 size_t i = DString::npos;
3974 size_t j = DString::npos;
3975 if ((fd==nullptr || fd->getLanguage()==SrcLangExt::Cpp) &&
3976 !name.startsWith("operator ") && // not operator
3977 (i=name.find('<'))!=DString::npos && // containing <
3978 (j=name.find('>'))!=DString::npos && // or >
3979 (j!=i+2 || name.at(i+1)!='=') // but not the C++20 spaceship operator <=>
3980 )
3981 {
3982 name=name.left(i);
3983 }
3984
3985 DString fileName = root->fileName;
3986 if (fileName.empty() && root->tagInfo())
3987 {
3988 fileName = root->tagInfo()->tagName;
3989 }
3990
3991 //printf("root->name='%s; args='%s' root->argList='%s'\n",
3992 // qPrint(root->name),qPrint(args),qPrint(argListToString(root->argList))
3993 // );
3994
3995 // adding class member
3996 Relationship relationship = relates.empty() ? Relationship::Member :
3997 root->relatesType==RelatesType::MemberOf ? Relationship::Foreign :
3998 Relationship::Related ;
3999 auto md = createMemberDef(
4000 fileName,root->startLine,root->startColumn,
4001 type,name,args,root->exception,
4002 protection,virt,
4003 stat && root->relatesType!=RelatesType::MemberOf,
4004 relationship,
4005 mtype,!root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList(),
4006 root->argList, root->metaData);
4007 auto mmd = toMemberDefMutable(md.get());
4008 mmd->setTagInfo(root->tagInfo());
4009 mmd->setMemberClass(cd);
4010 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
4011 mmd->setDocsForDefinition(!root->proto);
4012 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
4013 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
4014 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
4015 mmd->setMemberSpecifiers(spec);
4016 mmd->setVhdlSpecifiers(root->vhdlSpec);
4017 mmd->setMemberGroupId(root->mGrpId);
4018 mmd->setTypeConstraints(root->typeConstr);
4019 mmd->setLanguage(root->lang);
4020 mmd->setRequiresClause(root->req);
4021 mmd->setId(root->id);
4022 mmd->setBodyDef(fd);
4023 mmd->setFileDef(fd);
4024 mmd->addSectionsToDefinition(root->anchors);
4025 addIncludeFile(mmd,fd,root);
4026 DString def;
4028 SrcLangExt lang = cd->getLanguage();
4029 DString scopeSeparator=getLanguageSpecificSeparator(lang);
4030 if (scopeSeparator!="::")
4031 {
4032 qualScope = substitute(qualScope,"::",scopeSeparator);
4033 }
4034 if (lang==SrcLangExt::PHP)
4035 {
4036 // for PHP we use Class::method and Namespace\method
4037 scopeSeparator="::";
4038 }
4039 if (!relates.empty() || isFriend || Config_getBool(HIDE_SCOPE_NAMES))
4040 {
4041 if (!type.empty())
4042 {
4043 def=type+" "+name; //+optArgs;
4044 }
4045 else
4046 {
4047 def=name; //+optArgs;
4048 }
4049 }
4050 else
4051 {
4052 if (!type.empty())
4053 {
4054 def=type+" "+qualScope+scopeSeparator+name; //+optArgs;
4055 }
4056 else
4057 {
4058 def=qualScope+scopeSeparator+name; //+optArgs;
4059 }
4060 }
4061 def.stripPrefix("friend ");
4062 mmd->setDefinition(def);
4064 mmd->addQualifiers(root->qualifiers);
4065
4066 AUTO_TRACE("function member: type='{}' scope='{}' name='{}' args='{}' proto={} def='{}'",
4067 type, qualScope, rname, args, root->proto, def);
4068
4069 // add member to the class cd
4070 cd->insertMember(md.get());
4071 // add file to list of used files
4072 cd->insertUsedFile(fd);
4073
4074 addMemberToGroups(root,md.get());
4076 root->markAsProcessed();
4077 mmd->setRefItems(root->sli);
4078 mmd->setRequirementReferences(root->rqli);
4079
4080 // add member to the global list of all members
4081 //printf("Adding member=%s class=%s\n",qPrint(md->name()),qPrint(cd->name()));
4083 mn->push_back(std::move(md));
4084}
4085
4086//------------------------------------------------------------------------------------------
4087
4088static void addGlobalFunction(const Entry *root,const DString &rname,const DString &sc)
4089{
4090 DString scope = sc;
4091
4092 // new global function
4094 auto md = createMemberDef(
4095 root->fileName,root->startLine,root->startColumn,
4096 root->type,name,root->args,root->exception,
4097 root->protection,root->virt,root->isStatic,Relationship::Member,
4098 MemberType::Function,
4099 !root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList(),
4100 root->argList,root->metaData);
4101 auto mmd = toMemberDefMutable(md.get());
4102 mmd->setTagInfo(root->tagInfo());
4103 mmd->setLanguage(root->lang);
4104 mmd->setId(root->id);
4105 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
4106 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
4107 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
4108 mmd->setPrototype(root->proto,root->fileName,root->startLine,root->startColumn);
4109 mmd->setDocsForDefinition(!root->proto);
4110 mmd->setTypeConstraints(root->typeConstr);
4111 //md->setBody(root->body);
4112 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
4113 FileDef *fd=root->fileDef();
4114 mmd->setBodyDef(fd);
4115 mmd->addSectionsToDefinition(root->anchors);
4116 mmd->setMemberSpecifiers(root->spec);
4117 mmd->setVhdlSpecifiers(root->vhdlSpec);
4118 mmd->setMemberGroupId(root->mGrpId);
4119 mmd->setRequiresClause(root->req);
4120 mmd->setExplicitExternal(root->explicitExternal,root->fileName,root->startLine,root->startColumn);
4121 addIncludeFile(mmd,fd,root);
4122
4123 NamespaceDefMutable *nd = nullptr;
4124 // see if the function is inside a namespace that was not part of
4125 // the name already (in that case nd should be non-zero already)
4126 if (root->parent()->section.isNamespace())
4127 {
4128 //DString nscope=removeAnonymousScopes(root->parent()->name);
4129 DString nscope=root->parent()->name;
4130 if (!nscope.empty())
4131 {
4132 nd = getResolvedNamespaceMutable(nscope);
4133 }
4134 }
4135 else if (root->parent()->section.isGroupDoc() && !scope.empty())
4136 {
4138 }
4139
4140 if (!scope.empty())
4141 {
4143 if (sep!="::")
4144 {
4145 scope = substitute(scope,"::",sep);
4146 }
4147 scope+=sep;
4148 }
4149
4150 if (Config_getBool(HIDE_SCOPE_NAMES) || root->lang==SrcLangExt::Python) scope = "";
4151 DString def;
4152 //DString optArgs = root->argList.empty() ? DString() : root->args;
4153 if (!root->type.empty())
4154 {
4155 def=root->type+" "+scope+name; //+optArgs;
4156 }
4157 else
4158 {
4159 def=scope+name; //+optArgs;
4160 }
4161 AUTO_TRACE("new non-member function type='{}' scope='{}' name='{}' args='{}' proto={} def='{}'",
4162 root->type,scope,rname,root->args,root->proto,def);
4163 mmd->setDefinition(def);
4165 mmd->addQualifiers(root->qualifiers);
4166
4167 mmd->setRefItems(root->sli);
4168 mmd->setRequirementReferences(root->rqli);
4169 if (nd && !nd->name().empty() && nd->name().at(0)!='@')
4170 {
4171 // add member to namespace
4172 mmd->setNamespace(nd);
4173 nd->insertMember(md.get());
4174 }
4175 if (fd)
4176 {
4177 // add member to the file (we do this even if we have already
4178 // inserted it into the namespace)
4179 mmd->setFileDef(fd);
4180 fd->insertMember(md.get());
4181 }
4182
4183 addMemberToGroups(root,md.get());
4185 if (root->relatesType == RelatesType::Simple) // if this is a relatesalso command,
4186 // allow find Member to pick it up
4187 {
4188 root->markAsProcessed(); // Otherwise we have finished with this entry.
4189 }
4190
4191 // add member to the list of file members
4193 mn->push_back(std::move(md));
4194}
4195
4196//------------------------------------------------------------------------------------------
4197
4198static void buildFunctionList(const Entry *root)
4199{
4200 if (root->section.isFunction())
4201 {
4202 AUTO_TRACE("member function: type='{}' scope='{}' name='{}' args='{}' relates='{}' relatesType='{}'"
4203 " file='{}' line={} bodyLine={} #tArgLists={} mGrpId={}"
4204 " spec={} proto={} docFile='{}'",
4205 root->type, root->parent()->name, root->name, root->args, root->relates, root->relatesType,
4206 root->fileName, root->startLine, root->bodyLine, root->tArgLists.size(), root->mGrpId,
4207 root->spec, root->proto, root->docFile);
4208
4209 bool isFriend=root->type=="friend" || root->type.find("friend ")!=DString::npos;
4210 DString rname = removeRedundantWhiteSpace(root->name);
4211 //printf("rname=%s\n",qPrint(rname));
4212
4213 DString scope;
4214 int index = computeQualifiedIndex(rname);
4215 if (index!=-1 && root->parent()->section.isGroupDoc() && root->parent()->tagInfo())
4216 // grouped members are stored with full scope
4217 {
4218 buildScopeFromQualifiedName(rname.left(index+2),root->lang,root->tagInfo());
4219 scope=rname.left(index);
4220 rname=rname.mid(index+2);
4221 }
4222 else
4223 {
4224 scope=root->parent()->name; //stripAnonymousNamespaceScope(root->parent->name);
4225 }
4226 if (!rname.empty() && scope.find('@')==DString::npos)
4227 {
4228 // check if this function's parent is a class
4229 if (root->lang==SrcLangExt::CSharp)
4230 {
4231 scope=mangleCSharpGenericName(scope);
4232 }
4233 else
4234 {
4235 scope=stripTemplateSpecifiersFromScope(scope,false);
4236 }
4237
4238 FileDef *rfd=root->fileDef();
4239
4240 size_t memIndex=rname.rfind("::");
4241
4243 if (cd && scope+"::"==rname.left(scope.length()+2)) // found A::f inside A
4244 {
4245 // strip scope from name
4246 rname=rname.mid(root->parent()->name.length()+2);
4247 }
4248
4249 bool isMember=false;
4250 if (memIndex!=DString::npos)
4251 {
4252 size_t ts=rname.find('<');
4253 size_t te=rname.find('>');
4254 if (memIndex>0 && (ts==DString::npos || te==DString::npos))
4255 {
4256 // note: the following code was replaced by inMember=true to deal with a
4257 // function rname='X::foo' of class X inside a namespace also called X...
4258 // bug id 548175
4259 //nd = Doxygen::namespaceLinkedMap->find(rname.left(memIndex));
4260 //isMember = nd==nullptr;
4261 //if (nd)
4262 //{
4263 // // strip namespace scope from name
4264 // scope=rname.left(memIndex);
4265 // rname=rname.mid(memIndex+2);
4266 //}
4267 isMember = true;
4268 }
4269 else
4270 {
4271 isMember=memIndex<ts || memIndex>te;
4272 }
4273 }
4274
4275 if (!root->parent()->name.empty() && root->parent()->section.isCompound() && cd)
4276 {
4277 AUTO_TRACE_ADD("member '{}' of class '{}'", rname,cd->name());
4278 addMethodToClass(root,cd,root->type,rname,root->args,isFriend,
4279 root->protection,root->isStatic,root->virt,root->spec,root->relates);
4280 }
4281 else if (root->parent()->section.isObjcImpl() && cd)
4282 {
4283 const MemberDef *md = cd->getMemberByName(rname);
4284 if (md)
4285 {
4286 MemberDefMutable *mdm = toMemberDefMutable(const_cast<MemberDef*>(md));
4287 if (mdm)
4288 {
4289 mdm->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
4290 mdm->setBodyDef(root->fileDef());
4291 }
4292 }
4293 }
4294 else if (!root->parent()->section.isCompound() && !root->parent()->section.isObjcImpl() &&
4295 !isMember &&
4296 (root->relates.empty() || root->relatesType==RelatesType::Duplicate) &&
4297 !root->type.startsWith("extern ") && !root->type.startsWith("typedef ")
4298 )
4299 // no member => unrelated function
4300 {
4301 /* check the uniqueness of the function name in the file.
4302 * A file could contain a function prototype and a function definition
4303 * or even multiple function prototypes.
4304 */
4305 bool found=false;
4306 MemberDef *md_found=nullptr;
4308 if (mn)
4309 {
4310 AUTO_TRACE_ADD("function '{}' already found",rname);
4311 for (const auto &imd : *mn)
4312 {
4313 MemberDefMutable *md = toMemberDefMutable(imd.get());
4314 if (md)
4315 {
4316 const NamespaceDef *mnd = md->getNamespaceDef();
4317 NamespaceDef *rnd = nullptr;
4318 //printf("root namespace=%s\n",qPrint(rootNav->parent()->name()));
4319 DString fullScope = scope;
4320 DString parentScope = root->parent()->name;
4321 if (!parentScope.empty() && !leftScopeMatch(parentScope,scope))
4322 {
4323 if (!scope.empty()) fullScope.prepend("::");
4324 fullScope.prepend(parentScope);
4325 }
4326 //printf("fullScope=%s\n",qPrint(fullScope));
4327 rnd = getResolvedNamespace(fullScope);
4328 const FileDef *mfd = md->getFileDef();
4329 DString nsName,rnsName;
4330 if (mnd) nsName = mnd->name();
4331 if (rnd) rnsName = rnd->name();
4332 //printf("matching arguments for %s%s %s%s\n",
4333 // qPrint(md->name()),md->argsString(),qPrint(rname),qPrint(argListToString(root->argList)));
4334 const ArgumentList &mdAl = md->argumentList();
4335 const ArgumentList &mdTempl = md->templateArguments();
4336
4337 // in case of template functions, we need to check if the
4338 // functions have the same number of template parameters
4339 bool sameTemplateArgs = true;
4340 bool matchingReturnTypes = true;
4341 bool sameRequiresClause = true;
4342 if (!mdTempl.empty() && !root->tArgLists.empty())
4343 {
4344 sameTemplateArgs = matchTemplateArguments(mdTempl,root->tArgLists.back());
4345 if (md->typeString()!=removeRedundantWhiteSpace(root->type))
4346 {
4347 matchingReturnTypes = false;
4348 }
4349 if (md->requiresClause()!=root->req)
4350 {
4351 sameRequiresClause = false;
4352 }
4353 }
4354 else if (!mdTempl.empty() || !root->tArgLists.empty())
4355 { // if one has template parameters and the other doesn't then that also counts as a
4356 // difference
4357 sameTemplateArgs = false;
4358 }
4359
4360 bool staticsInDifferentFiles =
4361 root->isStatic && md->isStatic() && root->fileName!=md->getDefFileName();
4362
4363 if (sameTemplateArgs &&
4364 matchingReturnTypes &&
4365 sameRequiresClause &&
4366 !staticsInDifferentFiles &&
4367 matchArguments2(md->getOuterScope(),mfd,md->typeString(),&mdAl,
4368 rnd ? rnd : Doxygen::globalScope,rfd,root->type,&root->argList,
4369 false,root->lang)
4370 )
4371 {
4372 GroupDef *gd=nullptr;
4373 if (!root->groups.empty() && !root->groups.front().groupname.empty())
4374 {
4375 gd = Doxygen::groupLinkedMap->find(root->groups.front().groupname);
4376 }
4377 //printf("match!\n");
4378 //printf("mnd=%p rnd=%p nsName=%s rnsName=%s\n",mnd,rnd,qPrint(nsName),qPrint(rnsName));
4379 // see if we need to create a new member
4380 found=(mnd && rnd && nsName==rnsName) || // members are in the same namespace
4381 ((mnd==nullptr && rnd==nullptr && mfd!=nullptr && // no external reference and
4382 mfd->absFilePath()==root->fileName // prototype in the same file
4383 )
4384 );
4385 // otherwise, allow a duplicate global member with the same argument list
4386 if (!found && gd && gd==md->getGroupDef() && nsName==rnsName)
4387 {
4388 // member is already in the group, so we don't want to add it again.
4389 found=true;
4390 }
4391
4392 AUTO_TRACE_ADD("combining function with prototype found={} in namespace '{}'",found,nsName);
4393
4394 if (found)
4395 {
4396 // merge argument lists
4397 ArgumentList mergedArgList = root->argList;
4398 mergeArguments(const_cast<ArgumentList&>(mdAl),mergedArgList,!root->doc.empty());
4399 // merge documentation
4400 if (md->documentation().empty() && !root->doc.empty())
4401 {
4402 if (root->proto)
4403 {
4405 }
4406 else
4407 {
4409 }
4410 }
4411
4412 md->setDocumentation(root->doc,root->docFile,root->docLine);
4414 md->setDocsForDefinition(!root->proto);
4415 if (md->getStartBodyLine()==-1 && root->bodyLine!=-1)
4416 {
4417 md->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
4418 md->setBodyDef(rfd);
4419 }
4420
4421 if (md->briefDescription().empty() && !root->brief.empty())
4422 {
4423 md->setArgsString(root->args);
4424 }
4425 md->setBriefDescription(root->brief,root->briefFile,root->briefLine);
4426
4428
4430 md->addQualifiers(root->qualifiers);
4431
4432 // merge ingroup specifiers
4433 if (md->getGroupDef()==nullptr && !root->groups.empty())
4434 {
4435 addMemberToGroups(root,md);
4436 }
4437 else if (md->getGroupDef()!=nullptr && root->groups.empty())
4438 {
4439 //printf("existing member is grouped, new member not\n");
4440 }
4441 else if (md->getGroupDef()!=nullptr && !root->groups.empty())
4442 {
4443 //printf("both members are grouped\n");
4444 }
4446
4447 // if md is a declaration and root is the corresponding
4448 // definition, then turn md into a definition.
4449 if (md->isPrototype() && !root->proto)
4450 {
4451 md->setDeclFile(md->getDefFileName(),md->getDefLine(),md->getDefColumn());
4452 md->setPrototype(false,root->fileName,root->startLine,root->startColumn);
4453 }
4454 // if md is already the definition, then add the declaration info
4455 else if (!md->isPrototype() && root->proto)
4456 {
4457 md->setDeclFile(root->fileName,root->startLine,root->startColumn);
4458 }
4459 }
4460 }
4461 }
4462 if (found)
4463 {
4464 md_found = md;
4465 break;
4466 }
4467 }
4468 }
4469 if (!found) /* global function is unique with respect to the file */
4470 {
4471 addGlobalFunction(root,rname,scope);
4472 }
4473 else
4474 {
4475 FileDef *fd=root->fileDef();
4476 if (fd)
4477 {
4478 // add member to the file (we do this even if we have already
4479 // inserted it into the namespace)
4480 fd->insertMember(md_found);
4481 }
4482 }
4483
4484 AUTO_TRACE_ADD("unrelated function type='{}' name='{}' args='{}'",root->type,rname,root->args);
4485 }
4486 else
4487 {
4488 AUTO_TRACE_ADD("function '{}' is not processed",rname);
4489 }
4490 }
4491 else if (rname.empty())
4492 {
4493 warn(root->fileName,root->startLine,
4494 "Illegal member name found."
4495 );
4496 }
4497 }
4498 for (const auto &e : root->children()) buildFunctionList(e.get());
4499}
4500
4501//----------------------------------------------------------------------
4502
4503static void findFriends()
4504{
4505 AUTO_TRACE();
4506 for (const auto &fn : *Doxygen::functionNameLinkedMap) // for each global function name
4507 {
4508 MemberName *mn = Doxygen::memberNameLinkedMap->find(fn->memberName());
4509 if (mn)
4510 { // there are members with the same name
4511 // for each function with that name
4512 for (const auto &ifmd : *fn)
4513 {
4514 MemberDefMutable *fmd = toMemberDefMutable(ifmd.get());
4515 // for each member with that name
4516 for (const auto &immd : *mn)
4517 {
4518 MemberDefMutable *mmd = toMemberDefMutable(immd.get());
4519 //printf("Checking for matching arguments
4520 // mmd->isRelated()=%d mmd->isFriend()=%d mmd->isFunction()=%d\n",
4521 // mmd->isRelated(),mmd->isFriend(),mmd->isFunction());
4522 if (fmd && mmd &&
4523 (mmd->isFriend() || (mmd->isRelated() && mmd->isFunction())) &&
4524 matchArguments2(mmd->getOuterScope(), mmd->getFileDef(), mmd->typeString(), &mmd->argumentList(),
4525 fmd->getOuterScope(), fmd->getFileDef(), fmd->typeString(), &fmd->argumentList(),
4526 true,mmd->getLanguage()
4527 )
4528
4529 ) // if the member is related and the arguments match then the
4530 // function is actually a friend.
4531 {
4532 AUTO_TRACE_ADD("Merging related global and member '{}' isFriend={} isRelated={} isFunction={}",
4533 mmd->name(),mmd->isFriend(),mmd->isRelated(),mmd->isFunction());
4534 const ArgumentList &mmdAl = mmd->argumentList();
4535 const ArgumentList &fmdAl = fmd->argumentList();
4536 mergeArguments(const_cast<ArgumentList&>(fmdAl),const_cast<ArgumentList&>(mmdAl));
4537
4538 // reset argument lists to add missing default parameters
4539 DString mmdAlStr = argListToString(mmdAl);
4540 DString fmdAlStr = argListToString(fmdAl);
4541 mmd->setArgsString(mmdAlStr);
4542 fmd->setArgsString(fmdAlStr);
4543 mmd->moveDeclArgumentList(std::make_unique<ArgumentList>(mmdAl));
4544 fmd->moveDeclArgumentList(std::make_unique<ArgumentList>(fmdAl));
4545 AUTO_TRACE_ADD("friend args='{}' member args='{}'",argListToString(fmd->argumentList()),argListToString(mmd->argumentList()));
4546
4547 if (!fmd->documentation().empty())
4548 {
4549 mmd->setDocumentation(fmd->documentation(),fmd->docFile(),fmd->docLine());
4550 }
4551 else if (!mmd->documentation().empty())
4552 {
4553 fmd->setDocumentation(mmd->documentation(),mmd->docFile(),mmd->docLine());
4554 }
4555 if (mmd->briefDescription().empty() && !fmd->briefDescription().empty())
4556 {
4557 mmd->setBriefDescription(fmd->briefDescription(),fmd->briefFile(),fmd->briefLine());
4558 }
4559 else if (!mmd->briefDescription().empty() && !fmd->briefDescription().empty())
4560 {
4561 fmd->setBriefDescription(mmd->briefDescription(),mmd->briefFile(),mmd->briefLine());
4562 }
4563 if (!fmd->inbodyDocumentation().empty())
4564 {
4566 }
4567 else if (!mmd->inbodyDocumentation().empty())
4568 {
4570 }
4571 //printf("body mmd %d fmd %d\n",mmd->getStartBodyLine(),fmd->getStartBodyLine());
4572 if (mmd->getStartBodyLine()==-1 && fmd->getStartBodyLine()!=-1)
4573 {
4574 mmd->setBodySegment(fmd->getDefLine(),fmd->getStartBodyLine(),fmd->getEndBodyLine());
4575 mmd->setBodyDef(fmd->getBodyDef());
4576 //mmd->setBodyMember(fmd);
4577 }
4578 else if (mmd->getStartBodyLine()!=-1 && fmd->getStartBodyLine()==-1)
4579 {
4580 fmd->setBodySegment(mmd->getDefLine(),mmd->getStartBodyLine(),mmd->getEndBodyLine());
4581 fmd->setBodyDef(mmd->getBodyDef());
4582 //fmd->setBodyMember(mmd);
4583 }
4585
4587
4588 mmd->addQualifiers(fmd->getQualifiers());
4589 fmd->addQualifiers(mmd->getQualifiers());
4590
4591 }
4592 }
4593 }
4594 }
4595 }
4596}
4597
4598//----------------------------------------------------------------------
4599
4601{
4602 AUTO_TRACE();
4603
4604 // find matching function declaration and definitions.
4605 for (const auto &mn : *Doxygen::functionNameLinkedMap)
4606 {
4607 //printf("memberName=%s count=%zu\n",qPrint(mn->memberName()),mn->size());
4608 /* find a matching function declaration and definition for this function */
4609 for (const auto &imdec : *mn)
4610 {
4611 MemberDefMutable *mdec = toMemberDefMutable(imdec.get());
4612 if (mdec &&
4613 (mdec->isPrototype() ||
4614 (mdec->isVariable() && mdec->isExternal())
4615 ))
4616 {
4617 for (const auto &imdef : *mn)
4618 {
4619 MemberDefMutable *mdef = toMemberDefMutable(imdef.get());
4620 if (mdef && mdec!=mdef &&
4621 mdec->getNamespaceDef()==mdef->getNamespaceDef())
4622 {
4624 }
4625 }
4626 }
4627 }
4628 }
4629}
4630
4631//----------------------------------------------------------------------
4632
4634{
4635 AUTO_TRACE();
4636 for (const auto &mn : *Doxygen::functionNameLinkedMap)
4637 {
4638 MemberDefMutable *mdef=nullptr,*mdec=nullptr;
4639 /* find a matching function declaration and definition for this function */
4640 for (const auto &imd : *mn)
4641 {
4642 MemberDefMutable *md = toMemberDefMutable(imd.get());
4643 if (md)
4644 {
4645 if (md->isPrototype())
4646 mdec=md;
4647 else if (md->isVariable() && md->isExternal())
4648 mdec=md;
4649
4650 if (md->isFunction() && !md->isStatic() && !md->isPrototype())
4651 mdef=md;
4652 else if (md->isVariable() && !md->isExternal() && !md->isStatic())
4653 mdef=md;
4654 }
4655
4656 if (mdef && mdec) break;
4657 }
4658 if (mdef && mdec)
4659 {
4660 const ArgumentList &mdefAl = mdef->argumentList();
4661 const ArgumentList &mdecAl = mdec->argumentList();
4662 if (
4663 matchArguments2(mdef->getOuterScope(),mdef->getFileDef(),mdef->typeString(),const_cast<ArgumentList*>(&mdefAl),
4664 mdec->getOuterScope(),mdec->getFileDef(),mdec->typeString(),const_cast<ArgumentList*>(&mdecAl),
4665 true,mdef->getLanguage()
4666 )
4667 ) /* match found */
4668 {
4669 AUTO_TRACE_ADD("merging references for mdec={} mdef={}",mdec->name(),mdef->name());
4670 mdef->mergeReferences(mdec);
4671 mdec->mergeReferences(mdef);
4672 mdef->mergeReferencedBy(mdec);
4673 mdec->mergeReferencedBy(mdef);
4674 }
4675 }
4676 }
4677}
4678
4679//----------------------------------------------------------------------
4680
4682{
4683 AUTO_TRACE();
4684 // find match between function declaration and definition for
4685 // related functions
4686 for (const auto &mn : *Doxygen::functionNameLinkedMap)
4687 {
4688 /* find a matching function declaration and definition for this function */
4689 // for each global function
4690 for (const auto &imd : *mn)
4691 {
4692 MemberDefMutable *md = toMemberDefMutable(imd.get());
4693 if (md)
4694 {
4695 //printf(" Function '%s'\n",qPrint(md->name()));
4697 if (rmn) // check if there is a member with the same name
4698 {
4699 //printf(" Member name found\n");
4700 // for each member with the same name
4701 for (const auto &irmd : *rmn)
4702 {
4703 MemberDefMutable *rmd = toMemberDefMutable(irmd.get());
4704 //printf(" Member found: related='%d'\n",rmd->isRelated());
4705 if (rmd &&
4706 (rmd->isRelated() || rmd->isForeign()) && // related function
4707 matchArguments2( md->getOuterScope(), md->getFileDef(), md->typeString(), &md->argumentList(),
4708 rmd->getOuterScope(),rmd->getFileDef(),rmd->typeString(),&rmd->argumentList(),
4709 true,md->getLanguage()
4710 )
4711 )
4712 {
4713 AUTO_TRACE_ADD("Found related member '{}'",md->name());
4714 if (rmd->relatedAlso())
4715 md->setRelatedAlso(rmd->relatedAlso());
4716 else if (rmd->isForeign())
4717 md->makeForeign();
4718 else
4719 md->makeRelated();
4720 }
4721 }
4722 }
4723 }
4724 }
4725 }
4726}
4727
4728//----------------------------------------------------------------------
4729
4731{
4732 AUTO_TRACE();
4733 for (const auto &[qualifiedName,bodyInfo] : Doxygen::staticInitMap)
4734 {
4735 size_t i=qualifiedName.rfind("::");
4736 if (i!=std::string::npos)
4737 {
4738 DString scope = qualifiedName.substr(0,i);
4739 DString name = qualifiedName.substr(i+2);
4741 if (mn)
4742 {
4743 for (const auto &imd : *mn)
4744 {
4745 MemberDefMutable *md = toMemberDefMutable(imd.get());
4746 if (md && md->qualifiedName().str()==qualifiedName && md->isVariable())
4747 {
4748 AUTO_TRACE_ADD("found static member {} body [{}..{}]\n",
4749 md->qualifiedName(),bodyInfo.startLine,bodyInfo.endLine);
4750 md->setBodySegment(bodyInfo.defLine,
4751 bodyInfo.startLine,
4752 bodyInfo.endLine);
4753 }
4754 }
4755 }
4756 }
4757 }
4758}
4759
4760//----------------------------------------------------------------------
4761
4762/*! make a dictionary of all template arguments of class cd
4763 * that are part of the base class name.
4764 * Example: A template class A with template arguments <R,S,T>
4765 * that inherits from B<T,T,S> will have T and S in the dictionary.
4766 */
4767static TemplateNameMap getTemplateArgumentsInName(const ArgumentList &templateArguments,const std::string &name)
4768{
4769 std::map<std::string,int> templateNames;
4770 int count=0;
4771 for (const Argument &arg : templateArguments)
4772 {
4773 static const reg::Ex re(R"(\a[\w:]*)");
4774 reg::Iterator it(name,re);
4776 for (; it!=end ; ++it)
4777 {
4778 const auto &match = *it;
4779 std::string n = match.str();
4780 if (n==arg.name.str())
4781 {
4782 if (templateNames.find(n)==templateNames.end())
4783 {
4784 templateNames.emplace(n,count);
4785 }
4786 }
4787 }
4788 }
4789 return templateNames;
4790}
4791
4792/*! Searches a class from within \a context and \a cd and returns its
4793 * definition if found (otherwise nullptr is returned).
4794 */
4796{
4797 ClassDef *result=nullptr;
4798 if (cd==nullptr)
4799 {
4800 return result;
4801 }
4802 FileDef *fd=cd->getFileDef();
4803 SymbolResolver resolver(fd);
4804 if (context && cd!=context)
4805 {
4806 result = const_cast<ClassDef*>(resolver.resolveClass(context,name,true,true));
4807 }
4808 //printf("1. result=%p\n",result);
4809 if (result==nullptr)
4810 {
4811 result = const_cast<ClassDef*>(resolver.resolveClass(cd,name,true,true));
4812 }
4813 //printf("2. result=%p\n",result);
4814 if (result==nullptr) // try direct class, needed for namespaced classes imported via tag files (see bug624095)
4815 {
4816 result = getClass(name);
4817 }
4818 //printf("3. result=%p\n",result);
4819 //printf("** Trying to find %s within context %s class %s result=%s lookup=%p\n",
4820 // qPrint(name),
4821 // context ? qPrint(context->name()) : "<none>",
4822 // cd ? qPrint(cd->name()) : "<none>",
4823 // result ? qPrint(result->name()) : "<none>",
4824 // Doxygen::classLinkedMap->find(name)
4825 // );
4826 return result;
4827}
4828
4829
4830static void findUsedClassesForClass(const Entry *root,
4831 Definition *context,
4832 ClassDefMutable *masterCd,
4833 ClassDefMutable *instanceCd,
4834 bool isArtificial,
4835 const ArgumentList *actualArgs = nullptr,
4836 const TemplateNameMap &templateNames = TemplateNameMap()
4837 )
4838{
4839 AUTO_TRACE();
4840 const ArgumentList &formalArgs = masterCd->templateArguments();
4841 for (auto &mni : masterCd->memberNameInfoLinkedMap())
4842 {
4843 for (auto &mi : *mni)
4844 {
4845 const MemberDef *md=mi->memberDef();
4846 if (md->isVariable() || md->isObjCProperty()) // for each member variable in this class
4847 {
4848 AUTO_TRACE_ADD("Found variable '{}' in class '{}'",md->name(),masterCd->name());
4849 DString type = normalizeNonTemplateArgumentsInString(md->typeString(),masterCd,formalArgs);
4850 DString typedefValue = md->getLanguage()==SrcLangExt::Java ? type : resolveTypeDef(masterCd,type);
4851 if (!typedefValue.empty())
4852 {
4853 type = typedefValue;
4854 }
4855 int pos=0;
4856 DString usedClassName;
4857 DString templSpec;
4858 bool found=false;
4859 // the type can contain template variables, replace them if present
4860 type = substituteTemplateArgumentsInString(type,formalArgs,actualArgs);
4861
4862 //printf(" template substitution gives=%s\n",qPrint(type));
4863 while (!found && extractClassNameFromType(type,pos,usedClassName,templSpec,root->lang)!=-1)
4864 {
4865 // find the type (if any) that matches usedClassName
4866 SymbolResolver resolver(masterCd->getFileDef());
4867 const ClassDefMutable *typeCd = resolver.resolveClassMutable(masterCd,usedClassName,false,true);
4868 //printf("====> usedClassName=%s -> typeCd=%s\n",
4869 // qPrint(usedClassName),typeCd?qPrint(typeCd->name()):"<none>");
4870 if (typeCd)
4871 {
4872 usedClassName = typeCd->name();
4873 }
4874
4875 // replace any namespace aliases
4876 replaceNamespaceAliases(usedClassName);
4877 // add any template arguments to the class
4878 DString usedName = removeRedundantWhiteSpace(usedClassName+templSpec);
4879 //printf(" usedName=%s usedClassName=%s templSpec=%s\n",qPrint(usedName),qPrint(usedClassName),qPrint(templSpec));
4880
4881 TemplateNameMap formTemplateNames;
4882 if (templateNames.empty())
4883 {
4884 formTemplateNames = getTemplateArgumentsInName(formalArgs,usedName.str());
4885 }
4886 BaseInfo bi(usedName,Protection::Public,Specifier::Normal);
4887 findClassRelation(root,context,instanceCd,&bi,formTemplateNames,TemplateInstances,isArtificial);
4888
4889 for (const Argument &arg : masterCd->templateArguments())
4890 {
4891 if (arg.name==usedName) // type is a template argument
4892 {
4893 ClassDef *usedCd = Doxygen::hiddenClassLinkedMap->find(usedName);
4894 ClassDefMutable *usedCdm = toClassDefMutable(usedCd);
4895 if (usedCd==nullptr)
4896 {
4897 usedCdm = toClassDefMutable(
4898 Doxygen::hiddenClassLinkedMap->add(usedName,
4900 masterCd->getDefFileName(),masterCd->getDefLine(),
4901 masterCd->getDefColumn(),
4902 usedName,
4903 ClassDef::Class)));
4904 if (usedCdm)
4905 {
4906 //printf("making %s a template argument!!!\n",qPrint(usedCd->name()));
4907 usedCdm->makeTemplateArgument();
4908 usedCdm->setUsedOnly(true);
4909 usedCdm->setLanguage(masterCd->getLanguage());
4910 usedCd = usedCdm;
4911 }
4912 }
4913 if (usedCd)
4914 {
4915 found=true;
4916 AUTO_TRACE_ADD("case 1: adding used class '{}'", usedCd->name());
4917 instanceCd->addUsedClass(usedCd,md->name(),md->protection());
4918 if (usedCdm)
4919 {
4920 if (isArtificial) usedCdm->setArtificial(true);
4921 usedCdm->addUsedByClass(instanceCd,md->name(),md->protection());
4922 }
4923 }
4924 }
4925 }
4926
4927 if (!found)
4928 {
4929 ClassDef *usedCd=findClassWithinClassContext(context,masterCd,usedName);
4930 //printf("Looking for used class %s: result=%s master=%s\n",
4931 // qPrint(usedName),usedCd?qPrint(usedCd->name()):"<none>",masterCd?qPrint(masterCd->name()):"<none>");
4932
4933 if (usedCd)
4934 {
4935 found=true;
4936 AUTO_TRACE_ADD("case 2: adding used class '{}'", usedCd->name());
4937 instanceCd->addUsedClass(usedCd,md->name(),md->protection()); // class exists
4938 ClassDefMutable *usedCdm = toClassDefMutable(usedCd);
4939 if (usedCdm)
4940 {
4941 usedCdm->addUsedByClass(instanceCd,md->name(),md->protection());
4942 }
4943 }
4944 }
4945 }
4946 if (!found && !type.empty()) // used class is not documented in any scope
4947 {
4949 ClassDefMutable *usedCdm = toClassDefMutable(usedCd);
4950 if (usedCd==nullptr && !Config_getBool(HIDE_UNDOC_RELATIONS))
4951 {
4952 if (type.endsWith("(*") || type.endsWith("(^")) // type is a function pointer
4953 {
4954 type+=md->argsString();
4955 }
4956 AUTO_TRACE_ADD("New undocumented used class '{}'", type);
4957 usedCdm = toClassDefMutable(
4960 masterCd->getDefFileName(),masterCd->getDefLine(),
4961 masterCd->getDefColumn(),
4962 type,ClassDef::Class)));
4963 if (usedCdm)
4964 {
4965 usedCdm->setUsedOnly(true);
4966 usedCdm->setLanguage(masterCd->getLanguage());
4967 usedCd = usedCdm;
4968 }
4969 }
4970 if (usedCd)
4971 {
4972 AUTO_TRACE_ADD("case 3: adding used class '{}'", usedCd->name());
4973 instanceCd->addUsedClass(usedCd,md->name(),md->protection());
4974 if (usedCdm)
4975 {
4976 if (isArtificial) usedCdm->setArtificial(true);
4977 usedCdm->addUsedByClass(instanceCd,md->name(),md->protection());
4978 }
4979 }
4980 }
4981 }
4982 }
4983 }
4984}
4985
4987 const Entry *root,
4988 Definition *context,
4989 ClassDefMutable *masterCd,
4990 ClassDefMutable *instanceCd,
4992 bool isArtificial,
4993 const ArgumentList *actualArgs = nullptr,
4994 const TemplateNameMap &templateNames=TemplateNameMap()
4995 )
4996{
4997 AUTO_TRACE("name={}",root->name);
4998 // The base class could ofcouse also be a non-nested class
4999 const ArgumentList &formalArgs = masterCd->templateArguments();
5000 for (const BaseInfo &bi : root->extends)
5001 {
5002 //printf("masterCd=%s bi.name='%s' #actualArgs=%d\n",
5003 // qPrint(masterCd->localName()),qPrint(bi.name),actualArgs ? (int)actualArgs->size() : -1);
5004 TemplateNameMap formTemplateNames;
5005 if (templateNames.empty())
5006 {
5007 formTemplateNames = getTemplateArgumentsInName(formalArgs,bi.name.str());
5008 }
5009 BaseInfo tbi = bi;
5010 tbi.name = substituteTemplateArgumentsInString(bi.name,formalArgs,actualArgs);
5011 //printf("masterCd=%p instanceCd=%p bi->name=%s tbi.name=%s\n",(void*)masterCd,(void*)instanceCd,qPrint(bi.name),qPrint(tbi.name));
5012
5013 if (mode==DocumentedOnly)
5014 {
5015 // find a documented base class in the correct scope
5016 if (!findClassRelation(root,context,instanceCd,&tbi,formTemplateNames,DocumentedOnly,isArtificial))
5017 {
5018 // 1.8.2: decided to show inheritance relations even if not documented,
5019 // we do make them artificial, so they do not appear in the index
5020 //if (!Config_getBool(HIDE_UNDOC_RELATIONS))
5021 bool b = Config_getBool(HIDE_UNDOC_RELATIONS) ? true : isArtificial;
5022 //{
5023 // no documented base class -> try to find an undocumented one
5024 findClassRelation(root,context,instanceCd,&tbi,formTemplateNames,Undocumented,b);
5025 //}
5026 }
5027 }
5028 else if (mode==TemplateInstances)
5029 {
5030 findClassRelation(root,context,instanceCd,&tbi,formTemplateNames,TemplateInstances,isArtificial);
5031 }
5032 }
5033}
5034
5035//----------------------------------------------------------------------
5036
5037static void findTemplateInstanceRelation(const Entry *root,
5038 Definition *context,
5039 ClassDefMutable *templateClass,const DString &templSpec,
5040 const TemplateNameMap &templateNames,
5041 bool isArtificial)
5042{
5043 AUTO_TRACE("Derived from template '{}' with parameters '{}' isArtificial={}",
5044 templateClass->name(),templSpec,isArtificial);
5045
5046 DString tempArgsStr = tempArgListToString(templateClass->templateArguments(),root->lang,false);
5047 bool existingClass = templSpec==tempArgsStr;
5048 if (existingClass) return; // avoid recursion
5049
5050 bool freshInstance=false;
5051 ClassDefMutable *instanceClass = toClassDefMutable(
5052 templateClass->insertTemplateInstance(
5053 root->fileName,root->startLine,root->startColumn,templSpec,freshInstance));
5054 if (instanceClass)
5055 {
5056 if (freshInstance)
5057 {
5058 instanceClass->setArtificial(true);
5059 instanceClass->setLanguage(root->lang);
5060
5061 AUTO_TRACE_ADD("found fresh instance '{}'",instanceClass->name());
5062 instanceClass->setTemplateBaseClassNames(templateNames);
5063
5064 // search for new template instances caused by base classes of
5065 // instanceClass
5066 auto it_pair = g_classEntries.equal_range(templateClass->name().str());
5067 for (auto it=it_pair.first ; it!=it_pair.second ; ++it)
5068 {
5069 const Entry *templateRoot = it->second;
5070 AUTO_TRACE_ADD("template root found '{}' templSpec='{}'",templateRoot->name,templSpec);
5071 std::unique_ptr<ArgumentList> templArgs = stringToArgumentList(root->lang,templSpec);
5072 findBaseClassesForClass(templateRoot,context,templateClass,instanceClass,
5073 TemplateInstances,isArtificial,templArgs.get(),templateNames);
5074
5075 findUsedClassesForClass(templateRoot,context,templateClass,instanceClass,
5076 isArtificial,templArgs.get(),templateNames);
5077 }
5078 }
5079 else
5080 {
5081 AUTO_TRACE_ADD("instance already exists");
5082 }
5083 }
5084}
5085
5086//----------------------------------------------------------------------
5087
5088static void resolveTemplateInstanceInType(const Entry *root,const Definition *scope,const MemberDef *md)
5089{
5090 // For a statement like 'using X = T<A>', add a template instance 'T<A>' as a symbol, so it can
5091 // be used to match arguments (see issue #11111)
5092 AUTO_TRACE();
5093 DString ttype = md->typeString();
5094 ttype.stripPrefix("typedef ");
5095 if (size_t ti=ttype.find('<'); ti!=DString::npos)
5096 {
5097 DString templateClassName = ttype.left(ti);
5098 SymbolResolver resolver(root->fileDef());
5099 ClassDefMutable *baseClass = resolver.resolveClassMutable(scope ? scope : Doxygen::globalScope,
5100 templateClassName, true, true);
5101 AUTO_TRACE_ADD("templateClassName={} baseClass={}",templateClassName,baseClass?baseClass->name():"<none>");
5102 if (baseClass)
5103 {
5104 const ArgumentList &tl = baseClass->templateArguments();
5105 TemplateNameMap templateNames = getTemplateArgumentsInName(tl,templateClassName.str());
5107 baseClass,
5108 ttype.mid(ti),
5109 templateNames,
5110 baseClass->isArtificial());
5111 }
5112 }
5113}
5114
5115//----------------------------------------------------------------------
5116
5117static bool isRecursiveBaseClass(const DString &scope,const DString &name)
5118{
5119 DString n=name;
5120 if (size_t index=n.find('<'); index!=DString::npos)
5121 {
5122 n=n.left(index);
5123 }
5124 bool result = rightScopeMatch(scope,n);
5125 return result;
5126}
5127
5129{
5130 if (name.empty()) return 0;
5131 int l = static_cast<int>(name.length());
5132 if (name[l-1]=='>') // search backward to find the matching <, allowing nested <...> and strings.
5133 {
5134 int count=1;
5135 int i=l-2;
5136 char insideQuote=0;
5137 while (count>0 && i>=0)
5138 {
5139 char c = name[i--];
5140 switch (c)
5141 {
5142 case '>': if (!insideQuote) count++; break;
5143 case '<': if (!insideQuote) count--; break;
5144 case '\'': if (!insideQuote) insideQuote=c;
5145 else if (insideQuote==c && (i<0 || name[i]!='\\')) insideQuote=0;
5146 break;
5147 case '"': if (!insideQuote) insideQuote=c;
5148 else if (insideQuote==c && (i<0 || name[i]!='\\')) insideQuote=0;
5149 break;
5150 default: break;
5151 }
5152 }
5153 if (i>=0) l=i+1;
5154 }
5155 return l;
5156}
5157
5159 const Entry *root,
5160 Definition *context,
5161 ClassDefMutable *cd,
5162 const BaseInfo *bi,
5163 const TemplateNameMap &templateNames,
5165 bool isArtificial
5166 )
5167{
5168 AUTO_TRACE("name={} base={} isArtificial={} mode={}",cd->name(),bi->name,isArtificial,(int)mode);
5169
5170 DString biName=bi->name;
5171 bool explicitGlobalScope=false;
5172 if (biName.startsWith("::")) // explicit global scope
5173 {
5174 biName=biName.mid(2);
5175 explicitGlobalScope=true;
5176 }
5177
5178 Entry *parentNode=root->parent();
5179 bool lastParent=false;
5180 do // for each parent scope, starting with the largest scope
5181 // (in case of nested classes)
5182 {
5183 DString scopeName= parentNode ? parentNode->name : DString();
5184 int scopeOffset=explicitGlobalScope ? 0 : static_cast<int>(scopeName.length());
5185 do // try all parent scope prefixes, starting with the largest scope
5186 {
5187 //printf("scopePrefix='%s' biName='%s'\n",
5188 // qPrint(scopeName.left(scopeOffset)),qPrint(biName));
5189
5190 DString baseClassName=biName;
5191 if (scopeOffset>0)
5192 {
5193 baseClassName.prepend(scopeName.left(scopeOffset)+"::");
5194 }
5195 if (root->lang==SrcLangExt::CSharp)
5196 {
5197 baseClassName = mangleCSharpGenericName(baseClassName);
5198 }
5199 AUTO_TRACE_ADD("cd='{}' baseClassName='{}'",cd->name(),baseClassName);
5200 SymbolResolver resolver(cd->getFileDef());
5201 ClassDefMutable *baseClass = resolver.resolveClassMutable(explicitGlobalScope ? Doxygen::globalScope : context,
5202 baseClassName,
5203 mode==Undocumented,
5204 true
5205 );
5206 const MemberDef *baseClassTypeDef = resolver.getTypedef();
5207 DString templSpec = resolver.getTemplateSpec();
5208 //printf("baseClassName=%s baseClass=%p cd=%p explicitGlobalScope=%d\n",
5209 // qPrint(baseClassName),baseClass,cd,explicitGlobalScope);
5210 //printf(" scope='%s' baseClassName='%s' baseClass=%s templSpec=%s\n",
5211 // cd ? qPrint(cd->name()):"<none>",
5212 // qPrint(baseClassName),
5213 // baseClass?qPrint(baseClass->name()):"<none>",
5214 // qPrint(templSpec)
5215 // );
5216 //if (baseClassName.left(root->name.length())!=root->name ||
5217 // baseClassName.at(root->name.length())!='<'
5218 // ) // Check for base class with the same name.
5219 // // If found then look in the outer scope for a match
5220 // // and prevent recursion.
5221 if (!isRecursiveBaseClass(root->name,baseClassName)
5222 || explicitGlobalScope
5223 // sadly isRecursiveBaseClass always true for UNO IDL ifc/svc members
5224 // (i.e. this is needed for addInterfaceOrServiceToServiceOrSingleton)
5225 || (root->lang==SrcLangExt::IDL &&
5226 (root->section.isExportedInterface() ||
5227 root->section.isIncludedService()))
5228 )
5229 {
5230 AUTO_TRACE_ADD("class relation '{}' inherited/used by '{}' found prot={} virt={} templSpec='{}'",
5231 baseClassName, root->name, bi->prot, bi->virt, templSpec);
5232
5233 int i=findTemplateSpecializationPosition(baseClassName);
5234 size_t si=baseClassName.rfind("::",i);
5235 if (si==DString::npos) si=0;
5236 if (baseClass==nullptr && static_cast<size_t>(i)!=baseClassName.length())
5237 // base class has template specifiers
5238 {
5239 // TODO: here we should try to find the correct template specialization
5240 // but for now, we only look for the unspecialized base class.
5241 int e=findEndOfTemplate(baseClassName,i+1);
5242 //printf("baseClass==0 i=%d e=%d\n",i,e);
5243 if (e!=-1) // end of template was found at e
5244 {
5245 templSpec = removeRedundantWhiteSpace(baseClassName.mid(i,e-i));
5246 baseClassName = baseClassName.left(i)+baseClassName.mid(e);
5247 baseClass = resolver.resolveClassMutable(explicitGlobalScope ? Doxygen::globalScope : context,
5248 baseClassName,
5249 mode==Undocumented,
5250 true
5251 );
5252 baseClassTypeDef = resolver.getTypedef();
5253 //printf("baseClass=%p -> baseClass=%s templSpec=%s\n",
5254 // baseClass,qPrint(baseClassName),qPrint(templSpec));
5255 }
5256 }
5257 else if (baseClass && !templSpec.empty()) // we have a known class, but also
5258 // know it is a template, so see if
5259 // we can also link to the explicit
5260 // instance (for instance if a class
5261 // derived from a template argument)
5262 {
5263 //printf("baseClass=%s templSpec=%s\n",qPrint(baseClass->name()),qPrint(templSpec));
5264 ClassDefMutable *templClass=getClassMutable(baseClass->name()+templSpec);
5265 if (templClass)
5266 {
5267 // use the template instance instead of the template base.
5268 baseClass = templClass;
5269 templSpec.clear();
5270 }
5271 }
5272
5273 //printf("cd=%p baseClass=%p\n",cd,baseClass);
5274 bool found=baseClass!=nullptr && (baseClass!=cd || mode==TemplateInstances);
5275 AUTO_TRACE_ADD("1. found={}",found);
5276 if (!found && si!=DString::npos)
5277 {
5278 // replace any namespace aliases
5279 replaceNamespaceAliases(baseClassName);
5280 baseClass = resolver.resolveClassMutable(explicitGlobalScope ? Doxygen::globalScope : context,
5281 baseClassName,
5282 mode==Undocumented,
5283 true
5284 );
5285 baseClassTypeDef = resolver.getTypedef();
5286 found=baseClass!=nullptr && baseClass!=cd;
5287 if (found) templSpec = resolver.getTemplateSpec();
5288 }
5289 AUTO_TRACE_ADD("2. found={}",found);
5290
5291 if (!found)
5292 {
5293 baseClass=toClassDefMutable(findClassWithinClassContext(context,cd,baseClassName));
5294 //printf("findClassWithinClassContext(%s,%s)=%p\n",
5295 // qPrint(cd->name()),qPrint(baseClassName),baseClass);
5296 found = baseClass!=nullptr && baseClass!=cd;
5297
5298 }
5299 AUTO_TRACE_ADD("3. found={}",found);
5300 if (!found)
5301 {
5302 // for PHP the "use A\B as C" construct map class C to A::B, so we lookup
5303 // the class name also in the alias mapping.
5304 auto it = Doxygen::namespaceAliasMap.find(baseClassName.str());
5305 if (it!=Doxygen::namespaceAliasMap.end()) // see if it is indeed a class.
5306 {
5307 baseClass=getClassMutable(it->second.alias);
5308 found = baseClass!=nullptr && baseClass!=cd;
5309 }
5310 }
5311 bool isATemplateArgument = templateNames.find(biName.str())!=templateNames.end();
5312
5313 AUTO_TRACE_ADD("4. found={}",found);
5314 if (found)
5315 {
5316 AUTO_TRACE_ADD("Documented base class '{}' templSpec='{}'",biName,templSpec);
5317 // add base class to this class
5318
5319 // if templSpec is not empty then we should "instantiate"
5320 // the template baseClass. A new ClassDef should be created
5321 // to represent the instance. To be able to add the (instantiated)
5322 // members and documentation of a template class
5323 // (inserted in that template class at a later stage),
5324 // the template should know about its instances.
5325 // the instantiation process, should be done in a recursive way,
5326 // since instantiating a template may introduce new inheritance
5327 // relations.
5328 if (!templSpec.empty() && mode==TemplateInstances)
5329 {
5330 // if baseClass is actually a typedef then we should not
5331 // instantiate it, since typedefs are in a different namespace
5332 // see bug531637 for an example where this would otherwise hang
5333 // Doxygen
5334 if (baseClassTypeDef==nullptr)
5335 {
5336 //printf(" => findTemplateInstanceRelation: %s\n",qPrint(baseClass->name()));
5337 findTemplateInstanceRelation(root,context,baseClass,templSpec,templateNames,baseClass->isArtificial());
5338 }
5339 }
5340 else if (mode==DocumentedOnly || mode==Undocumented)
5341 {
5342 //printf(" => insert base class\n");
5343 DString usedName;
5344 if (baseClassTypeDef)
5345 {
5346 usedName=biName;
5347 //printf("***** usedName=%s templSpec=%s\n",qPrint(usedName),qPrint(templSpec));
5348 }
5349 Protection prot = bi->prot;
5350 if (Config_getBool(SIP_SUPPORT)) prot=Protection::Public;
5351 if (cd!=baseClass && !cd->isSubClass(baseClass) && baseClass->isBaseClass(cd,true,templSpec)==0) // check for recursion, see bug690787
5352 {
5353 AUTO_TRACE_ADD("insertBaseClass name={} prot={} virt={} templSpec={}",usedName,prot,bi->virt,templSpec);
5354 cd->insertBaseClass(baseClass,usedName,prot,bi->virt,templSpec);
5355 // add this class as super class to the base class
5356 baseClass->insertSubClass(cd,prot,bi->virt,templSpec);
5357 }
5358 else
5359 {
5360 warn(root->fileName,root->startLine,
5361 "Detected potential recursive class relation "
5362 "between class {} and base class {}!",
5363 cd->name(),baseClass->name()
5364 );
5365 }
5366 }
5367 return true;
5368 }
5369 else if (mode==Undocumented && (scopeOffset==0 || isATemplateArgument))
5370 {
5371 AUTO_TRACE_ADD("New undocumented base class '{}' baseClassName='{}' templSpec='{}' isArtificial={}",
5372 biName,baseClassName,templSpec,isArtificial);
5373 baseClass=nullptr;
5374 if (isATemplateArgument)
5375 {
5376 baseClass = toClassDefMutable(Doxygen::hiddenClassLinkedMap->find(baseClassName));
5377 if (baseClass==nullptr) // not found (or alias)
5378 {
5379 baseClass= toClassDefMutable(
5380 Doxygen::hiddenClassLinkedMap->add(baseClassName,
5381 createClassDef(root->fileName,root->startLine,root->startColumn,
5382 baseClassName,
5383 ClassDef::Class)));
5384 if (baseClass) // really added (not alias)
5385 {
5386 if (isArtificial) baseClass->setArtificial(true);
5387 baseClass->setLanguage(root->lang);
5388 }
5389 }
5390 }
5391 else
5392 {
5393 baseClass = toClassDefMutable(Doxygen::classLinkedMap->find(baseClassName));
5394 //printf("*** classDDict->find(%s)=%p biName=%s templSpec=%s\n",
5395 // qPrint(baseClassName),baseClass,qPrint(biName),qPrint(templSpec));
5396 if (baseClass==nullptr) // not found (or alias)
5397 {
5398 baseClass = toClassDefMutable(
5399 Doxygen::classLinkedMap->add(baseClassName,
5400 createClassDef(root->fileName,root->startLine,root->startColumn,
5401 baseClassName,
5402 ClassDef::Class)));
5403 if (baseClass) // really added (not alias)
5404 {
5405 if (isArtificial) baseClass->setArtificial(true);
5406 baseClass->setLanguage(root->lang);
5407 si = baseClassName.rfind("::");
5408 if (si!=DString::npos) // class is nested
5409 {
5410 Definition *sd = findScopeFromQualifiedName(Doxygen::globalScope,baseClassName.left(si),nullptr,root->tagInfo());
5411 if (sd==nullptr || sd==Doxygen::globalScope) // outer scope not found
5412 {
5413 baseClass->setArtificial(true); // see bug678139
5414 }
5415 }
5416 }
5417 }
5418 }
5419 if (baseClass)
5420 {
5421 if (biName.endsWith("-p"))
5422 {
5423 biName="<"+biName.left(biName.length()-2)+">";
5424 }
5425 if (!cd->isSubClass(baseClass) && cd!=baseClass && cd->isBaseClass(baseClass,true,templSpec)==0) // check for recursion
5426 {
5427 AUTO_TRACE_ADD("insertBaseClass name={} prot={} virt={} templSpec={}",biName,bi->prot,bi->virt,templSpec);
5428 // add base class to this class
5429 cd->insertBaseClass(baseClass,biName,bi->prot,bi->virt,templSpec);
5430 // add this class as super class to the base class
5431 baseClass->insertSubClass(cd,bi->prot,bi->virt,templSpec);
5432 }
5433 // the undocumented base was found in this file
5434 baseClass->insertUsedFile(root->fileDef());
5435
5436 Definition *scope = buildScopeFromQualifiedName(baseClass->name(),root->lang,nullptr);
5437 if (scope!=baseClass)
5438 {
5439 baseClass->setOuterScope(scope);
5440 }
5441
5442 if (baseClassName.endsWith("-p"))
5443 {
5445 }
5446 return true;
5447 }
5448 else
5449 {
5450 AUTO_TRACE_ADD("Base class '{}' not created (alias?)",biName);
5451 }
5452 }
5453 else
5454 {
5455 AUTO_TRACE_ADD("Base class '{}' not found",biName);
5456 }
5457 }
5458 else
5459 {
5460 if (mode!=TemplateInstances)
5461 {
5462 warn(root->fileName,root->startLine,
5463 "Detected potential recursive class relation "
5464 "between class {} and base class {}!",
5465 root->name,baseClassName
5466 );
5467 }
5468 // for mode==TemplateInstance this case is quite common and
5469 // indicates a relation between a template class and a template
5470 // instance with the same name.
5471 }
5472 if (scopeOffset==0)
5473 {
5474 scopeOffset=-1;
5475 }
5476 else
5477 {
5478 size_t o = scopeName.rfind("::",scopeOffset-1);
5479 scopeOffset = o!=DString::npos ? static_cast<int>(o) : 0;
5480 }
5481 //printf("new scopeOffset='%d'",scopeOffset);
5482 } while (scopeOffset>=0);
5483
5484 if (parentNode==nullptr)
5485 {
5486 lastParent=true;
5487 }
5488 else
5489 {
5490 parentNode=parentNode->parent();
5491 }
5492 } while (lastParent);
5493
5494 return false;
5495}
5496
5497//----------------------------------------------------------------------
5498// Computes the base and super classes for each class in the tree
5499
5500static bool isClassSection(const Entry *root)
5501{
5502 if ( !root->name.empty() )
5503 {
5504 if (root->section.isCompound())
5505 // is it a compound (class, struct, record, union, interface ...)
5506 {
5507 return true;
5508 }
5509 else if (root->section.isCompoundDoc())
5510 // is it a documentation block with inheritance info.
5511 {
5512 bool hasExtends = !root->extends.empty();
5513 if (hasExtends) return true;
5514 }
5515 }
5516 return false;
5517}
5518
5519
5520/*! Builds a dictionary of all entry nodes in the tree starting with \a root
5521 */
5522static void findClassEntries(const Entry *root)
5523{
5524 if (isClassSection(root))
5525 {
5526 g_classEntries.emplace(root->name.str(),root);
5527 }
5528 for (const auto &e : root->children()) findClassEntries(e.get());
5529}
5530
5531static DString extractClassName(const Entry *root)
5532{
5533 // strip any anonymous scopes first
5536 if (size_t i=bName.find('<'); (root->lang==SrcLangExt::CSharp || root->lang==SrcLangExt::Java) && i!=DString::npos)
5537 {
5538 // a Java/C# generic class looks like a C++ specialization, so we need to strip the
5539 // template part before looking for matches
5540 if (root->lang==SrcLangExt::CSharp)
5541 {
5542 bName = mangleCSharpGenericName(root->name);
5543 }
5544 else
5545 {
5546 bName = bName.left(i);
5547 }
5548 }
5549 return bName;
5550}
5551
5552/*! Using the dictionary build by findClassEntries(), this
5553 * function will look for additional template specialization that
5554 * exists as inheritance relations only. These instances will be
5555 * added to the template they are derived from.
5556 */
5558{
5559 AUTO_TRACE();
5560 ClassDefSet visitedClasses;
5561 for (const auto &[name,root] : g_classEntries)
5562 {
5563 DString bName = extractClassName(root);
5564 ClassDefMutable *cdm = getClassMutable(bName);
5565 if (cdm)
5566 {
5567 findBaseClassesForClass(root,cdm,cdm,cdm,TemplateInstances,false);
5568 }
5569 }
5570}
5571
5573{
5574 AUTO_TRACE("root->name={} cd={}",root->name,cd->name());
5575 size_t i = root->name.find('<');
5576 size_t j = root->name.rfind('>');
5577 size_t k = j!=DString::npos ? root->name.find("::",j+1) : DString::npos; // A<T::B> => ok, A<T>::B => nok
5578 if (i!=DString::npos && j!=DString::npos && k==DString::npos && root->lang!=SrcLangExt::CSharp && root->lang!=SrcLangExt::Java)
5579 {
5580 ClassDefMutable *master = getClassMutable(root->name.left(i));
5581 if (master && master!=cd && !cd->templateMaster())
5582 {
5583 AUTO_TRACE_ADD("class={} master={}",cd->name(),cd->templateMaster()?cd->templateMaster()->name():"<none>",master->name());
5584 cd->setTemplateMaster(master);
5585 master->insertExplicitTemplateInstance(cd,root->name.mid(i));
5586 }
5587 }
5588}
5589
5591{
5592 AUTO_TRACE();
5593 for (const auto &[name,root] : g_classEntries)
5594 {
5595 DString bName = extractClassName(root);
5596 ClassDefMutable *cdm = getClassMutable(bName);
5597 if (cdm)
5598 {
5599 findUsedClassesForClass(root,cdm,cdm,cdm,true);
5601 cdm->addTypeConstraints();
5602 }
5603 }
5604}
5605
5607{
5608 AUTO_TRACE();
5609 for (const auto &nd : *Doxygen::namespaceLinkedMap)
5610 {
5611 if (!nd->hasDocumentation())
5612 {
5613 if ((EntryType::guessSection(nd->getDefFileName()).isHeader() ||
5614 nd->getLanguage() == SrcLangExt::Fortran) && // Fortran doesn't have header files.
5615 !Config_getBool(HIDE_UNDOC_NAMESPACES) // undocumented namespaces are visible
5616 )
5617 {
5618 warn_undoc(nd->getDefFileName(),nd->getDefLine(), "{} {} is not documented.",
5619 nd->getLanguage() == SrcLangExt::Fortran ? "Module" : "Namespace",
5620 nd->name());
5621 }
5622 }
5623 }
5624}
5625
5627{
5628 AUTO_TRACE();
5629 for (const auto &[name,root] : g_classEntries)
5630 {
5631 DString bName = extractClassName(root);
5632 ClassDefMutable *cd = getClassMutable(bName);
5633 if (cd)
5634 {
5635 findBaseClassesForClass(root,cd,cd,cd,DocumentedOnly,false);
5636 }
5637 size_t numMembers = cd ? cd->memberNameInfoLinkedMap().size() : 0;
5638 if ((cd==nullptr || (!cd->hasDocumentation() && !cd->isReference())) && numMembers>0 && !bName.endsWith("::"))
5639 {
5640 if (!root->name.empty() && root->name.find('@')==DString::npos && // normal name
5641 (EntryType::guessSection(root->fileName).isHeader() ||
5642 Config_getBool(EXTRACT_LOCAL_CLASSES)) && // not defined in source file
5643 protectionLevelVisible(root->protection) && // hidden by protection
5644 !Config_getBool(HIDE_UNDOC_CLASSES) // undocumented class are visible
5645 )
5646 warn_undoc(root->fileName,root->startLine, "Compound {} is not documented.", root->name);
5647 }
5648 }
5649}
5650
5652{
5653 AUTO_TRACE();
5654 for (const auto &[name,root] : g_classEntries)
5655 {
5659 // strip any anonymous scopes first
5660 if (cd && !cd->getTemplateInstances().empty())
5661 {
5662 AUTO_TRACE_ADD("Template class '{}'",cd->name());
5663 for (const auto &ti : cd->getTemplateInstances()) // for each template instance
5664 {
5665 ClassDefMutable *tcd=toClassDefMutable(ti.classDef);
5666 if (tcd && tcd->isImplicitTemplateInstance()) // (partial) specializations have their own base classes
5667 {
5668 AUTO_TRACE_ADD("Template instance '{}'",tcd->name());
5669 DString templSpec = ti.templSpec;
5670 std::unique_ptr<ArgumentList> templArgs = stringToArgumentList(tcd->getLanguage(),templSpec);
5671 for (const BaseInfo &bi : root->extends)
5672 {
5673 // check if the base class is a template argument
5674 BaseInfo tbi = bi;
5675 const ArgumentList &tl = cd->templateArguments();
5676 if (!tl.empty())
5677 {
5678 TemplateNameMap baseClassNames = tcd->getTemplateBaseClassNames();
5679 TemplateNameMap templateNames = getTemplateArgumentsInName(tl,bi.name.str());
5680 // for each template name that we inherit from we need to
5681 // substitute the formal with the actual arguments
5682 TemplateNameMap actualTemplateNames;
5683 for (const auto &tn_kv : templateNames)
5684 {
5685 size_t templIndex = tn_kv.second;
5686 Argument actArg;
5687 bool hasActArg=false;
5688 if (templIndex<templArgs->size())
5689 {
5690 actArg=templArgs->at(templIndex);
5691 hasActArg=true;
5692 }
5693 if (hasActArg &&
5694 baseClassNames.find(actArg.type.str())!=baseClassNames.end() &&
5695 actualTemplateNames.find(actArg.type.str())==actualTemplateNames.end()
5696 )
5697 {
5698 actualTemplateNames.emplace(actArg.type.str(),static_cast<int>(templIndex));
5699 }
5700 }
5701
5702 tbi.name = substituteTemplateArgumentsInString(bi.name,tl,templArgs.get());
5703 // find a documented base class in the correct scope
5704 if (!findClassRelation(root,cd,tcd,&tbi,actualTemplateNames,DocumentedOnly,false))
5705 {
5706 // no documented base class -> try to find an undocumented one
5707 findClassRelation(root,cd,tcd,&tbi,actualTemplateNames,Undocumented,true);
5708 }
5709 }
5710 }
5711 }
5712 }
5713 }
5714 }
5715}
5716
5717//-----------------------------------------------------------------------
5718// compute the references (anchors in HTML) for each function in the file
5719
5721{
5722 AUTO_TRACE();
5723 for (const auto &cd : *Doxygen::classLinkedMap)
5724 {
5725 ClassDefMutable *cdm = toClassDefMutable(cd.get());
5726 if (cdm)
5727 {
5728 cdm->computeAnchors();
5729 }
5730 }
5731 for (const auto &fn : *Doxygen::inputNameLinkedMap)
5732 {
5733 for (const auto &fd : *fn)
5734 {
5735 fd->computeAnchors();
5736 }
5737 }
5738 for (const auto &nd : *Doxygen::namespaceLinkedMap)
5739 {
5741 if (ndm)
5742 {
5743 ndm->computeAnchors();
5744 }
5745 }
5746 for (const auto &gd : *Doxygen::groupLinkedMap)
5747 {
5748 gd->computeAnchors();
5749 }
5750}
5751
5752//----------------------------------------------------------------------
5753
5754
5755template<typename Func>
5756static void applyToAllDefinitions(Func func)
5757{
5758 for (const auto &cd : *Doxygen::classLinkedMap)
5759 {
5760 ClassDefMutable *cdm = toClassDefMutable(cd.get());
5761 if (cdm)
5762 {
5763 func(cdm);
5764 }
5765 }
5766
5767 for (const auto &cd : *Doxygen::conceptLinkedMap)
5768 {
5769 ConceptDefMutable *cdm = toConceptDefMutable(cd.get());
5770 if (cdm)
5771 {
5772 func(cdm);
5773 }
5774 }
5775
5776 for (const auto &fn : *Doxygen::inputNameLinkedMap)
5777 {
5778 for (const auto &fd : *fn)
5779 {
5780 func(fd.get());
5781 }
5782 }
5783
5784 for (const auto &nd : *Doxygen::namespaceLinkedMap)
5785 {
5787 if (ndm)
5788 {
5789 func(ndm);
5790 }
5791 }
5792
5793 for (const auto &gd : *Doxygen::groupLinkedMap)
5794 {
5795 func(gd.get());
5796 }
5797
5798 for (const auto &pd : *Doxygen::pageLinkedMap)
5799 {
5800 func(pd.get());
5801 }
5802
5803 for (const auto &dd : *Doxygen::dirLinkedMap)
5804 {
5805 func(dd.get());
5806 }
5807
5808 func(&ModuleManager::instance());
5809}
5810
5811//----------------------------------------------------------------------
5812
5814{
5815 AUTO_TRACE();
5816 applyToAllDefinitions([](auto* obj) { obj->addRequirementReferences(); });
5817}
5818
5819//----------------------------------------------------------------------
5820
5822{
5823 AUTO_TRACE();
5824 applyToAllDefinitions([](auto* obj) { obj->addListReferences(); });
5825}
5826
5827
5828//----------------------------------------------------------------------
5829
5831{
5832 AUTO_TRACE();
5834 {
5835 rl->generatePage();
5836 }
5837}
5838
5839//----------------------------------------------------------------------
5840// Copy the documentation in entry 'root' to member definition 'md' and
5841// set the function declaration of the member to 'funcDecl'. If the boolean
5842// over_load is set the standard overload text is added.
5843
5844static void addMemberDocs(const Entry *root,
5845 MemberDefMutable *md, const DString &funcDecl,
5846 const ArgumentList *al,
5847 bool over_load,
5848 TypeSpecifier spec
5849 )
5850{
5851 if (md==nullptr) return;
5852 AUTO_TRACE("scope='{}' name='{}' args='{}' funcDecl='{}' mSpec={}",
5853 root->parent()->name,md->name(),md->argsString(),funcDecl,spec);
5854 if (!root->section.isDoc()) // @fn or @var does not need to specify the complete definition, so don't overwrite it
5855 {
5856 DString fDecl=funcDecl;
5857 // strip extern specifier
5858 fDecl.stripPrefix("extern ");
5859 md->setDefinition(fDecl);
5860 }
5862 md->addQualifiers(root->qualifiers);
5864 const NamespaceDef *nd=md->getNamespaceDef();
5865 DString fullName;
5866 if (cd)
5867 fullName = cd->name();
5868 else if (nd)
5869 fullName = nd->name();
5870
5871 if (!fullName.empty()) fullName+="::";
5872 fullName+=md->name();
5873 FileDef *rfd=root->fileDef();
5874
5875 // TODO determine scope based on root not md
5876 Definition *rscope = md->getOuterScope();
5877
5878 const ArgumentList &mdAl = md->argumentList();
5879 if (al)
5880 {
5881 ArgumentList mergedAl = *al;
5882 //printf("merging arguments (1) docs=%d\n",root->doc.empty());
5883 mergeArguments(const_cast<ArgumentList&>(mdAl),mergedAl,!root->doc.empty());
5884 }
5885 else
5886 {
5887 if (
5888 matchArguments2( md->getOuterScope(), md->getFileDef(),md->typeString(),const_cast<ArgumentList*>(&mdAl),
5889 rscope,rfd,root->type,&root->argList,
5890 true, root->lang
5891 )
5892 )
5893 {
5894 //printf("merging arguments (2)\n");
5895 ArgumentList mergedArgList = root->argList;
5896 mergeArguments(const_cast<ArgumentList&>(mdAl),mergedArgList,!root->doc.empty());
5897 }
5898 }
5899 if (over_load) // the \overload keyword was used
5900 {
5902 if (!root->doc.empty())
5903 {
5904 doc+="<p>";
5905 doc+=root->doc;
5906 }
5907 md->setDocumentation(doc,root->docFile,root->docLine);
5909 md->setDocsForDefinition(!root->proto);
5910 }
5911 else
5912 {
5913 //printf("overwrite!\n");
5914 md->setDocumentation(root->doc,root->docFile,root->docLine);
5915 md->setDocsForDefinition(!root->proto);
5916
5917 //printf("overwrite!\n");
5918 md->setBriefDescription(root->brief,root->briefFile,root->briefLine);
5919
5920 if (
5921 (md->inbodyDocumentation().empty() ||
5922 !root->parent()->name.empty()
5923 ) && !root->inbodyDocs.empty()
5924 )
5925 {
5927 }
5928 }
5929
5930 //printf("initializer: '%s'(isEmpty=%d) '%s'(isEmpty=%d)\n",
5931 // qPrint(md->initializer()),md->initializer().empty(),
5932 // qPrint(root->initializer),root->initializer.empty()
5933 // );
5934 std::string rootInit = root->initializer.str();
5935 if (md->initializer().empty() && !rootInit.empty())
5936 {
5937 //printf("setInitializer\n");
5938 md->setInitializer(rootInit);
5939 }
5940 if (md->requiresClause().empty() && !root->req.empty())
5941 {
5942 md->setRequiresClause(root->req);
5943 }
5944
5945 md->setMaxInitLines(root->initLines);
5946
5947 if (rfd)
5948 {
5949 if ((md->getStartBodyLine()==-1 && root->bodyLine!=-1)
5950 )
5951 {
5952 //printf("Setting new body segment [%d,%d]\n",root->bodyLine,root->endBodyLine);
5953 md->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
5954 md->setBodyDef(rfd);
5955 }
5956
5957 md->setRefItems(root->sli);
5958 md->setRequirementReferences(root->rqli);
5959 }
5960
5962 md->addQualifiers(root->qualifiers);
5963
5964 md->mergeMemberSpecifiers(spec);
5966 addMemberToGroups(root,md);
5967 addIncludeFile(md,rfd,root);
5969 if (cd) cd->insertUsedFile(rfd);
5970 //printf("root->mGrpId=%d\n",root->mGrpId);
5971 if (root->mGrpId!=-1)
5972 {
5973 if (md->getMemberGroupId()!=-1)
5974 {
5975 if (md->getMemberGroupId()!=root->mGrpId)
5976 {
5977 warn(root->fileName,root->startLine,
5978 "member {} belongs to two different groups. The second one found here will be ignored.",
5979 md->name()
5980 );
5981 }
5982 }
5983 else // set group id
5984 {
5985 //printf("setMemberGroupId=%d md=%s\n",root->mGrpId,qPrint(md->name()));
5986 md->setMemberGroupId(root->mGrpId);
5987 }
5988 }
5989 md->addQualifiers(root->qualifiers);
5990}
5991
5992//----------------------------------------------------------------------
5993// find a class definition given the scope name and (optionally) a
5994// template list specifier
5995
5997 const DString &scopeName)
5998{
5999 SymbolResolver resolver(fd);
6000 const ClassDef *tcd = resolver.resolveClass(nd,scopeName,true,true);
6001 //printf("findClassDefinition(fd=%s,ns=%s,scopeName=%s)='%s'\n",
6002 // qPrint(fd?fd->name():""),qPrint(nd?nd->name():""),
6003 // qPrint(scopeName),qPrint(tcd?tcd->name():""));
6004 return tcd;
6005}
6006
6007//----------------------------------------------------------------------------
6008// Returns true, if the entry belongs to the group of the member definition,
6009// otherwise false.
6010
6011static bool isEntryInGroupOfMember(const Entry *root,const MemberDef *md,bool allowNoGroup=false)
6012{
6013 const GroupDef *gd = md->getGroupDef();
6014 if (!gd)
6015 {
6016 return allowNoGroup;
6017 }
6018
6019 for (const auto &g : root->groups)
6020 {
6021 if (g.groupname == gd->name())
6022 {
6023 return true; // matching group
6024 }
6025 }
6026
6027 return false;
6028}
6029
6030//----------------------------------------------------------------------
6031// Adds the documentation contained in 'root' to a global function
6032// with name 'name' and argument list 'args' (for overloading) and
6033// function declaration 'decl' to the corresponding member definition.
6034
6035static bool findGlobalMember(const Entry *root,
6036 const DString &namespaceName,
6037 const DString &type,
6038 const DString &name,
6039 const DString &tempArg,
6040 const DString &,
6041 const DString &decl,
6042 TypeSpecifier /* spec */)
6043{
6044 AUTO_TRACE("namespace='{}' type='{}' name='{}' tempArg='{}' decl='{}'",namespaceName,type,name,tempArg,decl);
6045 DString n=name;
6046 if (n.empty()) return false;
6047 if (n.find("::")!=DString::npos) return false; // skip undefined class members
6048 MemberName *mn=Doxygen::functionNameLinkedMap->find(n+tempArg); // look in function dictionary
6049 if (mn==nullptr)
6050 {
6051 mn=Doxygen::functionNameLinkedMap->find(n); // try without template arguments
6052 }
6053 if (mn) // function name defined
6054 {
6055 AUTO_TRACE_ADD("Found symbol name");
6056 //int count=0;
6057 bool found=false;
6058 for (const auto &md : *mn)
6059 {
6060 // If the entry has groups, then restrict the search to members which are
6061 // in one of the groups of the entry. If md is not associated with a group yet,
6062 // allow this documentation entry to add the group info.
6063 if (!root->groups.empty() && !isEntryInGroupOfMember(root, md.get(), true))
6064 {
6065 continue;
6066 }
6067
6068 const NamespaceDef *nd=nullptr;
6069 if (md->isAlias() && md->getOuterScope() &&
6070 md->getOuterScope()->definitionType()==Definition::TypeNamespace)
6071 {
6072 nd = toNamespaceDef(md->getOuterScope());
6073 }
6074 else
6075 {
6076 nd = md->getNamespaceDef();
6077 }
6078
6079 // special case for strong enums
6080 size_t enumNamePos=0;
6081 if (nd && md->isEnumValue() && (enumNamePos=namespaceName.rfind("::"))!=DString::npos)
6082 { // md part of a strong enum in a namespace?
6083 DString enumName = namespaceName.mid(enumNamePos+2);
6084 if (namespaceName.left(enumNamePos)==nd->name())
6085 {
6087 if (enumMn)
6088 {
6089 for (const auto &emd : *enumMn)
6090 {
6091 found = emd->isStrong() && md->getEnumScope()==emd.get();
6092 if (found)
6093 {
6094 addMemberDocs(root,toMemberDefMutable(md->resolveAlias()),decl,nullptr,false,root->spec);
6095 break;
6096 }
6097 }
6098 }
6099 }
6100 if (found)
6101 {
6102 break;
6103 }
6104 }
6105 else if (nd==nullptr && md->isEnumValue()) // md part of global strong enum?
6106 {
6107 MemberName *enumMn=Doxygen::functionNameLinkedMap->find(namespaceName);
6108 if (enumMn)
6109 {
6110 for (const auto &emd : *enumMn)
6111 {
6112 found = emd->isStrong() && md->getEnumScope()==emd.get();
6113 if (found)
6114 {
6115 addMemberDocs(root,toMemberDefMutable(md->resolveAlias()),decl,nullptr,false,root->spec);
6116 break;
6117 }
6118 }
6119 }
6120 }
6121
6122 const FileDef *fd=root->fileDef();
6123 //printf("File %s\n",fd ? qPrint(fd->name()) : "<none>");
6125 if (fd)
6126 {
6127 nl = fd->getUsedNamespaces();
6128 }
6129 //printf("NamespaceList %p\n",nl);
6130
6131 // search in the list of namespaces that are imported via a
6132 // using declaration
6133 bool viaUsingDirective = nd && nl.find(nd->qualifiedName())!=nullptr;
6134
6135 if ((namespaceName.empty() && nd==nullptr) || // not in a namespace
6136 (nd && nd->name()==namespaceName) || // or in the same namespace
6137 viaUsingDirective // member in 'using' namespace
6138 )
6139 {
6140 AUTO_TRACE_ADD("Try to add member '{}' to scope '{}'",md->name(),namespaceName);
6141
6142 NamespaceDef *rnd = nullptr;
6143 if (!namespaceName.empty()) rnd = Doxygen::namespaceLinkedMap->find(namespaceName);
6144
6145 const ArgumentList &mdAl = md.get()->argumentList();
6146 bool matching=
6147 (mdAl.empty() && root->argList.empty()) ||
6148 md->isVariable() || md->isTypedef() || /* in case of function pointers */
6149 matchArguments2(md->getOuterScope(),md->getFileDef(),md->typeString(),&mdAl,
6150 rnd ? rnd : Doxygen::globalScope,fd,root->type,&root->argList,
6151 false,root->lang);
6152
6153 // for template members we need to check if the number of
6154 // template arguments is the same, otherwise we are dealing with
6155 // different functions.
6156 if (matching && !root->tArgLists.empty())
6157 {
6158 const ArgumentList &mdTempl = md->templateArguments();
6159 if (root->tArgLists.back().size()!=mdTempl.size())
6160 {
6161 matching=false;
6162 }
6163 }
6164
6165 //printf("%s<->%s\n",
6166 // qPrint(argListToString(md->argumentList())),
6167 // qPrint(argListToString(root->argList)));
6168
6169 // For static members we also check if the comment block was found in
6170 // the same file. This is needed because static members with the same
6171 // name can be in different files. Thus it would be wrong to just
6172 // put the comment block at the first syntactically matching member. If
6173 // the comment block belongs to a group of the static member, then add
6174 // the documentation even if it is in a different file.
6175 if (matching && md->isStatic() &&
6176 md->getDefFileName()!=root->fileName &&
6177 mn->size()>1 &&
6178 !isEntryInGroupOfMember(root,md.get()))
6179 {
6180 matching = false;
6181 }
6182
6183 // for template member we also need to check the return type and requires
6184 if (!md->templateArguments().empty() && !root->tArgLists.empty())
6185 {
6186 //printf("Comparing return types '%s'<->'%s'\n",
6187 // md->typeString(),type);
6188 //printf("%s: Comparing '%s'<=>'%s'\n",qPrint(md->name()),qPrint(md->requiresClause()),qPrint(root->req));
6189 if (md->templateArguments().size()!=root->tArgLists.back().size() ||
6190 md->typeString()!=type ||
6191 md->requiresClause()!=root->req)
6192 {
6193 //printf(" ---> no matching\n");
6194 matching = false;
6195 }
6196 }
6197
6198 if (matching) // add docs to the member
6199 {
6200 AUTO_TRACE_ADD("Match found");
6201 addMemberDocs(root,toMemberDefMutable(md->resolveAlias()),decl,&root->argList,false,root->spec);
6202 found=true;
6203 break;
6204 }
6205 }
6206 }
6207 if (!found && root->relatesType!=RelatesType::Duplicate && root->section.isFunction()) // no match
6208 {
6209 DString fullFuncDecl=decl;
6210 if (!root->argList.empty()) fullFuncDecl+=argListToString(root->argList,true);
6211 DString warnMsg = "no matching file member found for \n"+fullFuncDecl;
6212 if (mn->size()>0)
6213 {
6214 warnMsg+="\nPossible candidates:";
6215 for (const auto &md : *mn)
6216 {
6217 warnMsg+="\n '";
6218 warnMsg+=replaceAnonymousScopes(md->declaration());
6219 warnMsg+="' " + warn_line(md->getDefFileName(),md->getDefLine());
6220 }
6221 }
6222 warn(root->fileName,root->startLine, "{}", qPrint(warnMsg));
6223 }
6224 }
6225 else // got docs for an undefined member!
6226 {
6227 if (root->type!="friend class" &&
6228 root->type!="friend struct" &&
6229 root->type!="friend union" &&
6230 root->type!="friend" &&
6231 (!Config_getBool(TYPEDEF_HIDES_STRUCT) ||
6232 root->type.find("typedef ")==DString::npos)
6233 )
6234 {
6235 warn(root->fileName,root->startLine,
6236 "documented symbol '{}' was not declared or defined.",qPrint(decl)
6237 );
6238 }
6239 }
6240 return true;
6241}
6242
6244 const ArgumentLists &srcTempArgLists,
6245 const ArgumentLists &dstTempArgLists
6246 )
6247{
6248 auto srcIt = srcTempArgLists.begin();
6249 auto dstIt = dstTempArgLists.begin();
6250 while (srcIt!=srcTempArgLists.end() && dstIt!=dstTempArgLists.end())
6251 {
6252 if ((*srcIt).size()!=(*dstIt).size()) return true;
6253 ++srcIt;
6254 ++dstIt;
6255 }
6256 return false;
6257}
6258
6259static bool scopeIsTemplate(const Definition *d)
6260{
6261 bool result=false;
6262 //printf("> scopeIsTemplate(%s)\n",qPrint(d?d->name():"null"));
6264 {
6265 auto cd = toClassDef(d);
6266 result = cd->templateArguments().hasParameters() || cd->templateMaster()!=nullptr ||
6268 }
6269 //printf("< scopeIsTemplate=%d\n",result);
6270 return result;
6271}
6272
6274 const ArgumentLists &srcTempArgLists,
6275 const ArgumentLists &dstTempArgLists,
6276 const std::string &src
6277 )
6278{
6279 std::string dst;
6280 static const reg::Ex re(R"(\a\w*)");
6281 reg::Iterator it(src,re);
6283 //printf("type=%s\n",qPrint(sa->type));
6284 size_t p=0;
6285 for (; it!=end ; ++it) // for each word in srcType
6286 {
6287 const auto &match = *it;
6288 size_t i = match.position();
6289 size_t l = match.length();
6290 bool found=false;
6291 dst+=src.substr(p,i-p);
6292 std::string name=match.str();
6293
6294 auto srcIt = srcTempArgLists.begin();
6295 auto dstIt = dstTempArgLists.begin();
6296 while (srcIt!=srcTempArgLists.end() && !found)
6297 {
6298 const ArgumentList *tdAli = nullptr;
6299 std::vector<Argument>::const_iterator tdaIt;
6300 if (dstIt!=dstTempArgLists.end())
6301 {
6302 tdAli = &(*dstIt);
6303 tdaIt = tdAli->begin();
6304 ++dstIt;
6305 }
6306
6307 const ArgumentList &tsaLi = *srcIt;
6308 for (auto tsaIt = tsaLi.begin(); tsaIt!=tsaLi.end() && !found; ++tsaIt)
6309 {
6310 Argument tsa = *tsaIt;
6311 const Argument *tda = nullptr;
6312 if (tdAli && tdaIt!=tdAli->end())
6313 {
6314 tda = &(*tdaIt);
6315 ++tdaIt;
6316 }
6317 //if (tda) printf("tsa=%s|%s tda=%s|%s\n",
6318 // qPrint(tsa.type),qPrint(tsa.name),
6319 // qPrint(tda->type),qPrint(tda->name));
6320 if (name==tsa.name.str())
6321 {
6322 if (tda && tda->name.empty())
6323 {
6324 DString tdaName = tda->name;
6325 DString tdaType = tda->type;
6326 int vc=0;
6327 if (tdaType.startsWith("class ")) vc=6;
6328 else if (tdaType.startsWith("typename ")) vc=9;
6329 if (vc>0) // convert type=="class T" to type=="class" name=="T"
6330 {
6331 tdaName = tdaType.mid(vc);
6332 }
6333 if (!tdaName.empty())
6334 {
6335 name=tdaName.str(); // substitute
6336 found=true;
6337 }
6338 }
6339 }
6340 }
6341
6342 //printf(" srcList='%s' dstList='%s faList='%s'\n",
6343 // qPrint(argListToString(srclali.current())),
6344 // qPrint(argListToString(dstlali.current())),
6345 // funcTempArgList ? qPrint(argListToString(funcTempArgList)) : "<none>");
6346 ++srcIt;
6347 }
6348 dst+=name;
6349 p=i+l;
6350 }
6351 dst+=src.substr(p);
6352 //printf(" substituteTemplatesInString(%s)=%s\n",
6353 // qPrint(src),qPrint(dst));
6354 return dst;
6355}
6356
6358 const ArgumentLists &srcTempArgLists,
6359 const ArgumentLists &dstTempArgLists,
6360 const ArgumentList &src,
6361 ArgumentList &dst
6362 )
6363{
6364 auto dstIt = dst.begin();
6365 for (const Argument &sa : src)
6366 {
6367 DString dstType = substituteTemplatesInString(srcTempArgLists,dstTempArgLists,sa.type.str());
6368 DString dstArray = substituteTemplatesInString(srcTempArgLists,dstTempArgLists,sa.array.str());
6369 if (dstIt == dst.end())
6370 {
6371 Argument da = sa;
6372 da.type = dstType;
6373 da.array = dstArray;
6374 dst.push_back(da);
6375 dstIt = dst.end();
6376 }
6377 else
6378 {
6379 Argument da = *dstIt;
6380 da.type = dstType;
6381 da.array = dstArray;
6382 ++dstIt;
6383 }
6384 }
6389 srcTempArgLists,dstTempArgLists,
6390 src.trailingReturnType().str()));
6391 dst.setIsDeleted(src.isDeleted());
6392 dst.setRefQualifier(src.refQualifier());
6393 dst.setNoParameters(src.noParameters());
6394 //printf("substituteTemplatesInArgList: replacing %s with %s\n",
6395 // qPrint(argListToString(src)),qPrint(argListToString(dst))
6396 // );
6397}
6398
6399//-------------------------------------------------------------------------------------------
6400
6401static void addLocalObjCMethod(const Entry *root,
6402 const DString &scopeName,
6403 const DString &funcType,const DString &funcName,const DString &funcArgs,
6404 const DString &exceptions,const DString &funcDecl,
6405 TypeSpecifier spec)
6406{
6407 AUTO_TRACE();
6408 //printf("scopeName='%s' className='%s'\n",qPrint(scopeName),qPrint(className));
6409 ClassDefMutable *cd=nullptr;
6410 if (Config_getBool(EXTRACT_LOCAL_METHODS) && (cd=getClassMutable(scopeName)))
6411 {
6412 AUTO_TRACE_ADD("Local objective C method '{}' scopeName='{}'",root->name,scopeName);
6413 auto md = createMemberDef(
6414 root->fileName,root->startLine,root->startColumn,
6415 funcType,funcName,funcArgs,exceptions,
6416 root->protection,root->virt,root->isStatic,Relationship::Member,
6417 MemberType::Function,ArgumentList(),root->argList,root->metaData);
6418 auto mmd = toMemberDefMutable(md.get());
6419 mmd->setTagInfo(root->tagInfo());
6420 mmd->setLanguage(root->lang);
6421 mmd->setId(root->id);
6422 mmd->makeImplementationDetail();
6423 mmd->setMemberClass(cd);
6424 mmd->setDefinition(funcDecl);
6426 mmd->addQualifiers(root->qualifiers);
6427 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
6428 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
6429 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
6430 mmd->setDocsForDefinition(!root->proto);
6431 mmd->setPrototype(root->proto,root->fileName,root->startLine,root->startColumn);
6432 mmd->addSectionsToDefinition(root->anchors);
6433 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
6434 FileDef *fd=root->fileDef();
6435 mmd->setBodyDef(fd);
6436 mmd->setMemberSpecifiers(spec);
6437 mmd->setVhdlSpecifiers(root->vhdlSpec);
6438 mmd->setMemberGroupId(root->mGrpId);
6439 cd->insertMember(md.get());
6440 cd->insertUsedFile(fd);
6441 mmd->setRefItems(root->sli);
6442 mmd->setRequirementReferences(root->rqli);
6443 addIncludeFile(mmd,fd,root);
6444
6446 mn->push_back(std::move(md));
6447 }
6448 else
6449 {
6450 // local objective C method found for class without interface
6451 }
6452}
6453
6454//-------------------------------------------------------------------------------------------
6455
6456static void addMemberFunction(const Entry *root,
6457 MemberName *mn,
6458 const DString &scopeName,
6459 const DString &namespaceName,
6460 const DString &className,
6461 const DString &funcTyp,
6462 const DString &funcName,
6463 const DString &funcArgs,
6464 const DString &funcTempList,
6465 const DString &exceptions,
6466 const DString &type,
6467 const DString &args,
6468 bool isFriend,
6469 TypeSpecifier spec,
6470 const DString &relates,
6471 const DString &funcDecl,
6472 bool overloaded,
6473 bool isFunc)
6474{
6475 AUTO_TRACE();
6476 DString funcType = funcTyp;
6477 int count=0;
6478 int noMatchCount=0;
6479 bool memFound=false;
6480 for (const auto &imd : *mn)
6481 {
6482 MemberDefMutable *md = toMemberDefMutable(imd.get());
6483 if (md==nullptr) continue;
6485 if (cd==nullptr) continue;
6486 //AUTO_TRACE_ADD("member definition found, scope needed='{}' scope='{}' args='{}' fileName='{}'",
6487 // scopeName, cd->name(), md->argsString(), root->fileName);
6488 FileDef *fd=root->fileDef();
6489 NamespaceDef *nd=nullptr;
6490 if (!namespaceName.empty()) nd=getResolvedNamespace(namespaceName);
6491
6492 //printf("scopeName %s->%s\n",qPrint(scopeName),
6493 // qPrint(stripTemplateSpecifiersFromScope(scopeName,false)));
6494
6495 // if the member we are searching for is an enum value that is part of
6496 // a "strong" enum, we need to look into the fields of the enum for a match
6497 size_t enumNamePos=0;
6498 if (md->isEnumValue() && (enumNamePos=className.rfind("::"))!=DString::npos)
6499 {
6500 DString enumName = className.mid(enumNamePos+2);
6501 DString fullScope = className.left(enumNamePos);
6502 if (!namespaceName.empty()) fullScope.prepend(namespaceName+"::");
6503 if (fullScope==cd->name())
6504 {
6505 MemberName *enumMn=Doxygen::memberNameLinkedMap->find(enumName);
6506 //printf("enumMn(%s)=%p\n",qPrint(className),(void*)enumMn);
6507 if (enumMn)
6508 {
6509 for (const auto &emd : *enumMn)
6510 {
6511 memFound = emd->isStrong() && md->getEnumScope()==emd.get();
6512 if (memFound)
6513 {
6514 addMemberDocs(root,md,funcDecl,nullptr,overloaded,spec);
6515 count++;
6516 }
6517 if (memFound) break;
6518 }
6519 }
6520 }
6521 }
6522 if (memFound) break;
6523
6524 const ClassDef *tcd=findClassDefinition(fd,nd,scopeName);
6525 if (tcd==nullptr && cd && stripAnonymousNamespaceScope(cd->name())==scopeName)
6526 {
6527 // don't be fooled by anonymous scopes
6528 tcd=cd;
6529 }
6530 //printf("Looking for %s inside nd=%s result=%s cd=%s\n",
6531 // qPrint(scopeName),nd?qPrint(nd->name()):"<none>",tcd?qPrint(tcd->name()):"",qPrint(cd->name()));
6532
6533 if (cd && tcd==cd) // member's classes match
6534 {
6535 AUTO_TRACE_ADD("class definition '{}' found",cd->name());
6536
6537 // get the template parameter lists found at the member declaration
6538 ArgumentLists declTemplArgs = cd->getTemplateParameterLists();
6539 const ArgumentList &templAl = md->templateArguments();
6540 if (!templAl.empty())
6541 {
6542 declTemplArgs.push_back(templAl);
6543 }
6544
6545 // get the template parameter lists found at the member definition
6546 const ArgumentLists &defTemplArgs = root->tArgLists;
6547 //printf("defTemplArgs=%p\n",defTemplArgs);
6548
6549 // do we replace the decl argument lists with the def argument lists?
6550 bool substDone=false;
6551 ArgumentList argList;
6552
6553 /* substitute the occurrences of class template names in the
6554 * argument list before matching
6555 */
6556 const ArgumentList &mdAl = md->argumentList();
6557 if (declTemplArgs.size()>0 && declTemplArgs.size()==defTemplArgs.size())
6558 {
6559 /* the function definition has template arguments
6560 * and the class definition also has template arguments, so
6561 * we must substitute the template names of the class by that
6562 * of the function definition before matching.
6563 */
6564 substituteTemplatesInArgList(declTemplArgs,defTemplArgs,mdAl,argList);
6565
6566 substDone=true;
6567 }
6568 else /* no template arguments, compare argument lists directly */
6569 {
6570 argList = mdAl;
6571 }
6572
6573 bool matching=
6574 md->isVariable() || md->isTypedef() || // needed for function pointers
6576 md->getClassDef(),md->getFileDef(),md->typeString(),&argList,
6577 cd,fd,root->type,&root->argList,
6578 true,root->lang);
6579
6580 AUTO_TRACE_ADD("matching '{}'<=>'{}' className='{}' namespaceName='{}' result={}",
6581 argListToString(argList,true),argListToString(root->argList,true),className,namespaceName,matching);
6582
6583 if (md->getLanguage()==SrcLangExt::ObjC && md->isVariable() && root->section.isFunction())
6584 {
6585 matching = false; // don't match methods and attributes with the same name
6586 }
6587
6588 // for template member we also need to check the return type
6589 if (!md->templateArguments().empty() && !root->tArgLists.empty())
6590 {
6591 DString memType = md->typeString();
6592 memType.stripPrefix("static "); // see bug700696
6593 // a member defined outside its namespace may use the namespace-qualified
6594 // name for its return type ("N::C" instead of "C"), while the in-class
6595 // declaration uses the unqualified name, so strip the leading namespace
6596 // before comparing the return types, see issue #12379
6597 funcType=substitute(stripTemplateSpecifiersFromScope(funcType,true),
6598 className+"::",""); // see bug700693 & bug732594
6599 memType=substitute(stripTemplateSpecifiersFromScope(memType,true),
6600 className+"::",""); // see bug758900
6601 if (!namespaceName.empty())
6602 {
6603 funcType.stripPrefix(namespaceName+"::");
6604 memType.stripPrefix(namespaceName+"::");
6605 }
6606 if (memType=="auto" && !argList.trailingReturnType().empty())
6607 {
6608 memType = argList.trailingReturnType();
6609 memType.stripPrefix(" -> ");
6610 }
6611 if (funcType=="auto" && !root->argList.trailingReturnType().empty())
6612 {
6613 funcType = root->argList.trailingReturnType();
6614 funcType.stripPrefix(" -> ");
6616 substDone=true;
6617 }
6618 AUTO_TRACE_ADD("Comparing return types '{}'<->'{}' #args {}<->{}",
6619 memType,funcType,md->templateArguments().size(),root->tArgLists.back().size());
6620 if (md->templateArguments().size()!=root->tArgLists.back().size() || memType!=funcType)
6621 {
6622 //printf(" ---> no matching\n");
6623 matching = false;
6624 }
6625 }
6626 else if (defTemplArgs.size()>declTemplArgs.size())
6627 {
6628 AUTO_TRACE_ADD("Different number of template arguments {} vs {}",defTemplArgs.size(),declTemplArgs.size());
6629 // avoid matching a non-template function in a template class against a
6630 // template function with the same name and parameters, see issue #10184
6631 substDone = false;
6632 matching = false;
6633 }
6634 bool rootIsUserDoc = root->section.isMemberDoc();
6635 bool classIsTemplate = scopeIsTemplate(md->getClassDef());
6636 bool mdIsTemplate = md->templateArguments().hasParameters();
6637 bool classOrMdIsTemplate = mdIsTemplate || classIsTemplate;
6638 bool rootIsTemplate = !root->tArgLists.empty();
6639 //printf("classIsTemplate=%d mdIsTemplate=%d rootIsTemplate=%d\n",classIsTemplate,mdIsTemplate,rootIsTemplate);
6640 if (!rootIsUserDoc && // don't check out-of-line @fn references, see bug722457
6641 (mdIsTemplate || rootIsTemplate) && // either md or root is a template
6642 ((classOrMdIsTemplate && !rootIsTemplate) || (!classOrMdIsTemplate && rootIsTemplate))
6643 )
6644 {
6645 // Method with template return type does not match method without return type
6646 // even if the parameters are the same. See also bug709052
6647 AUTO_TRACE_ADD("Comparing return types: template v.s. non-template");
6648 matching = false;
6649 }
6650
6651 AUTO_TRACE_ADD("Match results of matchArguments2='{}' substDone='{}'",matching,substDone);
6652
6653 if (substDone) // found a new argument list
6654 {
6655 if (matching) // replace member's argument list
6656 {
6658 md->moveArgumentList(std::make_unique<ArgumentList>(argList));
6659 }
6660 else // no match
6661 {
6662 if (!funcTempList.empty() &&
6663 isSpecialization(declTemplArgs,defTemplArgs))
6664 {
6665 // check if we are dealing with a partial template
6666 // specialization. In this case we add it to the class
6667 // even though the member arguments do not match.
6668
6669 addMethodToClass(root,cd,type,md->name(),args,isFriend,
6670 md->protection(),md->isStatic(),md->virtualness(),spec,relates);
6671 return;
6672 }
6673 }
6674 }
6675 if (matching)
6676 {
6677 addMemberDocs(root,md,funcDecl,nullptr,overloaded,spec);
6678 count++;
6679 memFound=true;
6680 }
6681 }
6682 else if (cd && cd!=tcd) // we did find a class with the same name as cd
6683 // but in a different namespace
6684 {
6685 noMatchCount++;
6686 }
6687
6688 if (memFound) break;
6689 }
6690 if (count==0 && root->parent() && root->parent()->section.isObjcImpl())
6691 {
6692 addLocalObjCMethod(root,scopeName,funcType,funcName,funcArgs,exceptions,funcDecl,spec);
6693 return;
6694 }
6695 if (count==0 && !(isFriend && funcType=="class"))
6696 {
6697 int candidates=0;
6698 const ClassDef *ecd = nullptr, *ucd = nullptr;
6699 MemberDef *emd = nullptr, *umd = nullptr;
6700 //printf("Assume template class\n");
6701 for (const auto &md : *mn)
6702 {
6703 MemberDef *cmd=md.get();
6705 ClassDefMutable *ccd=cdmdm ? cdmdm->getClassDefMutable() : nullptr;
6706 //printf("ccd->name()==%s className=%s\n",qPrint(ccd->name()),qPrint(className));
6707 if (ccd!=nullptr && rightScopeMatch(ccd->name(),className))
6708 {
6709 const ArgumentList &templAl = md->templateArguments();
6710 if (!root->tArgLists.empty() && !templAl.empty() &&
6711 root->tArgLists.back().size()<=templAl.size())
6712 {
6713 AUTO_TRACE_ADD("add template specialization");
6714 addMethodToClass(root,ccd,type,md->name(),args,isFriend,
6715 root->protection,root->isStatic,root->virt,spec,relates);
6716 return;
6717 }
6718 if (argListToString(md->argumentList(),false,false) ==
6719 argListToString(root->argList,false,false))
6720 { // exact argument list match -> remember
6721 ucd = ecd = ccd;
6722 umd = emd = cmd;
6723 AUTO_TRACE_ADD("new candidate className='{}' scope='{}' args='{}': exact match",
6724 className,ccd->name(),md->argsString());
6725 }
6726 else // arguments do not match, but member name and scope do -> remember
6727 {
6728 ucd = ccd;
6729 umd = cmd;
6730 AUTO_TRACE_ADD("new candidate className='{}' scope='{}' args='{}': no match",
6731 className,ccd->name(),md->argsString());
6732 }
6733 candidates++;
6734 }
6735 }
6736 bool strictProtoMatching = Config_getBool(STRICT_PROTO_MATCHING);
6737 if (!strictProtoMatching)
6738 {
6739 if (candidates==1 && ucd && umd)
6740 {
6741 // we didn't find an actual match on argument lists, but there is only 1 member with this
6742 // name in the same scope, so that has to be the one.
6743 addMemberDocs(root,toMemberDefMutable(umd),funcDecl,nullptr,overloaded,spec);
6744 return;
6745 }
6746 else if (candidates>1 && ecd && emd)
6747 {
6748 // we didn't find a unique match using type resolution,
6749 // but one of the matches has the exact same signature so
6750 // we take that one.
6751 addMemberDocs(root,toMemberDefMutable(emd),funcDecl,nullptr,overloaded,spec);
6752 return;
6753 }
6754 }
6755
6756 DString warnMsg = "no ";
6757 if (noMatchCount>1) warnMsg+="uniquely ";
6758 warnMsg+="matching class member found for \n";
6759
6760 for (const ArgumentList &al : root->tArgLists)
6761 {
6762 warnMsg+=" template ";
6763 warnMsg+=tempArgListToString(al,root->lang);
6764 warnMsg+='\n';
6765 }
6766
6767 DString fullFuncDecl=funcDecl;
6768 if (isFunc) fullFuncDecl+=argListToString(root->argList,true);
6769
6770 warnMsg+=" ";
6771 warnMsg+=fullFuncDecl;
6772
6773 if (candidates>0 || noMatchCount>=1)
6774 {
6775 warnMsg+="\nPossible candidates:";
6776
6777 NamespaceDef *nd=nullptr;
6778 if (!namespaceName.empty()) nd=getResolvedNamespace(namespaceName);
6779 FileDef *fd=root->fileDef();
6780
6781 for (const auto &md : *mn)
6782 {
6783 const ClassDef *cd=md->getClassDef();
6784 const ClassDef *tcd=findClassDefinition(fd,nd,scopeName);
6785 if (tcd==nullptr && cd && stripAnonymousNamespaceScope(cd->name())==scopeName)
6786 {
6787 // don't be fooled by anonymous scopes
6788 tcd=cd;
6789 }
6790 if (cd!=nullptr && (rightScopeMatch(cd->name(),className) || (cd!=tcd)))
6791 {
6792 warnMsg+='\n';
6793 const ArgumentList &templAl = md->templateArguments();
6794 warnMsg+=" '";
6795 if (templAl.hasParameters())
6796 {
6797 warnMsg+="template ";
6798 warnMsg+=tempArgListToString(templAl,root->lang);
6799 warnMsg+='\n';
6800 warnMsg+=" ";
6801 }
6802 if (!md->typeString().empty())
6803 {
6804 warnMsg+=md->typeString();
6805 warnMsg+=' ';
6806 }
6808 if (!qScope.empty())
6809 warnMsg+=qScope+"::"+md->name();
6810 warnMsg+=md->argsString();
6811 warnMsg+="' " + warn_line(md->getDefFileName(),md->getDefLine());
6812 }
6813 }
6814 }
6815 warn(root->fileName,root->startLine,"{}",warnMsg);
6816 }
6817}
6818
6819//-------------------------------------------------------------------------------------------
6820
6821static void addMemberSpecialization(const Entry *root,
6822 MemberName *mn,
6823 ClassDefMutable *cd,
6824 const DString &funcType,
6825 const DString &funcName,
6826 const DString &funcArgs,
6827 const DString &funcDecl,
6828 const DString &exceptions,
6829 TypeSpecifier spec
6830 )
6831{
6832 AUTO_TRACE("funcType={} funcName={} funcArgs={} funcDecl={} spec={}",funcType,funcName,funcArgs,funcDecl,spec);
6833 MemberDef *declMd=nullptr;
6834 for (const auto &md : *mn)
6835 {
6836 if (md->getClassDef()==cd)
6837 {
6838 // TODO: we should probably also check for matching arguments
6839 declMd = md.get();
6840 break;
6841 }
6842 }
6843 MemberType mtype=MemberType::Function;
6844 ArgumentList tArgList;
6845 // getTemplateArgumentsFromName(cd->name()+"::"+funcName,root->tArgLists);
6846 auto md = createMemberDef(
6847 root->fileName,root->startLine,root->startColumn,
6848 funcType,funcName,funcArgs,exceptions,
6849 declMd ? declMd->protection() : root->protection,
6850 root->virt,root->isStatic,Relationship::Member,
6851 mtype,tArgList,root->argList,root->metaData);
6852 auto mmd = toMemberDefMutable(md.get());
6853 //printf("new specialized member %s args='%s'\n",qPrint(md->name()),qPrint(funcArgs));
6854 mmd->setTagInfo(root->tagInfo());
6855 mmd->setLanguage(root->lang);
6856 mmd->setId(root->id);
6857 mmd->setMemberClass(cd);
6858 mmd->setTemplateSpecialization(true);
6859 mmd->setTypeConstraints(root->typeConstr);
6860 mmd->setDefinition(funcDecl);
6862 mmd->addQualifiers(root->qualifiers);
6863 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
6864 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
6865 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
6866 mmd->setDocsForDefinition(!root->proto);
6867 mmd->setPrototype(root->proto,root->fileName,root->startLine,root->startColumn);
6868 mmd->addSectionsToDefinition(root->anchors);
6869 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
6870 FileDef *fd=root->fileDef();
6871 mmd->setBodyDef(fd);
6872 mmd->setMemberSpecifiers(spec);
6873 mmd->setVhdlSpecifiers(root->vhdlSpec);
6874 mmd->setMemberGroupId(root->mGrpId);
6875 cd->insertMember(md.get());
6876 mmd->setRefItems(root->sli);
6877 mmd->setRequirementReferences(root->rqli);
6878 addIncludeFile(mmd,fd,root);
6879
6880 mn->push_back(std::move(md));
6881}
6882
6883//-------------------------------------------------------------------------------------------
6884
6885static void addOverloaded(const Entry *root,MemberName *mn,
6886 const DString &funcType,const DString &funcName,const DString &funcArgs,
6887 const DString &funcDecl,const DString &exceptions,TypeSpecifier spec)
6888{
6889 // for unique overloaded member we allow the class to be
6890 // omitted, this is to be Qt compatible. Using this should
6891 // however be avoided, because it is error prone
6892 bool sameClass=false;
6893 if (mn->size()>0)
6894 {
6895 // check if all members with the same name are also in the same class
6896 sameClass = std::equal(mn->begin()+1,mn->end(),mn->begin(),
6897 [](const auto &md1,const auto &md2)
6898 { return md1->getClassDef()->name()==md2->getClassDef()->name(); });
6899 }
6900 if (sameClass)
6901 {
6902 MemberDefMutable *mdm = toMemberDefMutable(mn->front().get());
6903 ClassDefMutable *cd = mdm ? mdm->getClassDefMutable() : nullptr;
6904 if (cd==nullptr) return;
6905
6906 MemberType mtype = MemberType::Function;
6907 if (root->mtype==MethodTypes::Signal) mtype=MemberType::Signal;
6908 else if (root->mtype==MethodTypes::Slot) mtype=MemberType::Slot;
6909 else if (root->mtype==MethodTypes::DCOP) mtype=MemberType::DCOP;
6910
6911 // new overloaded member function
6912 std::unique_ptr<ArgumentList> tArgList =
6913 getTemplateArgumentsFromName(cd->name()+"::"+funcName,root->tArgLists);
6914 //printf("new related member %s args='%s'\n",qPrint(md->name()),qPrint(funcArgs));
6915 auto md = createMemberDef(
6916 root->fileName,root->startLine,root->startColumn,
6917 funcType,funcName,funcArgs,exceptions,
6918 root->protection,root->virt,root->isStatic,Relationship::Related,
6919 mtype,tArgList ? *tArgList : ArgumentList(),root->argList,root->metaData);
6920 auto mmd = toMemberDefMutable(md.get());
6921 mmd->setTagInfo(root->tagInfo());
6922 mmd->setLanguage(root->lang);
6923 mmd->setId(root->id);
6924 mmd->setTypeConstraints(root->typeConstr);
6925 mmd->setMemberClass(cd);
6926 mmd->setDefinition(funcDecl);
6928 mmd->addQualifiers(root->qualifiers);
6930 doc+="<p>";
6931 doc+=root->doc;
6932 mmd->setDocumentation(doc,root->docFile,root->docLine);
6933 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
6934 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
6935 mmd->setDocsForDefinition(!root->proto);
6936 mmd->setPrototype(root->proto,root->fileName,root->startLine,root->startColumn);
6937 mmd->addSectionsToDefinition(root->anchors);
6938 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
6939 FileDef *fd=root->fileDef();
6940 mmd->setBodyDef(fd);
6941 mmd->setMemberSpecifiers(spec);
6942 mmd->setVhdlSpecifiers(root->vhdlSpec);
6943 mmd->setMemberGroupId(root->mGrpId);
6944 cd->insertMember(md.get());
6945 cd->insertUsedFile(fd);
6946 mmd->setRefItems(root->sli);
6947 mmd->setRequirementReferences(root->rqli);
6948 addIncludeFile(mmd,fd,root);
6949
6950 mn->push_back(std::move(md));
6951 }
6952}
6953
6954static void insertMemberAlias(Definition *outerScope,const MemberDef *md)
6955{
6956 if (outerScope && outerScope!=Doxygen::globalScope)
6957 {
6958 auto aliasMd = createMemberDefAlias(outerScope,md);
6959 if (outerScope->definitionType()==Definition::TypeClass)
6960 {
6961 ClassDefMutable *cdm = toClassDefMutable(outerScope);
6962 if (cdm)
6963 {
6964 cdm->insertMember(aliasMd.get());
6965 }
6966 }
6967 else if (outerScope->definitionType()==Definition::TypeNamespace)
6968 {
6969 NamespaceDefMutable *ndm = toNamespaceDefMutable(outerScope);
6970 if (ndm)
6971 {
6972 ndm->insertMember(aliasMd.get());
6973 }
6974 }
6975 else if (outerScope->definitionType()==Definition::TypeFile)
6976 {
6977 toFileDef(outerScope)->insertMember(aliasMd.get());
6978 }
6979 if (aliasMd)
6980 {
6981 Doxygen::functionNameLinkedMap->add(md->name())->push_back(std::move(aliasMd));
6982 }
6983 }
6984}
6985
6986//-------------------------------------------------------------------------------------------
6987
6988/*! This function tries to find a member (in a documented class/file/namespace)
6989 * that corresponds to the function/variable declaration given in \a funcDecl.
6990 *
6991 * The boolean \a overloaded is used to specify whether or not a standard
6992 * overload documentation line should be generated.
6993 *
6994 * The boolean \a isFunc is a hint that indicates that this is a function
6995 * instead of a variable or typedef.
6996 */
6997static void findMember(const Entry *root,
6998 const DString &relates,
6999 const DString &type,
7000 const DString &args,
7001 DString funcDecl,
7002 bool overloaded,
7003 bool isFunc
7004 )
7005{
7006 AUTO_TRACE("root='{}' funcDecl='{}' related='{}' overload={} isFunc={} mGrpId={} #tArgList={} spec={} lang={}",
7007 root->name, funcDecl, relates, overloaded, isFunc, root->mGrpId, root->tArgLists.size(),
7008 root->spec, root->lang);
7009
7010 DString scopeName;
7011 DString className;
7012 DString namespaceName;
7013 DString funcType;
7014 DString funcName;
7015 DString funcArgs;
7016 DString funcTempList;
7017 DString exceptions;
7018 DString funcSpec;
7019 bool isRelated=false;
7020 bool isMemberOf=false;
7021 bool isFriend=false;
7022 bool done=false;
7023 TypeSpecifier spec = root->spec;
7024 while (!done)
7025 {
7026 done=true;
7027 if (funcDecl.stripPrefix("friend ")) // treat friends as related members
7028 {
7029 isFriend=true;
7030 done=false;
7031 }
7032 if (funcDecl.stripPrefix("inline "))
7033 {
7034 spec.setInline(true);
7035 done=false;
7036 }
7037 if (funcDecl.stripPrefix("explicit "))
7038 {
7039 spec.setExplicit(true);
7040 done=false;
7041 }
7042 if (funcDecl.stripPrefix("mutable "))
7043 {
7044 spec.setMutable(true);
7045 done=false;
7046 }
7047 if (funcDecl.stripPrefix("thread_local "))
7048 {
7049 spec.setThreadLocal(true);
7050 done=false;
7051 }
7052 if (funcDecl.stripPrefix("virtual "))
7053 {
7054 done=false;
7055 }
7056 }
7057
7058 // delete any ; from the function declaration
7059 size_t sep=0;
7060 while ((sep=funcDecl.find(';'))!=DString::npos)
7061 {
7062 funcDecl=(funcDecl.left(sep)+funcDecl.mid(sep+1)).stripWhiteSpace();
7063 }
7064
7065 // make sure the first character is a space to simplify searching.
7066 if (!funcDecl.empty() && funcDecl[0]!=' ') funcDecl.prepend(" ");
7067
7068 // remove some superfluous spaces
7069 funcDecl= substitute(
7070 substitute(
7071 substitute(funcDecl,"~ ","~"),
7072 ":: ","::"
7073 ),
7074 " ::","::"
7075 ).stripWhiteSpace();
7076
7077 //printf("funcDecl='%s'\n",qPrint(funcDecl));
7078 if (isFriend && funcDecl.startsWith("class "))
7079 {
7080 //printf("friend class\n");
7081 funcDecl=funcDecl.mid(6);
7082 funcName = funcDecl;
7083 }
7084 else if (isFriend && funcDecl.startsWith("struct "))
7085 {
7086 funcDecl=funcDecl.mid(7);
7087 funcName = funcDecl;
7088 }
7089 else if (isFriend && funcDecl.startsWith("record "))
7090 {
7091 funcDecl=funcDecl.mid(7);
7092 funcName = funcDecl;
7093 }
7094 else
7095 {
7096 // extract information from the declarations
7097 parseFuncDecl(funcDecl,root->lang,scopeName,funcType,funcName,
7098 funcArgs,funcTempList,exceptions
7099 );
7100 }
7101
7102 // the class name can also be a namespace name, we decide this later.
7103 // if a related class name is specified and the class name could
7104 // not be derived from the function declaration, then use the
7105 // related field.
7106 AUTO_TRACE_ADD("scopeName='{}' className='{}' namespaceName='{}' funcType='{}' funcName='{}' funcArgs='{}'",
7107 scopeName,className,namespaceName,funcType,funcName,funcArgs);
7108 if (!relates.empty())
7109 { // related member, prefix user specified scope
7110 isRelated=true;
7111 isMemberOf=(root->relatesType == RelatesType::MemberOf);
7112 if (getClass(relates)==nullptr && !scopeName.empty())
7113 {
7114 scopeName= mergeScopes(scopeName,relates);
7115 }
7116 else
7117 {
7118 scopeName = relates;
7119 }
7120 }
7121
7122 if (relates.empty() && root->parent() &&
7123 (root->parent()->section.isScope() || root->parent()->section.isObjcImpl()) &&
7124 !root->parent()->name.empty()) // see if we can combine scopeName
7125 // with the scope in which it was found
7126 {
7127 DString joinedName = root->parent()->name+"::"+scopeName;
7128 if (!scopeName.empty() &&
7129 (getClass(joinedName) || Doxygen::namespaceLinkedMap->find(joinedName)))
7130 {
7131 scopeName = joinedName;
7132 }
7133 else
7134 {
7135 scopeName = mergeScopes(root->parent()->name,scopeName);
7136 }
7137 }
7138 else // see if we can prefix a namespace or class that is used from the file
7139 {
7140 FileDef *fd=root->fileDef();
7141 if (fd)
7142 {
7143 for (const auto &fnd : fd->getUsedNamespaces())
7144 {
7145 DString joinedName = fnd->name()+"::"+scopeName;
7146 if (Doxygen::namespaceLinkedMap->find(joinedName))
7147 {
7148 scopeName=joinedName;
7149 break;
7150 }
7151 }
7152 }
7153 }
7155 removeRedundantWhiteSpace(scopeName),false,&funcSpec,DString(),false);
7156
7157 // funcSpec contains the last template specifiers of the given scope.
7158 // If this method does not have any template arguments or they are
7159 // empty while funcSpec is not empty we assume this is a
7160 // specialization of a method. If not, we clear the funcSpec and treat
7161 // this as a normal method of a template class.
7162 if (!(root->tArgLists.size()>0 &&
7163 root->tArgLists.front().size()==0
7164 )
7165 )
7166 {
7167 funcSpec.clear();
7168 }
7169
7170 //namespaceName=removeAnonymousScopes(namespaceName);
7171 if (!Config_getBool(EXTRACT_ANON_NSPACES) && scopeName.find('@')!=DString::npos) return; // skip stuff in anonymous namespace...
7172
7173 // split scope into a namespace and a class part
7174 extractNamespaceName(scopeName,className,namespaceName,true);
7175 AUTO_TRACE_ADD("scopeName='{}' className='{}' namespaceName='{}'",scopeName,className,namespaceName);
7176
7177 //printf("namespaceName='%s' className='%s'\n",qPrint(namespaceName),qPrint(className));
7178 // merge class and namespace scopes again
7179 scopeName.clear();
7180 if (!namespaceName.empty())
7181 {
7182 if (className.empty())
7183 {
7184 scopeName=namespaceName;
7185 }
7186 else if (!relates.empty() || // relates command with explicit scope
7187 !getClass(className)) // class name only exists in a namespace
7188 {
7189 scopeName=namespaceName+"::"+className;
7190 }
7191 else
7192 {
7193 scopeName=className;
7194 }
7195 }
7196 else if (!className.empty())
7197 {
7198 scopeName=className;
7199 }
7200 //printf("new scope='%s'\n",qPrint(scopeName));
7201
7202 DString tempScopeName=scopeName;
7203 ClassDefMutable *cd=getClassMutable(scopeName);
7204 if (cd)
7205 {
7206 if (funcSpec.empty())
7207 {
7208 uint32_t argListIndex=0;
7209 tempScopeName=cd->qualifiedNameWithTemplateParameters(&root->tArgLists,&argListIndex);
7210 }
7211 else
7212 {
7213 tempScopeName=scopeName+funcSpec;
7214 }
7215 }
7216 //printf("scopeName=%s cd=%p root->tArgLists=%p result=%s\n",
7217 // qPrint(scopeName),cd,root->tArgLists,qPrint(tempScopeName));
7218
7219 //printf("scopeName='%s' className='%s'\n",qPrint(scopeName),qPrint(className));
7220 // rebuild the function declaration (needed to get the scope right).
7221 if (!scopeName.empty() && !isRelated && !isFriend && !Config_getBool(HIDE_SCOPE_NAMES) && root->lang!=SrcLangExt::Python)
7222 {
7223 if (!funcType.empty())
7224 {
7225 if (isFunc) // a function -> we use argList for the arguments
7226 {
7227 funcDecl=funcType+" "+tempScopeName+"::"+funcName+funcTempList;
7228 }
7229 else
7230 {
7231 funcDecl=funcType+" "+tempScopeName+"::"+funcName+funcArgs;
7232 }
7233 }
7234 else
7235 {
7236 if (isFunc) // a function => we use argList for the arguments
7237 {
7238 funcDecl=tempScopeName+"::"+funcName+funcTempList;
7239 }
7240 else // variable => add 'argument' list
7241 {
7242 funcDecl=tempScopeName+"::"+funcName+funcArgs;
7243 }
7244 }
7245 }
7246 else // build declaration without scope
7247 {
7248 if (!funcType.empty()) // but with a type
7249 {
7250 if (isFunc) // function => omit argument list
7251 {
7252 funcDecl=funcType+" "+funcName+funcTempList;
7253 }
7254 else // variable => add 'argument' list
7255 {
7256 funcDecl=funcType+" "+funcName+funcArgs;
7257 }
7258 }
7259 else // no type
7260 {
7261 if (isFunc)
7262 {
7263 funcDecl=funcName+funcTempList;
7264 }
7265 else
7266 {
7267 funcDecl=funcName+funcArgs;
7268 }
7269 }
7270 }
7271
7272 if (funcType=="template class" && !funcTempList.empty())
7273 return; // ignore explicit template instantiations
7274
7275 AUTO_TRACE_ADD("Parse results: namespaceName='{}' className=`{}` funcType='{}' funcSpec='{}' "
7276 " funcName='{}' funcArgs='{}' funcTempList='{}' funcDecl='{}' relates='{}'"
7277 " exceptions='{}' isRelated={} isMemberOf={} isFriend={} isFunc={}",
7278 namespaceName, className, funcType, funcSpec,
7279 funcName, funcArgs, funcTempList, funcDecl, relates,
7280 exceptions, isRelated, isMemberOf, isFriend, isFunc);
7281
7282 if (!funcName.empty()) // function name is valid
7283 {
7284 // check if 'className' is actually a scoped enum, in which case we need to
7285 // process it as a global, see issue #6471
7286 bool strongEnum = false;
7287 MemberName *mn=nullptr;
7288 if (!className.empty() && (mn=Doxygen::functionNameLinkedMap->find(className)))
7289 {
7290 for (const auto &imd : *mn)
7291 {
7292 MemberDefMutable *md = toMemberDefMutable(imd.get());
7293 Definition *mdScope = nullptr;
7294 if (md && md->isEnumerate() && md->isStrong() && (mdScope=md->getOuterScope()) &&
7295 // need filter for the correct scope, see issue #9668
7296 ((namespaceName.empty() && mdScope==Doxygen::globalScope) || (mdScope->name()==namespaceName)))
7297 {
7298 AUTO_TRACE_ADD("'{}' is a strong enum! (namespace={} md->getOuterScope()->name()={})",md->name(),namespaceName,md->getOuterScope()->name());
7299 strongEnum = true;
7300 // pass the scope name name as a 'namespace' to the findGlobalMember function
7301 if (!namespaceName.empty())
7302 {
7303 namespaceName+="::"+className;
7304 }
7305 else
7306 {
7307 namespaceName=className;
7308 }
7309 }
7310 }
7311 }
7312
7313 if (funcName.startsWith("operator ")) // strip class scope from cast operator
7314 {
7315 funcName = substitute(funcName,className+"::","");
7316 }
7317 mn = nullptr;
7318 if (!funcTempList.empty()) // try with member specialization
7319 {
7320 mn=Doxygen::memberNameLinkedMap->find(funcName+funcTempList);
7321 }
7322 if (mn==nullptr) // try without specialization
7323 {
7324 mn=Doxygen::memberNameLinkedMap->find(funcName);
7325 }
7326 if (!isRelated && !strongEnum && mn) // function name already found
7327 {
7328 AUTO_TRACE_ADD("member name exists ({} members with this name)",mn->size());
7329 if (!className.empty()) // class name is valid
7330 {
7331 if (funcSpec.empty()) // not a member specialization
7332 {
7333 addMemberFunction(root,mn,scopeName,namespaceName,className,funcType,funcName,
7334 funcArgs,funcTempList,exceptions,
7335 type,args,isFriend,spec,relates,funcDecl,overloaded,isFunc);
7336 }
7337 else if (cd) // member specialization
7338 {
7339 addMemberSpecialization(root,mn,cd,funcType,funcName,funcArgs,funcDecl,exceptions,spec);
7340 }
7341 else
7342 {
7343 //printf("*** Specialized member %s of unknown scope %s%s found!\n",
7344 // qPrint(scopeName),qPrint(funcName),qPrint(funcArgs));
7345 }
7346 }
7347 else if (overloaded) // check if the function belongs to only one class
7348 {
7349 addOverloaded(root,mn,funcType,funcName,funcArgs,funcDecl,exceptions,spec);
7350 }
7351 else // unrelated function with the same name as a member
7352 {
7353 if (!findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl,spec))
7354 {
7355 DString fullFuncDecl=funcDecl;
7356 if (isFunc) fullFuncDecl+=argListToString(root->argList,true);
7357 warn(root->fileName,root->startLine,
7358 "Cannot determine class for function\n{}",
7359 fullFuncDecl
7360 );
7361 }
7362 }
7363 }
7364 else if (isRelated && !relates.empty())
7365 {
7366 AUTO_TRACE_ADD("related function scopeName='{}' className='{}'",scopeName,className);
7367 if (className.empty()) className=relates;
7368 //printf("scopeName='%s' className='%s'\n",qPrint(scopeName),qPrint(className));
7369 if ((cd=getClassMutable(scopeName)))
7370 {
7371 bool newMember=true; // assume we have a new member
7372 MemberDefMutable *mdDefine=nullptr;
7373 {
7374 mn = Doxygen::functionNameLinkedMap->find(funcName);
7375 if (mn)
7376 {
7377 for (const auto &imd : *mn)
7378 {
7379 MemberDefMutable *md = toMemberDefMutable(imd.get());
7380 if (md && md->isDefine())
7381 {
7382 mdDefine = md;
7383 break;
7384 }
7385 }
7386 }
7387 }
7388
7389 if (mdDefine) // macro definition is already created by the preprocessor and inserted as a file member
7390 {
7391 //printf("moving #define %s into class %s\n",qPrint(mdDefine->name()),qPrint(cd->name()));
7392
7393 // take mdDefine from the Doxygen::functionNameLinkedMap (without deleting the data)
7394 auto mdDefineTaken = Doxygen::functionNameLinkedMap->take(funcName,mdDefine);
7395 // insert it as a class member
7396 if ((mn=Doxygen::memberNameLinkedMap->find(funcName))==nullptr)
7397 {
7398 mn=Doxygen::memberNameLinkedMap->add(funcName);
7399 }
7400
7401 if (mdDefine->getFileDef())
7402 {
7403 mdDefine->getFileDef()->removeMember(mdDefine);
7404 }
7405 mdDefine->makeRelated();
7406 mdDefine->setMemberClass(cd);
7407 mdDefine->moveTo(cd);
7408 cd->insertMember(mdDefine);
7409 // also insert the member as an alias in the parent's scope, so it can be referenced also without cd's scope
7410 insertMemberAlias(cd->getOuterScope(),mdDefine);
7411 mn->push_back(std::move(mdDefineTaken));
7412 }
7413 else // normal member, needs to be created and added to the class
7414 {
7415 FileDef *fd=root->fileDef();
7416
7417 if ((mn=Doxygen::memberNameLinkedMap->find(funcName))==nullptr)
7418 {
7419 mn=Doxygen::memberNameLinkedMap->add(funcName);
7420 }
7421 else
7422 {
7423 // see if we got another member with matching arguments
7424 MemberDefMutable *rmd_found = nullptr;
7425 for (const auto &irmd : *mn)
7426 {
7427 MemberDefMutable *rmd = toMemberDefMutable(irmd.get());
7428 if (rmd)
7429 {
7430 const ArgumentList &rmdAl = rmd->argumentList();
7431
7432 newMember=
7433 className!=rmd->getOuterScope()->name() ||
7434 !matchArguments2(rmd->getOuterScope(),rmd->getFileDef(),rmd->typeString(),&rmdAl,
7435 cd,fd,root->type,&root->argList,
7436 true,root->lang);
7437 if (!newMember)
7438 {
7439 rmd_found = rmd;
7440 }
7441 }
7442 }
7443 if (rmd_found) // member already exists as rmd -> add docs
7444 {
7445 AUTO_TRACE_ADD("addMemberDocs for related member {}",root->name);
7446 addMemberDocs(root,rmd_found,funcDecl,nullptr,overloaded,spec);
7447 newMember=false;
7448 }
7449 }
7450
7451 if (newMember) // need to create a new member
7452 {
7453 MemberType mtype = MemberType::Function;
7454 switch (root->mtype)
7455 {
7456 case MethodTypes::Method: mtype = MemberType::Function; break;
7457 case MethodTypes::Signal: mtype = MemberType::Signal; break;
7458 case MethodTypes::Slot: mtype = MemberType::Slot; break;
7459 case MethodTypes::DCOP: mtype = MemberType::DCOP; break;
7460 case MethodTypes::Property: mtype = MemberType::Property; break;
7461 case MethodTypes::Event: mtype = MemberType::Event; break;
7462 }
7463
7464 //printf("New related name '%s' '%d'\n",qPrint(funcName),
7465 // root->argList ? (int)root->argList->count() : -1);
7466
7467 // first note that we pass:
7468 // (root->tArgLists ? root->tArgLists->last() : nullptr)
7469 // for the template arguments for the new "member."
7470 // this accurately reflects the template arguments of
7471 // the related function, which don't have to do with
7472 // those of the related class.
7473 auto md = createMemberDef(
7474 root->fileName,root->startLine,root->startColumn,
7475 funcType,funcName,funcArgs,exceptions,
7476 root->protection,root->virt,
7477 root->isStatic,
7478 isMemberOf ? Relationship::Foreign : Relationship::Related,
7479 mtype,
7480 (!root->tArgLists.empty() ? root->tArgLists.back() : ArgumentList()),
7481 funcArgs.empty() ? ArgumentList() : root->argList,
7482 root->metaData);
7483 auto mmd = toMemberDefMutable(md.get());
7484
7485 // also insert the member as an alias in the parent's scope, so it can be referenced also without cd's scope
7486 insertMemberAlias(cd->getOuterScope(),md.get());
7487
7488 // we still have the problem that
7489 // MemberDef::writeDocumentation() in memberdef.cpp
7490 // writes the template argument list for the class,
7491 // as if this member is a member of the class.
7492 // fortunately, MemberDef::writeDocumentation() has
7493 // a special mechanism that allows us to totally
7494 // override the set of template argument lists that
7495 // are printed. We use that and set it to the
7496 // template argument lists of the related function.
7497 //
7498 mmd->setDefinitionTemplateParameterLists(root->tArgLists);
7499
7500 mmd->setTagInfo(root->tagInfo());
7501
7502 addIncludeFile(mmd,root->fileDef(),root);
7503 //printf("Related member name='%s' decl='%s' bodyLine='%d'\n",
7504 // qPrint(funcName),qPrint(funcDecl),root->bodyLine);
7505
7506 // try to find the matching line number of the body from the
7507 // global function list
7508 bool found=false;
7509 if (root->bodyLine==-1)
7510 {
7512 if (rmn)
7513 {
7514 const MemberDefMutable *rmd_found=nullptr;
7515 for (const auto &irmd : *rmn)
7516 {
7517 MemberDefMutable *rmd = toMemberDefMutable(irmd.get());
7518 if (rmd)
7519 {
7520 const ArgumentList &rmdAl = rmd->argumentList();
7521 // check for matching argument lists
7522 if (
7523 matchArguments2(rmd->getOuterScope(),rmd->getFileDef(),rmd->typeString(),&rmdAl,
7524 cd,fd,root->type,&root->argList,
7525 true,root->lang)
7526 )
7527 {
7528 found=true;
7529 rmd_found = rmd;
7530 break;
7531 }
7532 }
7533 }
7534 if (rmd_found) // member found -> copy line number info
7535 {
7536 mmd->setBodySegment(rmd_found->getDefLine(),rmd_found->getStartBodyLine(),rmd_found->getEndBodyLine());
7537 mmd->setBodyDef(rmd_found->getBodyDef());
7538 //md->setBodyMember(rmd);
7539 }
7540 }
7541 }
7542 if (!found) // line number could not be found or is available in this
7543 // entry
7544 {
7545 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
7546 mmd->setBodyDef(fd);
7547 }
7548
7549 //if (root->mGrpId!=-1)
7550 //{
7551 // md->setMemberGroup(memberGroupDict[root->mGrpId]);
7552 //}
7553 mmd->setMemberClass(cd);
7554 mmd->setMemberSpecifiers(spec);
7555 mmd->setVhdlSpecifiers(root->vhdlSpec);
7556 mmd->setDefinition(funcDecl);
7558 mmd->addQualifiers(root->qualifiers);
7559 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
7560 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
7561 mmd->setDocsForDefinition(!root->proto);
7562 mmd->setPrototype(root->proto,root->fileName,root->startLine,root->startColumn);
7563 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
7564 mmd->addSectionsToDefinition(root->anchors);
7565 mmd->setMemberGroupId(root->mGrpId);
7566 mmd->setLanguage(root->lang);
7567 mmd->setId(root->id);
7568 //md->setMemberDefTemplateArguments(root->mtArgList);
7569 cd->insertMember(md.get());
7570 cd->insertUsedFile(fd);
7571 mmd->setRefItems(root->sli);
7572 mmd->setRequirementReferences(root->rqli);
7573 if (root->relatesType==RelatesType::Duplicate) mmd->setRelatedAlso(cd);
7574 addMemberToGroups(root,md.get());
7576 //printf("Adding member=%s\n",qPrint(md->name()));
7577 mn->push_back(std::move(md));
7578 }
7579 if (root->relatesType==RelatesType::Duplicate)
7580 {
7581 if (!findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl,spec))
7582 {
7583 DString fullFuncDecl=funcDecl;
7584 if (isFunc) fullFuncDecl+=argListToString(root->argList,true);
7585 warn(root->fileName,root->startLine,
7586 "Cannot determine file/namespace for relatedalso function\n{}",
7587 fullFuncDecl
7588 );
7589 }
7590 }
7591 }
7592 }
7593 else
7594 {
7595 warn_undoc(root->fileName,root->startLine, "class '{}' for related function '{}' is not documented.", className,funcName);
7596 }
7597 }
7598 else if (root->parent() && root->parent()->section.isObjcImpl())
7599 {
7600 addLocalObjCMethod(root,scopeName,funcType,funcName,funcArgs,exceptions,funcDecl,spec);
7601 }
7602 else // unrelated not overloaded member found
7603 {
7604 bool globMem = findGlobalMember(root,namespaceName,funcType,funcName,funcTempList,funcArgs,funcDecl,spec);
7605 if (className.empty() && !globMem)
7606 {
7607 warn(root->fileName,root->startLine, "class for member '{}' cannot be found.", funcName);
7608 }
7609 else if (!className.empty() && !globMem)
7610 {
7611 warn(root->fileName,root->startLine,
7612 "member '{}' of class '{}' cannot be found",
7613 funcName,className);
7614 }
7615 }
7616 }
7617 else
7618 {
7619 // this should not be called
7620 warn(root->fileName,root->startLine,"member with no name found.");
7621 }
7622 return;
7623}
7624
7625//----------------------------------------------------------------------
7626// find the members corresponding to the different documentation blocks
7627// that are extracted from the sources.
7628
7629static void filterMemberDocumentation(const Entry *root,const DString &relates)
7630{
7631 AUTO_TRACE("root->type='{}' root->inside='{}' root->name='{}' root->args='{}' section={} root->spec={} root->mGrpId={}",
7632 root->type,root->inside,root->name,root->args,root->section,root->spec,root->mGrpId);
7633 //printf("root->parent()->name=%s\n",qPrint(root->parent()->name));
7634 bool isFunc=true;
7635
7636 DString type = root->type;
7637 DString args = root->args;
7638 int i=-1, l=0;
7639 if ( // detect func variable/typedef to func ptr
7640 (i=findFunctionPtr(type.str(),root->lang,&l))!=-1
7641 )
7642 {
7643 //printf("Fixing function pointer!\n");
7644 // fix type and argument
7645 args.prepend(type.mid(i+l));
7646 type=type.left(i+l);
7647 //printf("Results type=%s,name=%s,args=%s\n",qPrint(type),qPrint(root->name),qPrint(args));
7648 isFunc=false;
7649 }
7650 else if ((type.startsWith("typedef ") && args.find('(')!=DString::npos))
7651 // detect function types marked as functions
7652 {
7653 isFunc=false;
7654 }
7655
7656 //printf("Member %s isFunc=%d\n",qPrint(root->name),isFunc);
7657 if (root->section.isMemberDoc())
7658 {
7659 //printf("Documentation for inline member '%s' found args='%s'\n",
7660 // qPrint(root->name),qPrint(args));
7661 //if (relates.length()) printf(" Relates %s\n",qPrint(relates));
7662 if (type.empty())
7663 {
7664 findMember(root,
7665 relates,
7666 type,
7667 args,
7668 root->name + args + root->exception,
7669 false,
7670 isFunc);
7671 }
7672 else
7673 {
7674 findMember(root,
7675 relates,
7676 type,
7677 args,
7678 type + " " + root->name + args + root->exception,
7679 false,
7680 isFunc);
7681 }
7682 }
7683 else if (root->section.isOverloadDoc())
7684 {
7685 //printf("Overloaded member %s found\n",qPrint(root->name));
7686 findMember(root,
7687 relates,
7688 type,
7689 args,
7690 root->name,
7691 true,
7692 isFunc);
7693 }
7694 else if
7695 ((root->section.isFunction() // function
7696 ||
7697 (root->section.isVariable() && // variable
7698 !type.empty() && // with a type
7699 g_compoundKeywords.find(type.str())==g_compoundKeywords.end() // that is not a keyword
7700 // (to skip forward declaration of class etc.)
7701 )
7702 )
7703 )
7704 {
7705 //printf("Documentation for member '%s' found args='%s' excp='%s'\n",
7706 // qPrint(root->name),qPrint(args),qPrint(root->exception));
7707 //if (relates.length()) printf(" Relates %s\n",qPrint(relates));
7708 //printf("Inside=%s\n Relates=%s\n",qPrint(root->inside),qPrint(relates));
7709 if (isTypeAClassFriend(type))
7710 {
7711 findMember(root,
7712 relates,
7713 type,
7714 args,
7715 type+" "+root->name,
7716 false,false);
7717
7718 }
7719 else if (!type.empty())
7720 {
7721 findMember(root,
7722 relates,
7723 type,
7724 args,
7725 type+" "+ root->inside + root->name + args + root->exception,
7726 false,isFunc);
7727 }
7728 else
7729 {
7730 findMember(root,
7731 relates,
7732 type,
7733 args,
7734 root->inside + root->name + args + root->exception,
7735 false,isFunc);
7736 }
7737 }
7738 else if (root->section.isDefine() && !relates.empty())
7739 {
7740 findMember(root,
7741 relates,
7742 type,
7743 args,
7744 root->name + args,
7745 false,
7746 !args.empty());
7747 }
7748 else if (root->section.isVariableDoc())
7749 {
7750 //printf("Documentation for variable %s found\n",qPrint(root->name));
7751 //if (!relates.empty()) printf(" Relates %s\n",qPrint(relates));
7752 findMember(root,
7753 relates,
7754 type,
7755 args,
7756 root->name,
7757 false,
7758 false);
7759 }
7760 else if (root->section.isExportedInterface() ||
7761 root->section.isIncludedService())
7762 {
7763 findMember(root,
7764 relates,
7765 type,
7766 args,
7767 type + " " + root->name,
7768 false,
7769 false);
7770 }
7771 else
7772 {
7773 // skip section
7774 //printf("skip section\n");
7775 }
7776}
7777
7778static void findMemberDocumentation(const Entry *root)
7779{
7780 if (root->section.isMemberDoc() ||
7781 root->section.isOverloadDoc() ||
7782 root->section.isFunction() ||
7783 root->section.isVariable() ||
7784 root->section.isVariableDoc() ||
7785 root->section.isDefine() ||
7786 root->section.isIncludedService() ||
7787 root->section.isExportedInterface()
7788 )
7789 {
7790 AUTO_TRACE();
7791 if (root->relatesType==RelatesType::Duplicate && !root->relates.empty())
7792 {
7794 }
7796 }
7797 for (const auto &e : root->children())
7798 {
7799 if (!e->section.isEnum())
7800 {
7801 findMemberDocumentation(e.get());
7802 }
7803 }
7804}
7805
7806//----------------------------------------------------------------------
7807
7808static void findObjCMethodDefinitions(const Entry *root)
7809{
7810 AUTO_TRACE();
7811 for (const auto &objCImpl : root->children())
7812 {
7813 if (objCImpl->section.isObjcImpl())
7814 {
7815 for (const auto &objCMethod : objCImpl->children())
7816 {
7817 if (objCMethod->section.isFunction())
7818 {
7819 //printf(" Found ObjC method definition %s\n",qPrint(objCMethod->name));
7820 findMember(objCMethod.get(),
7821 objCMethod->relates,
7822 objCMethod->type,
7823 objCMethod->args,
7824 objCMethod->type+" "+objCImpl->name+"::"+objCMethod->name+" "+objCMethod->args,
7825 false,true);
7826 objCMethod->section=EntryType::makeEmpty();
7827 }
7828 }
7829 }
7830 }
7831}
7832
7833//----------------------------------------------------------------------
7834// find and add the enumeration to their classes, namespaces or files
7835
7836static void findEnums(const Entry *root)
7837{
7838 if (root->section.isEnum())
7839 {
7840 AUTO_TRACE("name={}",root->name);
7841 ClassDefMutable *cd = nullptr;
7842 FileDef *fd = nullptr;
7843 NamespaceDefMutable *nd = nullptr;
7844 MemberNameLinkedMap *mnsd = nullptr;
7845 bool isGlobal = false;
7846 bool isRelated = false;
7847 bool isMemberOf = false;
7848 //printf("Found enum with name '%s' relates=%s\n",qPrint(root->name),qPrint(root->relates));
7849
7850 DString name;
7851 DString scope;
7852
7853 if (size_t i = root->name.rfind("::"); i!=DString::npos) // scope is specified
7854 {
7855 scope=root->name.left(i); // extract scope
7856 if (root->lang==SrcLangExt::CSharp)
7857 {
7858 scope = mangleCSharpGenericName(scope);
7859 }
7860 name=root->name.right(root->name.length()-i-2); // extract name
7861 if ((cd=getClassMutable(scope))==nullptr)
7862 {
7864 }
7865 }
7866 else // no scope, check the scope in which the docs where found
7867 {
7868 if (root->parent()->section.isScope() && !root->parent()->name.empty()) // found enum docs inside a compound
7869 {
7870 scope=root->parent()->name;
7871 if ((cd=getClassMutable(scope))==nullptr) nd=getResolvedNamespaceMutable(scope);
7872 }
7873 name=root->name;
7874 }
7875
7876 if (!root->relates.empty())
7877 { // related member, prefix user specified scope
7878 isRelated=true;
7879 isMemberOf=(root->relatesType==RelatesType::MemberOf);
7880 if (getClass(root->relates)==nullptr && !scope.empty())
7881 scope=mergeScopes(scope,root->relates);
7882 else
7883 scope=root->relates;
7884 if ((cd=getClassMutable(scope))==nullptr) nd=getResolvedNamespaceMutable(scope);
7885 }
7886
7887 if (cd && !name.empty()) // found a enum inside a compound
7888 {
7889 //printf("Enum '%s'::'%s'\n",qPrint(cd->name()),qPrint(name));
7890 fd=nullptr;
7892 isGlobal=false;
7893 }
7894 else if (nd) // found enum inside namespace
7895 {
7897 isGlobal=true;
7898 }
7899 else // found a global enum
7900 {
7901 fd=root->fileDef();
7903 isGlobal=true;
7904 }
7905
7906 if (!name.empty())
7907 {
7908 // new enum type
7909 AUTO_TRACE_ADD("new enum {} at line {} of {}",name,root->bodyLine,root->fileName);
7910 auto md = createMemberDef(
7911 root->fileName,root->startLine,root->startColumn,
7912 DString(),name,DString(),DString(),
7913 root->protection,Specifier::Normal,false,
7914 isMemberOf ? Relationship::Foreign : isRelated ? Relationship::Related : Relationship::Member,
7915 MemberType::Enumeration,
7917 auto mmd = toMemberDefMutable(md.get());
7918 mmd->setTagInfo(root->tagInfo());
7919 mmd->setLanguage(root->lang);
7920 mmd->setId(root->id);
7921 if (!isGlobal) mmd->setMemberClass(cd); else mmd->setFileDef(fd);
7922 mmd->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
7923 mmd->setBodyDef(root->fileDef());
7924 mmd->setMemberSpecifiers(root->spec);
7925 mmd->setVhdlSpecifiers(root->vhdlSpec);
7926 mmd->setEnumBaseType(root->args);
7927 //printf("Enum %s definition at line %d of %s: protection=%d scope=%s\n",
7928 // qPrint(root->name),root->bodyLine,qPrint(root->fileName),root->protection,cd?qPrint(cd->name()):"<none>");
7929 mmd->addSectionsToDefinition(root->anchors);
7930 mmd->setMemberGroupId(root->mGrpId);
7932 mmd->addQualifiers(root->qualifiers);
7933 //printf("%s::setRefItems(%zu)\n",qPrint(md->name()),root->sli.size());
7934 mmd->setRefItems(root->sli);
7935 mmd->setRequirementReferences(root->rqli);
7936 //printf("found enum %s nd=%p\n",qPrint(md->name()),nd);
7937 bool defSet=false;
7938 addIncludeFile(mmd,root->fileDef(),root);
7939
7940 DString baseType = root->args;
7941 if (!baseType.empty())
7942 {
7943 baseType.prepend(" : ");
7944 }
7945
7946 if (nd)
7947 {
7948 if (isRelated || Config_getBool(HIDE_SCOPE_NAMES) || root->lang==SrcLangExt::Python)
7949 {
7950 mmd->setDefinition(name+baseType);
7951 }
7952 else
7953 {
7954 mmd->setDefinition(nd->name()+"::"+name+baseType);
7955 }
7956 //printf("definition=%s\n",md->definition());
7957 defSet=true;
7958 mmd->setNamespace(nd);
7959 nd->insertMember(md.get());
7960 }
7961
7962 // even if we have already added the enum to a namespace, we still
7963 // also want to add it to other appropriate places such as file
7964 // or class.
7965 if (isGlobal && (nd==nullptr || !nd->isAnonymous()))
7966 {
7967 if (!defSet) mmd->setDefinition(name+baseType);
7968 if (fd==nullptr && root->parent())
7969 {
7970 fd=root->parent()->fileDef();
7971 }
7972 if (fd)
7973 {
7974 mmd->setFileDef(fd);
7975 fd->insertMember(md.get());
7976 }
7977 }
7978 else if (cd)
7979 {
7980 if (isRelated || Config_getBool(HIDE_SCOPE_NAMES) || root->lang==SrcLangExt::Python)
7981 {
7982 mmd->setDefinition(name+baseType);
7983 }
7984 else
7985 {
7986 mmd->setDefinition(cd->name()+"::"+name+baseType);
7987 }
7988 cd->insertMember(md.get());
7989 cd->insertUsedFile(fd);
7990 }
7991 mmd->setDocumentation(root->doc,root->docFile,root->docLine);
7992 mmd->setDocsForDefinition(!root->proto);
7993 mmd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
7994 mmd->setInbodyDocumentation(root->inbodyDocs,root->inbodyFile,root->inbodyLine);
7995
7996 //printf("Adding member=%s\n",qPrint(md->name()));
7997 addMemberToGroups(root,md.get());
7999
8000 MemberName *mn = mnsd->add(name);
8001 mn->push_back(std::move(md));
8002 }
8003 }
8004 else
8005 {
8006 for (const auto &e : root->children()) findEnums(e.get());
8007 }
8008}
8009
8010//----------------------------------------------------------------------
8011
8012static void addEnumValuesToEnums(const Entry *root)
8013{
8014 if (root->section.isEnum())
8015 // non anonymous enumeration
8016 {
8017 AUTO_TRACE("name={}",root->name);
8018 ClassDefMutable *cd = nullptr;
8019 FileDef *fd = nullptr;
8020 NamespaceDefMutable *nd = nullptr;
8021 MemberNameLinkedMap *mnsd = nullptr;
8022 bool isGlobal = false;
8023 bool isRelated = false;
8024 //printf("Found enum with name '%s' relates=%s\n",qPrint(root->name),qPrint(root->relates));
8025
8026 DString name;
8027 DString scope;
8028
8029 if (size_t i = root->name.rfind("::"); i!=DString::npos) // scope is specified
8030 {
8031 scope=root->name.left(i); // extract scope
8032 if (root->lang==SrcLangExt::CSharp)
8033 {
8034 scope = mangleCSharpGenericName(scope);
8035 }
8036 name=root->name.right(root->name.length()-i-2); // extract name
8037 if ((cd=getClassMutable(scope))==nullptr)
8038 {
8040 }
8041 }
8042 else // no scope, check the scope in which the docs where found
8043 {
8044 if (root->parent()->section.isScope() && !root->parent()->name.empty()) // found enum docs inside a compound
8045 {
8046 scope=root->parent()->name;
8047 if (root->lang==SrcLangExt::CSharp)
8048 {
8049 scope = mangleCSharpGenericName(scope);
8050 }
8051 if ((cd=getClassMutable(scope))==nullptr) nd=getResolvedNamespaceMutable(scope);
8052 }
8053 name=root->name;
8054 }
8055
8056 if (!root->relates.empty())
8057 { // related member, prefix user specified scope
8058 isRelated=true;
8059 if (getClassMutable(root->relates)==nullptr && !scope.empty())
8060 scope=mergeScopes(scope,root->relates);
8061 else
8062 scope=root->relates;
8063 if ((cd=getClassMutable(scope))==nullptr) nd=getResolvedNamespaceMutable(scope);
8064 }
8065
8066 if (cd && !name.empty()) // found a enum inside a compound
8067 {
8068 //printf("Enum in class '%s'::'%s'\n",qPrint(cd->name()),qPrint(name));
8069 fd=nullptr;
8071 isGlobal=false;
8072 }
8073 else if (nd && !nd->isAnonymous()) // found enum inside namespace
8074 {
8075 //printf("Enum in namespace '%s'::'%s'\n",qPrint(nd->name()),qPrint(name));
8077 isGlobal=true;
8078 }
8079 else // found a global enum
8080 {
8081 fd=root->fileDef();
8082 //printf("Enum in file '%s': '%s'\n",qPrint(fd->name()),qPrint(name));
8084 isGlobal=true;
8085 }
8086
8087 if (!name.empty())
8088 {
8089 //printf("** name=%s\n",qPrint(name));
8090 MemberName *mn = mnsd->find(name); // for all members with this name
8091 if (mn)
8092 {
8093 struct EnumValueInfo
8094 {
8095 EnumValueInfo(const DString &n,std::unique_ptr<MemberDef> &&md) :
8096 name(n), member(std::move(md)) {}
8097 DString name;
8098 std::unique_ptr<MemberDef> member;
8099 };
8100 std::vector< EnumValueInfo > extraMembers;
8101 // for each enum in this list
8102 for (const auto &imd : *mn)
8103 {
8104 MemberDefMutable *md = toMemberDefMutable(imd.get());
8105 // use raw pointer in this loop, since we modify mn and can then invalidate mdp.
8106 if (md && md->isEnumerate() && !root->children().empty())
8107 {
8108 AUTO_TRACE_ADD("enum {} with {} children",md->name(),root->children().size());
8109 for (const auto &e : root->children())
8110 {
8111 SrcLangExt sle = root->lang;
8112 bool isJavaLike = sle==SrcLangExt::CSharp || sle==SrcLangExt::Java || sle==SrcLangExt::XML;
8113 if ( isJavaLike || root->spec.isStrong())
8114 {
8115 if (sle == SrcLangExt::Cpp && e->section.isDefine()) continue;
8116 // Unlike classic C/C++ enums, for C++11, C# & Java enum
8117 // values are only visible inside the enum scope, so we must create
8118 // them here and only add them to the enum
8119 //printf("md->qualifiedName()=%s e->name=%s tagInfo=%p name=%s\n",
8120 // qPrint(md->qualifiedName()),qPrint(e->name),(void*)e->tagInfo(),qPrint(e->name));
8121 DString qualifiedName = root->name;
8122 if (size_t i = qualifiedName.rfind("::"); i!=DString::npos && sle==SrcLangExt::CSharp)
8123 {
8124 qualifiedName = mangleCSharpGenericName(qualifiedName.left(i))+qualifiedName.mid(i);
8125 }
8126 if (isJavaLike)
8127 {
8128 qualifiedName=substitute(qualifiedName,"::",".");
8129 }
8130 if (md->qualifiedName()==qualifiedName) // enum value scope matches that of the enum
8131 {
8132 DString fileName = e->fileName;
8133 if (fileName.empty() && e->tagInfo())
8134 {
8135 fileName = e->tagInfo()->tagName;
8136 }
8137 AUTO_TRACE_ADD("strong enum value {}",e->name);
8138 auto fmd = createMemberDef(
8139 fileName,e->startLine,e->startColumn,
8140 e->type,e->name,e->args,DString(),
8141 e->protection, Specifier::Normal,e->isStatic,Relationship::Member,
8142 MemberType::EnumValue,ArgumentList(),ArgumentList(),e->metaData);
8143 auto fmmd = toMemberDefMutable(fmd.get());
8144 NamespaceDef *mnd = md->getNamespaceDef();
8145 if (md->getClassDef())
8146 fmmd->setMemberClass(md->getClassDef());
8147 else if (mnd && (mnd->isLinkable() || mnd->isAnonymous()))
8148 fmmd->setNamespace(mnd);
8149 else if (md->getFileDef())
8150 fmmd->setFileDef(md->getFileDef());
8151 fmmd->setOuterScope(md->getOuterScope());
8152 fmmd->setTagInfo(e->tagInfo());
8153 fmmd->setLanguage(e->lang);
8154 fmmd->setBodySegment(e->startLine,e->bodyLine,e->endBodyLine);
8155 fmmd->setBodyDef(e->fileDef());
8156 fmmd->setId(e->id);
8157 fmmd->setDocumentation(e->doc,e->docFile,e->docLine);
8158 fmmd->setBriefDescription(e->brief,e->briefFile,e->briefLine);
8159 fmmd->addSectionsToDefinition(e->anchors);
8160 fmmd->setInitializer(e->initializer.str());
8161 fmmd->setMaxInitLines(e->initLines);
8162 fmmd->setMemberGroupId(e->mGrpId);
8163 fmmd->setExplicitExternal(e->explicitExternal,fileName,e->startLine,e->startColumn);
8164 fmmd->setRefItems(e->sli);
8165 fmmd->setRequirementReferences(e->rqli);
8166 fmmd->setAnchor();
8167 md->insertEnumField(fmd.get());
8168 fmmd->setEnumScope(md,true);
8169 extraMembers.emplace_back(e->name,std::move(fmd));
8170 }
8171 }
8172 else
8173 {
8174 AUTO_TRACE_ADD("enum value {}",e->name);
8175 //printf("e->name=%s isRelated=%d\n",qPrint(e->name),isRelated);
8176 MemberName *fmn=nullptr;
8177 MemberNameLinkedMap *emnsd = isRelated ? Doxygen::functionNameLinkedMap : mnsd;
8178 if (!e->name.empty() && (fmn=emnsd->find(e->name)))
8179 // get list of members with the same name as the field
8180 {
8181 for (const auto &ifmd : *fmn)
8182 {
8183 MemberDefMutable *fmd = toMemberDefMutable(ifmd.get());
8184 if (fmd && fmd->isEnumValue() && fmd->getOuterScope()==md->getOuterScope()) // in same scope
8185 {
8186 //printf("found enum value with same name %s in scope %s\n",
8187 // qPrint(fmd->name()),qPrint(fmd->getOuterScope()->name()));
8188 if (nd && !nd->isAnonymous())
8189 {
8190 if (!fmd->isStrongEnumValue()) // only non strong enum values can be globally added
8191 {
8192 const NamespaceDef *fnd=fmd->getNamespaceDef();
8193 if (fnd==nd) // enum value is inside a namespace
8194 {
8195 md->insertEnumField(fmd);
8196 fmd->setEnumScope(md);
8197 }
8198 }
8199 }
8200 else if (isGlobal)
8201 {
8202 if (!fmd->isStrongEnumValue()) // only non strong enum values can be globally added
8203 {
8204 const FileDef *ffd=fmd->getFileDef();
8205 if (ffd==fd && ffd==md->getFileDef()) // enum value has file scope
8206 {
8207 md->insertEnumField(fmd);
8208 fmd->setEnumScope(md);
8209 }
8210 }
8211 }
8212 else if (isRelated && cd) // reparent enum value to
8213 // match the enum's scope
8214 {
8215 md->insertEnumField(fmd); // add field def to list
8216 fmd->setEnumScope(md); // cross ref with enum name
8217 fmd->setEnumClassScope(cd); // cross ref with enum name
8218 fmd->setOuterScope(cd);
8219 fmd->makeRelated();
8220 cd->insertMember(fmd);
8221 }
8222 else
8223 {
8224 if (!fmd->isStrongEnumValue()) // only non strong enum values can be globally added
8225 {
8226 const ClassDef *fcd=fmd->getClassDef();
8227 if (fcd==cd) // enum value is inside a class
8228 {
8229 //printf("Inserting enum field %s in enum scope %s\n",
8230 // qPrint(fmd->name()),qPrint(md->name()));
8231 md->insertEnumField(fmd); // add field def to list
8232 fmd->setEnumScope(md); // cross ref with enum name
8233 }
8234 }
8235 }
8236 }
8237 }
8238 }
8239 }
8240 }
8241 }
8242 }
8243 // move the newly added members into mn
8244 for (auto &e : extraMembers)
8245 {
8246 MemberName *emn=mnsd->add(e.name);
8247 emn->push_back(std::move(e.member));
8248 }
8249 }
8250 }
8251 }
8252 else
8253 {
8254 for (const auto &e : root->children()) addEnumValuesToEnums(e.get());
8255 }
8256}
8257
8258//----------------------------------------------------------------------
8259
8260static void addEnumDocs(const Entry *root,MemberDefMutable *md)
8261{
8262 AUTO_TRACE();
8263 // documentation outside a compound overrides the documentation inside it
8264 {
8265 md->setDocumentation(root->doc,root->docFile,root->docLine);
8266 md->setDocsForDefinition(!root->proto);
8267 }
8268
8269 // brief descriptions inside a compound override the documentation
8270 // outside it
8271 {
8272 md->setBriefDescription(root->brief,root->briefFile,root->briefLine);
8273 }
8274
8275 if (md->inbodyDocumentation().empty() || !root->parent()->name.empty())
8276 {
8278 }
8279
8280 if (root->mGrpId!=-1 && md->getMemberGroupId()==-1)
8281 {
8282 md->setMemberGroupId(root->mGrpId);
8283 }
8284
8286 md->setRefItems(root->sli);
8287 md->setRequirementReferences(root->rqli);
8288
8289 const GroupDef *gd=md->getGroupDef();
8290 if (gd==nullptr && !root->groups.empty()) // member not grouped but out-of-line documentation is
8291 {
8292 addMemberToGroups(root,md);
8293 }
8295}
8296
8297//----------------------------------------------------------------------
8298// Search for the name in the associated groups. If a matching member
8299// definition exists, then add the documentation to it and return true,
8300// otherwise false.
8301
8302static bool tryAddEnumDocsToGroupMember(const Entry *root,const DString &name)
8303{
8304 for (const auto &g : root->groups)
8305 {
8306 const GroupDef *gd = Doxygen::groupLinkedMap->find(g.groupname);
8307 if (gd)
8308 {
8309 MemberList *ml = gd->getMemberList(MemberListType::DecEnumMembers());
8310 if (ml)
8311 {
8312 MemberDefMutable *md = toMemberDefMutable(ml->find(name));
8313 if (md)
8314 {
8315 addEnumDocs(root,md);
8316 return true;
8317 }
8318 }
8319 }
8320 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
8321 {
8322 warn(root->fileName, root->startLine,
8323 "Found non-existing group '{}' for the command '{}', ignoring command",
8324 g.groupname, Grouping::getGroupPriName( g.pri )
8325 );
8326 }
8327 }
8328
8329 return false;
8330}
8331
8332//----------------------------------------------------------------------
8333// find the documentation blocks for the enumerations
8334
8335static void findEnumDocumentation(const Entry *root)
8336{
8337 if (root->section.isEnumDoc() &&
8338 !root->name.empty() &&
8339 root->name.at(0)!='@' // skip anonymous enums
8340 )
8341 {
8342 DString name;
8343 DString scope;
8344 if (size_t i = root->name.rfind("::"); i!=DString::npos) // scope is specified as part of the name
8345 {
8346 name=root->name.mid(i+2); // extract name
8347 scope=root->name.left(i); // extract scope
8348 //printf("Scope='%s' Name='%s'\n",qPrint(scope),qPrint(name));
8349 }
8350 else // just the name
8351 {
8352 name=root->name;
8353 }
8354 if (root->parent()->section.isScope() && !root->parent()->name.empty()) // found enum docs inside a compound
8355 {
8356 if (!scope.empty()) scope.prepend("::");
8357 scope.prepend(root->parent()->name);
8358 }
8359 const ClassDef *cd = getClass(scope);
8361 const FileDef *fd = root->fileDef();
8362 AUTO_TRACE("Found docs for enum with name '{}' and scope '{}' in context '{}' cd='{}', nd='{}' fd='{}'",
8363 name,scope,root->parent()->name,
8364 cd ? cd->name() : DString("<none>"),
8365 nd ? nd->name() : DString("<none>"),
8366 fd ? fd->name() : DString("<none>"));
8367
8368 if (!name.empty())
8369 {
8370 bool found = tryAddEnumDocsToGroupMember(root, name);
8371 if (!found)
8372 {
8374 if (mn)
8375 {
8376 for (const auto &imd : *mn)
8377 {
8378 MemberDefMutable *md = toMemberDefMutable(imd.get());
8379 if (md && md->isEnumerate())
8380 {
8381 const ClassDef *mcd = md->getClassDef();
8382 const NamespaceDef *mnd = md->getNamespaceDef();
8383 const FileDef *mfd = md->getFileDef();
8384 if (cd && mcd==cd)
8385 {
8386 AUTO_TRACE_ADD("Match found for class scope");
8387 addEnumDocs(root,md);
8388 found = true;
8389 break;
8390 }
8391 else if (cd==nullptr && mcd==nullptr && nd!=nullptr && mnd==nd)
8392 {
8393 AUTO_TRACE_ADD("Match found for namespace scope");
8394 addEnumDocs(root,md);
8395 found = true;
8396 break;
8397 }
8398 else if (cd==nullptr && nd==nullptr && mcd==nullptr && mnd==nullptr && fd==mfd)
8399 {
8400 AUTO_TRACE_ADD("Match found for global scope");
8401 addEnumDocs(root,md);
8402 found = true;
8403 break;
8404 }
8405 }
8406 }
8407 }
8408 }
8409 if (!found)
8410 {
8411 warn(root->fileName,root->startLine, "Documentation for undefined enum '{}' found.", name);
8412 }
8413 }
8414 }
8415 for (const auto &e : root->children()) findEnumDocumentation(e.get());
8416}
8417
8418// search for each enum (member or function) in mnl if it has documented
8419// enum values.
8420static void findDEV(const MemberNameLinkedMap &mnsd)
8421{
8422 // for each member name
8423 for (const auto &mn : mnsd)
8424 {
8425 // for each member definition
8426 for (const auto &imd : *mn)
8427 {
8428 MemberDefMutable *md = toMemberDefMutable(imd.get());
8429 if (md && md->isEnumerate()) // member is an enum
8430 {
8431 int documentedEnumValues=0;
8432 // for each enum value
8433 for (const auto &fmd : md->enumFieldList())
8434 {
8435 if (fmd->isLinkableInProject()) documentedEnumValues++;
8436 }
8437 // at least one enum value is documented
8438 if (documentedEnumValues>0) md->setDocumentedEnumValues(true);
8439 }
8440 }
8441 }
8442}
8443
8444// search for each enum (member or function) if it has documented enum
8445// values.
8451
8452//----------------------------------------------------------------------
8453
8455{
8456 auto &index = Index::instance();
8457 // for each class member name
8458 for (const auto &mn : *Doxygen::memberNameLinkedMap)
8459 {
8460 // for each member definition
8461 for (const auto &md : *mn)
8462 {
8463 index.addClassMemberNameToIndex(md.get());
8464 if (md->getModuleDef())
8465 {
8466 index.addModuleMemberNameToIndex(md.get());
8467 }
8468 }
8469 }
8470 // for each file/namespace function name
8471 for (const auto &mn : *Doxygen::functionNameLinkedMap)
8472 {
8473 // for each member definition
8474 for (const auto &md : *mn)
8475 {
8476 if (md->getNamespaceDef())
8477 {
8478 index.addNamespaceMemberNameToIndex(md.get());
8479 }
8480 else
8481 {
8482 index.addFileMemberNameToIndex(md.get());
8483 }
8484 if (md->getModuleDef())
8485 {
8486 index.addModuleMemberNameToIndex(md.get());
8487 }
8488 }
8489 }
8490
8491 index.sortMemberIndexLists();
8492}
8493
8494//----------------------------------------------------------------------
8495
8496static void addToIndices()
8497{
8498 for (const auto &cd : *Doxygen::classLinkedMap)
8499 {
8500 if (cd->isLinkableInProject())
8501 {
8502 Doxygen::indexList->addIndexItem(cd.get(),nullptr);
8503 if (Doxygen::searchIndex.enabled())
8504 {
8505 Doxygen::searchIndex.setCurrentDoc(cd.get(),cd->anchor(),false);
8506 Doxygen::searchIndex.addWord(cd->localName(),true);
8507 }
8508 }
8509 }
8510
8511 for (const auto &cd : *Doxygen::conceptLinkedMap)
8512 {
8513 if (cd->isLinkableInProject())
8514 {
8515 Doxygen::indexList->addIndexItem(cd.get(),nullptr);
8516 if (Doxygen::searchIndex.enabled())
8517 {
8518 Doxygen::searchIndex.setCurrentDoc(cd.get(),cd->anchor(),false);
8519 Doxygen::searchIndex.addWord(cd->localName(),true);
8520 }
8521 }
8522 }
8523
8524 for (const auto &nd : *Doxygen::namespaceLinkedMap)
8525 {
8526 if (nd->isLinkableInProject())
8527 {
8528 Doxygen::indexList->addIndexItem(nd.get(),nullptr);
8529 if (Doxygen::searchIndex.enabled())
8530 {
8531 Doxygen::searchIndex.setCurrentDoc(nd.get(),nd->anchor(),false);
8532 Doxygen::searchIndex.addWord(nd->localName(),true);
8533 }
8534 }
8535 }
8536
8537 for (const auto &fn : *Doxygen::inputNameLinkedMap)
8538 {
8539 for (const auto &fd : *fn)
8540 {
8541 if (Doxygen::searchIndex.enabled() && fd->isLinkableInProject())
8542 {
8543 Doxygen::searchIndex.setCurrentDoc(fd.get(),fd->anchor(),false);
8544 Doxygen::searchIndex.addWord(fd->localName(),true);
8545 }
8546 }
8547 }
8548
8549 auto addWordsForTitle = [](const Definition *d,const DString &anchor,const DString &title)
8550 {
8552 if (Doxygen::searchIndex.enabled())
8553 {
8554 Doxygen::searchIndex.setCurrentDoc(d,anchor,false);
8555 std::string s = title.str();
8556 static const reg::Ex re(R"(\a[\w-]*)");
8557 reg::Iterator it(s,re);
8559 for (; it!=end ; ++it)
8560 {
8561 const auto &match = *it;
8562 std::string matchStr = match.str();
8563 Doxygen::searchIndex.addWord(matchStr,true);
8564 }
8565 }
8566 };
8567
8568 for (const auto &gd : *Doxygen::groupLinkedMap)
8569 {
8570 if (gd->isLinkableInProject())
8571 {
8572 addWordsForTitle(gd.get(),gd->anchor(),gd->groupTitle());
8573 }
8574 }
8575
8576 for (const auto &pd : *Doxygen::pageLinkedMap)
8577 {
8578 if (pd->isLinkableInProject())
8579 {
8580 addWordsForTitle(pd.get(),pd->anchor(),pd->title());
8581 }
8582 }
8583
8585 {
8586 addWordsForTitle(Doxygen::mainPage.get(),Doxygen::mainPage->anchor(),Doxygen::mainPage->title());
8587 }
8588
8589 auto addMemberToSearchIndex = [](const MemberDef *md)
8590 {
8591 if (Doxygen::searchIndex.enabled())
8592 {
8593 Doxygen::searchIndex.setCurrentDoc(md,md->anchor(),false);
8594 DString ln=md->localName();
8595 DString qn=md->qualifiedName();
8597 if (ln!=qn)
8598 {
8600 if (md->getClassDef())
8601 {
8602 Doxygen::searchIndex.addWord(md->getClassDef()->displayName(),true);
8603 }
8604 if (md->getNamespaceDef())
8605 {
8606 Doxygen::searchIndex.addWord(md->getNamespaceDef()->displayName(),true);
8607 }
8608 }
8609 }
8610 };
8611
8612 auto getScope = [](const MemberDef *md)
8613 {
8614 const Definition *scope = nullptr;
8615 if (md->getGroupDef()) scope = md->getGroupDef();
8616 else if (md->getClassDef()) scope = md->getClassDef();
8617 else if (md->getNamespaceDef()) scope = md->getNamespaceDef();
8618 else if (md->getFileDef()) scope = md->getFileDef();
8619 return scope;
8620 };
8621
8622 auto addMemberToIndices = [addMemberToSearchIndex,getScope](const MemberDef *md)
8623 {
8624 if (md->isLinkableInProject())
8625 {
8626 if (!(md->isEnumerate() && md->isAnonymous()))
8627 {
8628 Doxygen::indexList->addIndexItem(getScope(md),md);
8629 addMemberToSearchIndex(md);
8630 }
8631 if (md->isEnumerate())
8632 {
8633 for (const auto &fmd : md->enumFieldList())
8634 {
8635 Doxygen::indexList->addIndexItem(getScope(fmd),fmd);
8636 addMemberToSearchIndex(fmd);
8637 }
8638 }
8639 }
8640 };
8641
8642 // for each class member name
8643 for (const auto &mn : *Doxygen::memberNameLinkedMap)
8644 {
8645 // for each member definition
8646 for (const auto &md : *mn)
8647 {
8648 addMemberToIndices(md.get());
8649 }
8650 }
8651 // for each file/namespace function name
8652 for (const auto &mn : *Doxygen::functionNameLinkedMap)
8653 {
8654 // for each member definition
8655 for (const auto &md : *mn)
8656 {
8657 addMemberToIndices(md.get());
8658 }
8659 }
8660}
8661
8662//----------------------------------------------------------------------
8663
8665{
8666 // for each member name
8667 for (const auto &mn : *Doxygen::memberNameLinkedMap)
8668 {
8669 // for each member definition
8670 for (const auto &imd : *mn)
8671 {
8672 MemberDefMutable *md = toMemberDefMutable(imd.get());
8673 if (md)
8674 {
8676 }
8677 }
8678 }
8679 // for each member name
8680 for (const auto &mn : *Doxygen::functionNameLinkedMap)
8681 {
8682 // for each member definition
8683 for (const auto &imd : *mn)
8684 {
8685 MemberDefMutable *md = toMemberDefMutable(imd.get());
8686 if (md)
8687 {
8689 }
8690 }
8691 }
8692}
8693
8694// recursive helper function looking for reimplements/implemented
8695// by relations between class cd and direct or indirect base class bcd
8696static void computeMemberRelationsForBaseClass(const ClassDef *cd,const BaseClassDef *bcd,const ArgumentList *actualArgs)
8697{
8698 for (const auto &mn : cd->memberNameInfoLinkedMap()) // for each member in class cd with a unique name
8699 {
8700 for (const auto &imd : *mn) // for each member with a given name
8701 {
8702 MemberDefMutable *md = toMemberDefMutable(imd->memberDef());
8703 if (md && (md->isFunction() || md->isCSharpProperty())) // filter on reimplementable members
8704 {
8705 ClassDef *mbcd = bcd->classDef;
8706 if (mbcd && mbcd->isLinkable()) // filter on linkable classes
8707 {
8708 const auto &bmn = mbcd->memberNameInfoLinkedMap();
8709 const auto &bmni = bmn.find(mn->memberName());
8710 if (bmni) // there are base class members with the same name
8711 {
8712 for (const auto &ibmd : *bmni) // for base class member with that name
8713 {
8714 MemberDefMutable *bmd = toMemberDefMutable(ibmd->memberDef());
8715 if (bmd) // not part of an inline namespace
8716 {
8717 auto lang = bmd->getLanguage();
8718 auto compType = mbcd->compoundType();
8719 if (bmd->virtualness()!=Specifier::Normal ||
8720 lang==SrcLangExt::Python ||
8721 lang==SrcLangExt::Java ||
8722 lang==SrcLangExt::PHP ||
8723 compType==ClassDef::Interface ||
8724 compType==ClassDef::Protocol)
8725 {
8726 const ArgumentList &bmdAl = bmd->argumentList();
8727 const ArgumentList &mdAl = md->argumentList();
8728 const ClassDef *baseClass = bcd->classDef;
8729 const ClassDef *baseTemplate = baseClass->templateMaster() ? baseClass->templateMaster() : baseClass;
8730 const ClassDef *memberClass = bmd->getClassDef();
8731 bool instantiateBaseMember = actualArgs &&
8732 (memberClass==baseClass || memberClass==baseTemplate) &&
8733 !baseTemplate->templateArguments().empty();
8734 bool useDerivedScope = false;
8735 ArgumentList instantiatedBmdAl;
8736 DString instantiatedBmdType = bmd->typeString();
8737 if (instantiateBaseMember)
8738 {
8739 instantiatedBmdAl = bmdAl;
8740 for (Argument &arg : instantiatedBmdAl)
8741 {
8743 arg.type,baseTemplate->templateArguments(),actualArgs);
8744 useDerivedScope = useDerivedScope || substitutedType!=arg.type;
8745 arg.type = substitutedType;
8746 }
8747 DString substitutedTrailingReturnType = substituteTemplateArgumentsInString(
8748 instantiatedBmdAl.trailingReturnType(),baseTemplate->templateArguments(),actualArgs);
8749 useDerivedScope = useDerivedScope ||
8750 substitutedTrailingReturnType!=instantiatedBmdAl.trailingReturnType();
8751 instantiatedBmdAl.setTrailingReturnType(substitutedTrailingReturnType);
8753 instantiatedBmdType,baseTemplate->templateArguments(),actualArgs);
8754 useDerivedScope = useDerivedScope || substitutedType!=instantiatedBmdType;
8755 instantiatedBmdType = substitutedType;
8756 }
8757 //printf(" Base argList='%s'\n Super argList='%s'\n",
8758 // qPrint(argListToString(bmdAl)),
8759 // qPrint(argListToString(mdAl))
8760 // );
8761 if (
8762 lang==SrcLangExt::Python ||
8763 matchArguments2(useDerivedScope ? cd : bmd->getOuterScope(),
8764 useDerivedScope ? cd->getFileDef() : bmd->getFileDef(),
8765 instantiatedBmdType,instantiateBaseMember ? &instantiatedBmdAl : &bmdAl,
8766 md->getOuterScope(), md->getFileDef(), md->typeString(),&mdAl,
8767 true,lang
8768 )
8769 )
8770 {
8771 if (lang==SrcLangExt::Python && md->name().startsWith("__")) continue; // private members do not reimplement
8772 //printf("match!\n");
8773 const MemberDef *rmd = md->reimplements();
8774 if (rmd==nullptr) // not already assigned
8775 {
8776 //printf("%s: setting (new) reimplements member %s\n",qPrint(md->qualifiedName()),qPrint(bmd->qualifiedName()));
8777 md->setReimplements(bmd);
8778 }
8779 //printf("%s: add reimplementedBy member %s\n",qPrint(bmd->qualifiedName()),qPrint(md->qualifiedName()));
8780 bmd->insertReimplementedBy(md);
8781 }
8782 else
8783 {
8784 //printf("no match!\n");
8785 }
8786 }
8787 }
8788 }
8789 }
8790 }
8791 }
8792 }
8793 }
8794
8795 // do also for indirect base classes
8796 for (const auto &bbcd : bcd->classDef->baseClasses())
8797 {
8798 DString templSpec = bbcd.templSpecifiers;
8799 const ClassDef *baseClass = bcd->classDef;
8800 const ClassDef *baseTemplate = baseClass->templateMaster() ? baseClass->templateMaster() : baseClass;
8801 if (actualArgs)
8802 {
8803 templSpec = substituteTemplateArgumentsInString(templSpec,baseTemplate->templateArguments(),actualArgs);
8804 }
8805 auto nextActualArgs = stringToArgumentList(baseClass->getLanguage(),templSpec);
8806 computeMemberRelationsForBaseClass(cd,&bbcd,nextActualArgs.get());
8807 }
8808}
8809
8810//----------------------------------------------------------------------
8811// computes the relation between all members. For each member 'm'
8812// the members that override the implementation of 'm' are searched and
8813// the member that 'm' overrides is searched.
8814
8816{
8817 for (const auto &cd : *Doxygen::classLinkedMap)
8818 {
8819 if (cd->isLinkable())
8820 {
8821 for (const auto &bcd : cd->baseClasses())
8822 {
8823 auto actualArgs = stringToArgumentList(cd->getLanguage(),bcd.templSpecifiers);
8824 computeMemberRelationsForBaseClass(cd.get(),&bcd,actualArgs.get());
8825 }
8826 }
8827 }
8828}
8829
8830//----------------------------------------------------------------------------
8831
8833{
8834 // for each class
8835 for (const auto &cd : *Doxygen::classLinkedMap)
8836 {
8837 // that is a template
8838 for (const auto &ti : cd->getTemplateInstances())
8839 {
8840 ClassDefMutable *tcdm = toClassDefMutable(ti.classDef);
8841 if (tcdm && tcdm->isImplicitTemplateInstance()) // (partial) specializations have their own members
8842 {
8843 tcdm->addMembersToTemplateInstance(cd.get(),cd->templateArguments(),ti.templSpec);
8844 }
8845 }
8846 }
8847}
8848
8849//----------------------------------------------------------------------------
8850
8851static void mergeCategories()
8852{
8853 AUTO_TRACE();
8854 // merge members of categories into the class they extend
8855 for (const auto &cd : *Doxygen::classLinkedMap)
8856 {
8857 if (size_t i=cd->name().find('('); i!=DString::npos) // it is an Objective-C category
8858 {
8859 DString baseName=cd->name().left(i);
8860 ClassDefMutable *baseClass=toClassDefMutable(Doxygen::classLinkedMap->find(baseName));
8861 if (baseClass)
8862 {
8863 AUTO_TRACE_ADD("merging members of category {} into {}",cd->name(),baseClass->name());
8864 baseClass->mergeCategory(cd.get());
8865 }
8866 }
8867 }
8868}
8869
8870// builds the list of all members for each class
8871
8873{
8874 // merge the member list of base classes into the inherited classes.
8875 for (const auto &cd : *Doxygen::classLinkedMap)
8876 {
8877 if (// !cd->isReference() && // not an external class
8878 cd->subClasses().empty() && // is a root of the hierarchy
8879 !cd->baseClasses().empty()) // and has at least one base class
8880 {
8881 ClassDefMutable *cdm = toClassDefMutable(cd.get());
8882 if (cdm)
8883 {
8884 //printf("*** merging members for %s\n",qPrint(cd->name()));
8885 cdm->mergeMembers();
8886 }
8887 }
8888 }
8889 // now sort the member list of all members for all classes.
8890 for (const auto &cd : *Doxygen::classLinkedMap)
8891 {
8892 ClassDefMutable *cdm = toClassDefMutable(cd.get());
8893 if (cdm)
8894 {
8895 cdm->sortAllMembersList();
8896 }
8897 }
8898}
8899
8900//----------------------------------------------------------------------------
8901
8903{
8904 auto processSourceFile = [](FileDef *fd,OutputList &ol,ClangTUParser *parser)
8905 {
8906 bool showSources = fd->generateSourceFile() && !Htags::useHtags; // sources need to be shown in the output
8907 bool parseSources = !fd->isReference() && Doxygen::parseSourcesNeeded; // we needed to parse the sources even if we do not show them
8908 if (showSources)
8909 {
8910 msg("Generating code for file {}...\n",fd->docName());
8911 fd->writeSourceHeader(ol);
8912 fd->writeSourceBody(ol,parser);
8913 fd->writeSourceFooter(ol);
8914 }
8915 else if (parseSources)
8916 {
8917 msg("Parsing code for file {}...\n",fd->docName());
8918 fd->parseSource(parser);
8919 }
8920 };
8921 if (!Doxygen::inputNameLinkedMap->empty())
8922 {
8923#if USE_LIBCLANG
8925 {
8926 StringUnorderedSet processedFiles;
8927
8928 // create a dictionary with files to process
8929 StringUnorderedSet filesToProcess;
8930
8931 for (const auto &fn : *Doxygen::inputNameLinkedMap)
8932 {
8933 for (const auto &fd : *fn)
8934 {
8935 filesToProcess.insert(fd->absFilePath().str());
8936 }
8937 }
8938 // process source files (and their include dependencies)
8939 for (const auto &fn : *Doxygen::inputNameLinkedMap)
8940 {
8941 for (const auto &fd : *fn)
8942 {
8943 if (fd->isSource() && !fd->isReference() && fd->getLanguage()==SrcLangExt::Cpp &&
8944 (fd->generateSourceFile() ||
8946 )
8947 )
8948 {
8949 auto clangParser = ClangParser::instance()->createTUParser(fd.get());
8950 clangParser->parse();
8951 processSourceFile(fd.get(),*g_outputList,clangParser.get());
8952
8953 for (auto incFile : clangParser->filesInSameTU())
8954 {
8955 if (filesToProcess.find(incFile)!=filesToProcess.end() && // part of input
8956 fd->absFilePath()!=incFile && // not same file
8957 processedFiles.find(incFile)==processedFiles.end()) // not yet marked as processed
8958 {
8959 StringVector moreFiles;
8960 bool ambig = false;
8961 FileDef *ifd=Doxygen::inputNameLinkedMap->findFileDef(incFile,ambig);
8962 if (ifd && !ifd->isReference())
8963 {
8964 processSourceFile(ifd,*g_outputList,clangParser.get());
8965 processedFiles.insert(incFile);
8966 }
8967 }
8968 }
8969 processedFiles.insert(fd->absFilePath().str());
8970 }
8971 }
8972 }
8973 // process remaining files
8974 for (const auto &fn : *Doxygen::inputNameLinkedMap)
8975 {
8976 for (const auto &fd : *fn)
8977 {
8978 if (processedFiles.find(fd->absFilePath().str())==processedFiles.end()) // not yet processed
8979 {
8980 if (fd->getLanguage()==SrcLangExt::Cpp) // C/C++ file, use clang parser
8981 {
8982 auto clangParser = ClangParser::instance()->createTUParser(fd.get());
8983 clangParser->parse();
8984 processSourceFile(fd.get(),*g_outputList,clangParser.get());
8985 }
8986 else // non C/C++ file, use built-in parser
8987 {
8988 processSourceFile(fd.get(),*g_outputList,nullptr);
8989 }
8990 }
8991 }
8992 }
8993 }
8994 else
8995#endif
8996 {
8997 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
8998 if (numThreads>1)
8999 {
9000 msg("Generating code files using {} threads.\n",numThreads);
9001 struct SourceContext
9002 {
9003 SourceContext(FileDef *fd_,bool gen_,const OutputList &ol_)
9004 : fd(fd_), generateSourceFile(gen_), ol(ol_) {}
9005 FileDef *fd;
9006 bool generateSourceFile;
9007 OutputList ol;
9008 };
9009 ThreadPool threadPool(numThreads);
9010 std::vector< std::future< std::shared_ptr<SourceContext> > > results;
9011 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9012 {
9013 for (const auto &fd : *fn)
9014 {
9015 bool generateSourceFile = fd->generateSourceFile() && !Htags::useHtags;
9016 auto ctx = std::make_shared<SourceContext>(fd.get(),generateSourceFile,*g_outputList);
9017 auto processFile = [ctx]()
9018 {
9019 if (ctx->generateSourceFile)
9020 {
9021 msg("Generating code for file {}...\n",ctx->fd->docName());
9022 }
9023 else
9024 {
9025 msg("Parsing code for file {}...\n",ctx->fd->docName());
9026 }
9027 StringVector filesInSameTu;
9028 ctx->fd->getAllIncludeFilesRecursively(filesInSameTu);
9029 if (ctx->generateSourceFile) // sources need to be shown in the output
9030 {
9031 ctx->fd->writeSourceHeader(ctx->ol);
9032 ctx->fd->writeSourceBody(ctx->ol,nullptr);
9033 ctx->fd->writeSourceFooter(ctx->ol);
9034 }
9035 else if (!ctx->fd->isReference() && Doxygen::parseSourcesNeeded)
9036 // we needed to parse the sources even if we do not show them
9037 {
9038 ctx->fd->parseSource(nullptr);
9039 }
9040 return ctx;
9041 };
9042 results.emplace_back(threadPool.queue(processFile));
9043 }
9044 }
9045 for (auto &f : results)
9046 {
9047 auto ctx = f.get();
9048 }
9049 }
9050 else // single threaded version
9051 {
9052 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9053 {
9054 for (const auto &fd : *fn)
9055 {
9056 StringVector filesInSameTu;
9057 fd->getAllIncludeFilesRecursively(filesInSameTu);
9058 processSourceFile(fd.get(),*g_outputList,nullptr);
9059 }
9060 }
9061 }
9062 }
9063 }
9064}
9065
9066//----------------------------------------------------------------------------
9067
9068static void generateFileDocs()
9069{
9070 if (Index::instance().numDocumentedFiles()==0) return;
9071
9072 if (!Doxygen::inputNameLinkedMap->empty())
9073 {
9074 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
9075 if (numThreads>1) // multi threaded processing
9076 {
9077 struct DocContext
9078 {
9079 DocContext(FileDef *fd_,const OutputList &ol_)
9080 : fd(fd_), ol(ol_) {}
9081 FileDef *fd;
9082 OutputList ol;
9083 };
9084 ThreadPool threadPool(numThreads);
9085 std::vector< std::future< std::shared_ptr<DocContext> > > results;
9086 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9087 {
9088 for (const auto &fd : *fn)
9089 {
9090 bool doc = fd->isLinkableInProject();
9091 if (doc)
9092 {
9093 auto ctx = std::make_shared<DocContext>(fd.get(),*g_outputList);
9094 auto processFile = [ctx]() {
9095 msg("Generating docs for file {}...\n",ctx->fd->docName());
9096 ctx->fd->writeDocumentation(ctx->ol);
9097 return ctx;
9098 };
9099 results.emplace_back(threadPool.queue(processFile));
9100 }
9101 }
9102 }
9103 for (auto &f : results)
9104 {
9105 auto ctx = f.get();
9106 }
9107 }
9108 else // single threaded processing
9109 {
9110 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9111 {
9112 for (const auto &fd : *fn)
9113 {
9114 bool doc = fd->isLinkableInProject();
9115 if (doc)
9116 {
9117 msg("Generating docs for file {}...\n",fd->docName());
9118 fd->writeDocumentation(*g_outputList);
9119 }
9120 }
9121 }
9122 }
9123 }
9124}
9125
9126//----------------------------------------------------------------------------
9127
9129{
9130 // add source references for class definitions
9131 for (const auto &cd : *Doxygen::classLinkedMap)
9132 {
9133 const FileDef *fd=cd->getBodyDef();
9134 if (fd && cd->isLinkableInProject() && cd->getStartDefLine()!=-1)
9135 {
9136 const_cast<FileDef*>(fd)->addSourceRef(cd->getStartDefLine(),cd.get(),nullptr);
9137 }
9138 }
9139 // add source references for concept definitions
9140 for (const auto &cd : *Doxygen::conceptLinkedMap)
9141 {
9142 const FileDef *fd=cd->getBodyDef();
9143 if (fd && cd->isLinkableInProject() && cd->getStartDefLine()!=-1)
9144 {
9145 const_cast<FileDef*>(fd)->addSourceRef(cd->getStartDefLine(),cd.get(),nullptr);
9146 }
9147 }
9148 // add source references for namespace definitions
9149 for (const auto &nd : *Doxygen::namespaceLinkedMap)
9150 {
9151 const FileDef *fd=nd->getBodyDef();
9152 if (fd && nd->isLinkableInProject() && nd->getStartDefLine()!=-1)
9153 {
9154 const_cast<FileDef*>(fd)->addSourceRef(nd->getStartDefLine(),nd.get(),nullptr);
9155 }
9156 }
9157
9158 // add source references for member names
9159 for (const auto &mn : *Doxygen::memberNameLinkedMap)
9160 {
9161 for (const auto &md : *mn)
9162 {
9163 //printf("class member %s: def=%s body=%d link?=%d\n",
9164 // qPrint(md->name()),
9165 // md->getBodyDef()?qPrint(md->getBodyDef()->name()):"<none>",
9166 // md->getStartBodyLine(),md->isLinkableInProject());
9167 const FileDef *fd=md->getBodyDef();
9168 if (fd &&
9169 md->getStartDefLine()!=-1 &&
9170 md->isLinkableInProject() &&
9172 )
9173 {
9174 //printf("Found member '%s' in file '%s' at line '%d' def=%s\n",
9175 // qPrint(md->name()),qPrint(fd->name()),md->getStartBodyLine(),qPrint(md->getOuterScope()->name()));
9176 const_cast<FileDef*>(fd)->addSourceRef(md->getStartDefLine(),md->getOuterScope(),md.get());
9177 }
9178 }
9179 }
9180 for (const auto &mn : *Doxygen::functionNameLinkedMap)
9181 {
9182 for (const auto &md : *mn)
9183 {
9184 const FileDef *fd=md->getBodyDef();
9185 //printf("member %s body=[%d,%d] fd=%p link=%d parseSources=%d\n",
9186 // qPrint(md->name()),
9187 // md->getStartBodyLine(),md->getEndBodyLine(),fd,
9188 // md->isLinkableInProject(),
9189 // Doxygen::parseSourcesNeeded);
9190 if (fd &&
9191 md->getStartDefLine()!=-1 &&
9192 md->isLinkableInProject() &&
9194 )
9195 {
9196 //printf("Found member '%s' in file '%s' at line '%d' def=%s\n",
9197 // qPrint(md->name()),qPrint(fd->name()),md->getStartBodyLine(),qPrint(md->getOuterScope()->name()));
9198 const_cast<FileDef*>(fd)->addSourceRef(md->getStartDefLine(),md->getOuterScope(),md.get());
9199 }
9200 }
9201 }
9202}
9203
9204//----------------------------------------------------------------------------
9205
9206// add the macro definitions found during preprocessing as file members
9207static void buildDefineList()
9208{
9209 AUTO_TRACE();
9210 for (const auto &s : g_inputFiles)
9211 {
9212 auto it = Doxygen::macroDefinitions.find(s);
9214 {
9215 for (const auto &def : it->second)
9216 {
9217 auto md = createMemberDef(
9218 def.fileName,def.lineNr,def.columnNr,
9219 "#define",def.name,def.args,DString(),
9220 Protection::Public,Specifier::Normal,false,Relationship::Member,MemberType::Define,
9221 ArgumentList(),ArgumentList(),"");
9222 auto mmd = toMemberDefMutable(md.get());
9223
9224 if (!def.args.empty())
9225 {
9226 mmd->moveArgumentList(stringToArgumentList(SrcLangExt::Cpp, def.args));
9227 }
9228 mmd->setInitializer(def.definition);
9229 mmd->setFileDef(def.fileDef);
9230 mmd->setDefinition("#define "+def.name);
9231
9233 if (def.fileDef)
9234 {
9235 const MemberList *defMl = def.fileDef->getMemberList(MemberListType::DocDefineMembers());
9236 if (defMl)
9237 {
9238 const MemberDef *defMd = defMl->findRev(def.name);
9239 if (defMd) // definition already stored
9240 {
9241 mmd->setRedefineCount(defMd->redefineCount()+1);
9242 }
9243 }
9244 def.fileDef->insertMember(md.get());
9245 }
9246 AUTO_TRACE_ADD("adding macro {} with definition {}",def.name,def.definition);
9247 mn->push_back(std::move(md));
9248 }
9249 }
9250 }
9251}
9252
9253//----------------------------------------------------------------------------
9254
9255static void sortMemberLists()
9256{
9257 // sort class member lists
9258 for (const auto &cd : *Doxygen::classLinkedMap)
9259 {
9260 ClassDefMutable *cdm = toClassDefMutable(cd.get());
9261 if (cdm)
9262 {
9263 cdm->sortMemberLists();
9264 }
9265 }
9266
9267 // sort namespace member lists
9268 for (const auto &nd : *Doxygen::namespaceLinkedMap)
9269 {
9271 if (ndm)
9272 {
9273 ndm->sortMemberLists();
9274 }
9275 }
9276
9277 // sort file member lists
9278 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9279 {
9280 for (const auto &fd : *fn)
9281 {
9282 fd->sortMemberLists();
9283 }
9284 }
9285
9286 // sort group member lists
9287 for (const auto &gd : *Doxygen::groupLinkedMap)
9288 {
9289 gd->sortMemberLists();
9290 }
9291
9293}
9294
9295//----------------------------------------------------------------------------
9296
9297static bool isSymbolHidden(const Definition *d)
9298{
9299 bool hidden = d->isHidden();
9300 const Definition *parent = d->getOuterScope();
9301 return parent ? hidden || isSymbolHidden(parent) : hidden;
9302}
9303
9305{
9306 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
9307 if (numThreads>1)
9308 {
9309 ThreadPool threadPool(numThreads);
9310 std::vector < std::future< void > > results;
9311 // queue the work
9312 for (const auto &[name,symList] : *Doxygen::symbolMap)
9313 {
9314 for (const auto &def : symList)
9315 {
9317 if (dm && !isSymbolHidden(def) && !def->isArtificial() && def->isLinkableInProject())
9318 {
9319 auto processTooltip = [dm]() {
9320 dm->computeTooltip();
9321 };
9322 results.emplace_back(threadPool.queue(processTooltip));
9323 }
9324 }
9325 }
9326 // wait for the results
9327 for (auto &f : results)
9328 {
9329 f.get();
9330 }
9331 }
9332 else
9333 {
9334 for (const auto &[name,symList] : *Doxygen::symbolMap)
9335 {
9336 for (const auto &def : symList)
9337 {
9339 if (dm && !isSymbolHidden(def) && !def->isArtificial() && def->isLinkableInProject())
9340 {
9341 dm->computeTooltip();
9342 }
9343 }
9344 }
9345 }
9346}
9347
9348//----------------------------------------------------------------------------
9349
9351{
9352 for (const auto &cd : *Doxygen::classLinkedMap)
9353 {
9354 ClassDefMutable *cdm = toClassDefMutable(cd.get());
9355 if (cdm)
9356 {
9357 cdm->setAnonymousEnumType();
9358 }
9359 }
9360}
9361
9362//----------------------------------------------------------------------------
9363
9364static void countMembers()
9365{
9366 for (const auto &cd : *Doxygen::classLinkedMap)
9367 {
9368 ClassDefMutable *cdm = toClassDefMutable(cd.get());
9369 if (cdm)
9370 {
9371 cdm->countMembers();
9372 }
9373 }
9374
9375 for (const auto &nd : *Doxygen::namespaceLinkedMap)
9376 {
9378 if (ndm)
9379 {
9380 ndm->countMembers();
9381 }
9382 }
9383
9384 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9385 {
9386 for (const auto &fd : *fn)
9387 {
9388 fd->countMembers();
9389 }
9390 }
9391
9392 for (const auto &gd : *Doxygen::groupLinkedMap)
9393 {
9394 gd->countMembers();
9395 }
9396
9397 auto &mm = ModuleManager::instance();
9398 mm.countMembers();
9399}
9400
9401
9402//----------------------------------------------------------------------------
9403// generate the documentation for all classes
9404
9405static void generateDocsForClassList(const std::vector<ClassDefMutable*> &classList)
9406{
9407 AUTO_TRACE();
9408 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
9409 if (numThreads>1) // multi threaded processing
9410 {
9411 struct DocContext
9412 {
9413 DocContext(ClassDefMutable *cd_,const OutputList &ol_)
9414 : cd(cd_), ol(ol_) {}
9415 ClassDefMutable *cd;
9416 OutputList ol;
9417 };
9418 ThreadPool threadPool(numThreads);
9419 std::vector< std::future< std::shared_ptr<DocContext> > > results;
9420 for (const auto &cd : classList)
9421 {
9422 //printf("cd=%s getOuterScope=%p global=%p\n",qPrint(cd->name()),cd->getOuterScope(),Doxygen::globalScope);
9423 if (cd->getOuterScope()==nullptr || // <-- should not happen, but can if we read an old tag file
9424 cd->getOuterScope()==Doxygen::globalScope // only look at global classes
9425 )
9426 {
9427 auto ctx = std::make_shared<DocContext>(cd,*g_outputList);
9428 auto processFile = [ctx]()
9429 {
9430 msg("Generating docs for compound {}...\n",ctx->cd->displayName());
9431
9432 // skip external references, anonymous compounds and
9433 // template instances
9434 if (!ctx->cd->isHidden() && !ctx->cd->isEmbeddedInOuterScope() &&
9435 ctx->cd->isLinkableInProject() && !ctx->cd->isImplicitTemplateInstance())
9436 {
9437 ctx->cd->writeDocumentation(ctx->ol);
9438 ctx->cd->writeMemberList(ctx->ol);
9439 }
9440
9441 // even for undocumented classes, the inner classes can be documented.
9442 ctx->cd->writeDocumentationForInnerClasses(ctx->ol);
9443 return ctx;
9444 };
9445 results.emplace_back(threadPool.queue(processFile));
9446 }
9447 }
9448 for (auto &f : results)
9449 {
9450 auto ctx = f.get();
9451 }
9452 }
9453 else // single threaded processing
9454 {
9455 for (const auto &cd : classList)
9456 {
9457 //printf("cd=%s getOuterScope=%p global=%p hidden=%d embeddedInOuterScope=%d\n",
9458 // qPrint(cd->name()),cd->getOuterScope(),Doxygen::globalScope,cd->isHidden(),cd->isEmbeddedInOuterScope());
9459 if (cd->getOuterScope()==nullptr || // <-- should not happen, but can if we read an old tag file
9460 cd->getOuterScope()==Doxygen::globalScope // only look at global classes
9461 )
9462 {
9463 // skip external references, anonymous compounds and
9464 // template instances
9465 if ( !cd->isHidden() && !cd->isEmbeddedInOuterScope() &&
9466 cd->isLinkableInProject() && !cd->isImplicitTemplateInstance())
9467 {
9468 msg("Generating docs for compound {}...\n",cd->displayName());
9469
9470 cd->writeDocumentation(*g_outputList);
9471 cd->writeMemberList(*g_outputList);
9472 }
9473 // even for undocumented classes, the inner classes can be documented.
9474 cd->writeDocumentationForInnerClasses(*g_outputList);
9475 }
9476 }
9477 }
9478}
9479
9480static void addClassAndNestedClasses(std::vector<ClassDefMutable*> &list,ClassDefMutable *cd)
9481{
9482 list.push_back(cd);
9483 for (const auto &innerCdi : cd->getClasses())
9484 {
9485 ClassDefMutable *innerCd = toClassDefMutable(innerCdi);
9486 if (innerCd)
9487 {
9488 AUTO_TRACE("innerCd={} isLinkable={} isImplicitTemplateInstance={} protectLevelVisible={} embeddedInOuterScope={}",
9489 innerCd->name(),innerCd->isLinkableInProject(),innerCd->isImplicitTemplateInstance(),protectionLevelVisible(innerCd->protection()),
9490 innerCd->isEmbeddedInOuterScope());
9491 }
9492 if (innerCd && innerCd->isLinkableInProject() && !innerCd->isImplicitTemplateInstance() &&
9493 protectionLevelVisible(innerCd->protection()) &&
9494 !innerCd->isEmbeddedInOuterScope()
9495 )
9496 {
9497 list.push_back(innerCd);
9498 addClassAndNestedClasses(list,innerCd);
9499 }
9500 }
9501}
9502
9504{
9505 std::vector<ClassDefMutable*> classList;
9506 for (const auto &cdi : *Doxygen::classLinkedMap)
9507 {
9508 ClassDefMutable *cd = toClassDefMutable(cdi.get());
9509 if (cd && (cd->getOuterScope()==nullptr ||
9511 {
9512 addClassAndNestedClasses(classList,cd);
9513 }
9514 }
9515 for (const auto &cdi : *Doxygen::hiddenClassLinkedMap)
9516 {
9517 ClassDefMutable *cd = toClassDefMutable(cdi.get());
9518 if (cd && (cd->getOuterScope()==nullptr ||
9520 {
9521 addClassAndNestedClasses(classList,cd);
9522 }
9523 }
9524 generateDocsForClassList(classList);
9525}
9526
9527//----------------------------------------------------------------------------
9528
9530{
9531 for (const auto &cdi : *Doxygen::conceptLinkedMap)
9532 {
9534
9535 //printf("cd=%s getOuterScope=%p global=%p\n",qPrint(cd->name()),cd->getOuterScope(),Doxygen::globalScope);
9536 if (cd &&
9537 (cd->getOuterScope()==nullptr || // <-- should not happen, but can if we read an old tag file
9538 cd->getOuterScope()==Doxygen::globalScope // only look at global concepts
9539 ) && !cd->isHidden() && cd->isLinkableInProject()
9540 )
9541 {
9542 msg("Generating docs for concept {}...\n",cd->displayName());
9544 }
9545 }
9546}
9547
9548//----------------------------------------------------------------------------
9549
9551{
9552 for (const auto &mn : *Doxygen::memberNameLinkedMap)
9553 {
9554 for (const auto &imd : *mn)
9555 {
9556 MemberDefMutable *md = toMemberDefMutable(imd.get());
9557 //static int count=0;
9558 //printf("%04d Member '%s'\n",count++,qPrint(md->qualifiedName()));
9559 if (md && md->documentation().empty() && md->briefDescription().empty())
9560 { // no documentation yet
9561 const MemberDef *bmd = md->reimplements();
9562 while (bmd && bmd->documentation().empty() &&
9563 bmd->briefDescription().empty()
9564 )
9565 { // search up the inheritance tree for a documentation member
9566 //printf("bmd=%s class=%s\n",qPrint(bmd->name()),qPrint(bmd->getClassDef()->name()));
9567 bmd = bmd->reimplements();
9568 }
9569 if (bmd) // copy the documentation from the reimplemented member
9570 {
9571 md->setInheritsDocsFrom(bmd);
9572 md->setDocumentation(bmd->documentation(),bmd->docFile(),bmd->docLine());
9574 md->setBriefDescription(bmd->briefDescription(),bmd->briefFile(),bmd->briefLine());
9575 md->copyArgumentNames(bmd);
9577 }
9578 }
9579 }
9580 }
9581}
9582
9583//----------------------------------------------------------------------------
9584
9586{
9587 // for each file
9588 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9589 {
9590 for (const auto &fd : *fn)
9591 {
9592 fd->combineUsingRelations();
9593 }
9594 }
9595
9596 // for each namespace
9597 NamespaceDefSet visitedNamespaces;
9598 for (const auto &nd : *Doxygen::namespaceLinkedMap)
9599 {
9601 if (ndm)
9602 {
9603 ndm->combineUsingRelations(visitedNamespaces);
9604 }
9605 }
9606}
9607
9608//----------------------------------------------------------------------------
9609
9611{
9612 // for each class
9613 for (const auto &cd : *Doxygen::classLinkedMap)
9614 {
9615 ClassDefMutable *cdm = toClassDefMutable(cd.get());
9616 if (cdm)
9617 {
9619 }
9620 }
9621 // for each file
9622 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9623 {
9624 for (const auto &fd : *fn)
9625 {
9626 fd->addMembersToMemberGroup();
9627 }
9628 }
9629 // for each namespace
9630 for (const auto &nd : *Doxygen::namespaceLinkedMap)
9631 {
9633 if (ndm)
9634 {
9636 }
9637 }
9638 // for each group
9639 for (const auto &gd : *Doxygen::groupLinkedMap)
9640 {
9641 gd->addMembersToMemberGroup();
9642 }
9644}
9645
9646//----------------------------------------------------------------------------
9647
9649{
9650 // for each class
9651 for (const auto &cd : *Doxygen::classLinkedMap)
9652 {
9653 ClassDefMutable *cdm = toClassDefMutable(cd.get());
9654 if (cdm)
9655 {
9657 }
9658 }
9659 // for each file
9660 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9661 {
9662 for (const auto &fd : *fn)
9663 {
9664 fd->distributeMemberGroupDocumentation();
9665 }
9666 }
9667 // for each namespace
9668 for (const auto &nd : *Doxygen::namespaceLinkedMap)
9669 {
9671 if (ndm)
9672 {
9674 }
9675 }
9676 // for each group
9677 for (const auto &gd : *Doxygen::groupLinkedMap)
9678 {
9679 gd->distributeMemberGroupDocumentation();
9680 }
9682}
9683
9684//----------------------------------------------------------------------------
9685
9687{
9688 // for each class
9689 for (const auto &cd : *Doxygen::classLinkedMap)
9690 {
9691 ClassDefMutable *cdm = toClassDefMutable(cd.get());
9692 if (cdm)
9693 {
9695 }
9696 }
9697 // for each concept
9698 for (const auto &cd : *Doxygen::conceptLinkedMap)
9699 {
9700 ConceptDefMutable *cdm = toConceptDefMutable(cd.get());
9701 if (cdm)
9702 {
9704 }
9705 }
9706 // for each file
9707 for (const auto &fn : *Doxygen::inputNameLinkedMap)
9708 {
9709 for (const auto &fd : *fn)
9710 {
9711 fd->findSectionsInDocumentation();
9712 }
9713 }
9714 // for each namespace
9715 for (const auto &nd : *Doxygen::namespaceLinkedMap)
9716 {
9718 if (ndm)
9719 {
9721 }
9722 }
9723 // for each group
9724 for (const auto &gd : *Doxygen::groupLinkedMap)
9725 {
9726 gd->findSectionsInDocumentation();
9727 }
9728 // for each page
9729 for (const auto &pd : *Doxygen::pageLinkedMap)
9730 {
9731 pd->findSectionsInDocumentation();
9732 }
9733 // for each directory
9734 for (const auto &dd : *Doxygen::dirLinkedMap)
9735 {
9736 dd->findSectionsInDocumentation();
9737 }
9739 if (Doxygen::mainPage) Doxygen::mainPage->findSectionsInDocumentation();
9740}
9741
9742//----------------------------------------------------------------------
9743
9744
9746{
9747 // remove all references to classes from the cache
9748 // as there can be new template instances in the inheritance path
9749 // to this class. Optimization: only remove those classes that
9750 // have inheritance instances as direct or indirect sub classes.
9752
9753 // remove all cached typedef resolutions whose target is a
9754 // template class as this may now be a template instance
9755 // for each global function name
9756 for (const auto &fn : *Doxygen::functionNameLinkedMap)
9757 {
9758 // for each function with that name
9759 for (const auto &ifmd : *fn)
9760 {
9761 MemberDefMutable *fmd = toMemberDefMutable(ifmd.get());
9762 if (fmd && fmd->isTypedefValCached())
9763 {
9764 const ClassDef *cd = fmd->getCachedTypedefVal();
9765 if (cd->isTemplate()) fmd->invalidateTypedefValCache();
9766 }
9767 }
9768 }
9769 // for each class method name
9770 for (const auto &nm : *Doxygen::memberNameLinkedMap)
9771 {
9772 // for each function with that name
9773 for (const auto &imd : *nm)
9774 {
9775 MemberDefMutable *md = toMemberDefMutable(imd.get());
9776 if (md && md->isTypedefValCached())
9777 {
9778 const ClassDef *cd = md->getCachedTypedefVal();
9779 if (cd->isTemplate()) md->invalidateTypedefValCache();
9780 }
9781 }
9782 }
9783}
9784
9785//----------------------------------------------------------------------------
9786
9788{
9789 // Remove all unresolved references to classes from the cache.
9790 // This is needed before resolving the inheritance relations, since
9791 // it would otherwise not find the inheritance relation
9792 // for C in the example below, as B::I was already found to be unresolvable
9793 // (which is correct if you ignore the inheritance relation between A and B).
9794 //
9795 // class A { class I {} };
9796 // class B : public A {};
9797 // class C : public B::I {};
9799
9800 // for each class method name
9801 for (const auto &nm : *Doxygen::memberNameLinkedMap)
9802 {
9803 // for each function with that name
9804 for (const auto &imd : *nm)
9805 {
9806 MemberDefMutable *md = toMemberDefMutable(imd.get());
9807 if (md)
9808 {
9810 }
9811 }
9812 }
9813
9814}
9815
9816//----------------------------------------------------------------------------
9817// Returns true if the entry and member definition have equal file names,
9818// otherwise false.
9819
9820static bool haveEqualFileNames(const Entry *root, const MemberDef *md)
9821{
9822 if (const FileDef *fd = md->getFileDef())
9823 {
9824 return fd->absFilePath() == root->fileName;
9825 }
9826 return false;
9827}
9828
9829//----------------------------------------------------------------------------
9830
9831static void addDefineDoc(const Entry *root, MemberDefMutable *md)
9832{
9833 md->setDocumentation(root->doc,root->docFile,root->docLine);
9834 md->setDocsForDefinition(!root->proto);
9835 md->setBriefDescription(root->brief,root->briefFile,root->briefLine);
9836 if (md->inbodyDocumentation().empty())
9837 {
9839 }
9840 if (md->getStartBodyLine()==-1 && root->bodyLine!=-1)
9841 {
9842 md->setBodySegment(root->startLine,root->bodyLine,root->endBodyLine);
9843 md->setBodyDef(root->fileDef());
9844 }
9846 md->setMaxInitLines(root->initLines);
9848 md->setRefItems(root->sli);
9849 md->setRequirementReferences(root->rqli);
9850 md->addQualifiers(root->qualifiers);
9851 if (root->mGrpId!=-1) md->setMemberGroupId(root->mGrpId);
9852 addMemberToGroups(root,md);
9854}
9855
9856//----------------------------------------------------------------------------
9857
9859{
9860 if ((root->section.isDefineDoc() || root->section.isDefine()) && !root->name.empty())
9861 {
9862 //printf("found define '%s' '%s' brief='%s' doc='%s'\n",
9863 // qPrint(root->name),qPrint(root->args),qPrint(root->brief),qPrint(root->doc));
9864
9865 if (root->tagInfo() && !root->name.empty()) // define read from a tag file
9866 {
9867 auto md = createMemberDef(root->tagInfo()->tagName,1,1,
9868 "#define",root->name,root->args,DString(),
9869 Protection::Public,Specifier::Normal,false,Relationship::Member,MemberType::Define,
9870 ArgumentList(),ArgumentList(),"");
9871 auto mmd = toMemberDefMutable(md.get());
9872 mmd->setTagInfo(root->tagInfo());
9873 mmd->setLanguage(root->lang);
9874 mmd->addQualifiers(root->qualifiers);
9875 //printf("Searching for '%s' fd=%p\n",qPrint(filePathName),fd);
9876 mmd->setFileDef(root->parent()->fileDef());
9877 //printf("Adding member=%s\n",qPrint(md->name()));
9879 mn->push_back(std::move(md));
9880 }
9882 if (mn)
9883 {
9884 int count=0;
9885 for (const auto &md : *mn)
9886 {
9887 if (md->memberType()==MemberType::Define) count++;
9888 }
9889 if (count==1)
9890 {
9891 for (const auto &imd : *mn)
9892 {
9893 MemberDefMutable *md = toMemberDefMutable(imd.get());
9894 if (md && md->memberType()==MemberType::Define)
9895 {
9896 addDefineDoc(root,md);
9897 }
9898 }
9899 }
9900 else if (count>1 &&
9901 (!root->doc.empty() ||
9902 !root->brief.empty() ||
9903 root->bodyLine!=-1
9904 )
9905 )
9906 // multiple defines don't know where to add docs
9907 // but maybe they are in different files together with their documentation
9908 {
9909 for (const auto &imd : *mn)
9910 {
9911 MemberDefMutable *md = toMemberDefMutable(imd.get());
9912 if (md && md->memberType()==MemberType::Define)
9913 {
9914 if (haveEqualFileNames(root, md) || isEntryInGroupOfMember(root, md))
9915 // doc and define in the same file or group assume they belong together.
9916 {
9917 addDefineDoc(root,md);
9918 }
9919 }
9920 }
9921 //warn("define {} found in the following files:\n",root->name);
9922 //warn("Cannot determine where to add the documentation found "
9923 // "at line {} of file {}. \n",
9924 // root->startLine,root->fileName);
9925 }
9926 }
9927 else if (!root->doc.empty() || !root->brief.empty()) // define not found
9928 {
9929 bool preEnabled = Config_getBool(ENABLE_PREPROCESSING);
9930 if (preEnabled)
9931 {
9932 warn(root->fileName,root->startLine,"documentation for unknown define {} found.",root->name);
9933 }
9934 else
9935 {
9936 warn(root->fileName,root->startLine, "found documented #define {} but ignoring it because ENABLE_PREPROCESSING is NO.", root->name);
9937 }
9938 }
9939 }
9940 for (const auto &e : root->children()) findDefineDocumentation(e.get());
9941}
9942
9943//----------------------------------------------------------------------------
9944
9945static void findDirDocumentation(const Entry *root)
9946{
9947 if (root->section.isDirDoc())
9948 {
9949 DString normalizedName = root->name;
9950 normalizedName = substitute(normalizedName,"\\","/");
9951 //printf("root->docFile=%s normalizedName=%s\n",
9952 // qPrint(root->docFile),qPrint(normalizedName));
9953 if (root->docFile==normalizedName) // current dir?
9954 {
9955 if (size_t lastSlashPos=normalizedName.rfind('/'); lastSlashPos!=DString::npos) // strip file name
9956 {
9957 normalizedName=normalizedName.left(lastSlashPos);
9958 }
9959 }
9960 if (normalizedName.at(normalizedName.length()-1)!='/')
9961 {
9962 normalizedName+='/';
9963 }
9964 DirDef *matchingDir=nullptr;
9965 for (const auto &dir : *Doxygen::dirLinkedMap)
9966 {
9967 //printf("Dir: %s<->%s\n",qPrint(dir->name()),qPrint(normalizedName));
9968 if (dir->name().right(normalizedName.length())==normalizedName)
9969 {
9970 if (matchingDir)
9971 {
9972 warn(root->fileName,root->startLine,
9973 "\\dir command matches multiple directories.\n"
9974 " Applying the command for directory {}\n"
9975 " Ignoring the command for directory {}",
9976 matchingDir->name(),dir->name()
9977 );
9978 }
9979 else
9980 {
9981 matchingDir=dir.get();
9982 }
9983 }
9984 }
9985 if (matchingDir)
9986 {
9987 //printf("Match for with dir %s #anchor=%zu\n",qPrint(matchingDir->name()),root->anchors.size());
9988 matchingDir->setBriefDescription(root->brief,root->briefFile,root->briefLine);
9989 matchingDir->setDocumentation(root->doc,root->docFile,root->docLine);
9990 matchingDir->setRefItems(root->sli);
9991 matchingDir->setRequirementReferences(root->rqli);
9992 matchingDir->addSectionsToDefinition(root->anchors);
9993 root->commandOverrides.apply_directoryGraph([&](bool b) { matchingDir->overrideDirectoryGraph(b); });
9994 addDirToGroups(root,matchingDir);
9995 }
9996 else
9997 {
9998 warn(root->fileName,root->startLine,"No matching directory found for command \\dir {}",normalizedName);
9999 }
10000 }
10001 for (const auto &e : root->children()) findDirDocumentation(e.get());
10002}
10003
10004//----------------------------------------------------------------------------
10006{
10007 if (root->section.isRequirementDoc())
10008 {
10010 }
10011 for (const auto &e : root->children()) buildRequirementsList(e.get());
10012}
10013
10014//----------------------------------------------------------------------------
10015// create a (sorted) list of separate documentation pages
10016
10017static void buildPageList(Entry *root)
10018{
10019 if (root->section.isPageDoc())
10020 {
10021 if (!root->name.empty())
10022 {
10023 addRelatedPage(root);
10024 }
10025 }
10026 else if (root->section.isMainpageDoc())
10027 {
10028 DString title=root->args.stripWhiteSpace();
10029 if (title.empty()) title=theTranslator->trMainPage();
10030 //DString name = Config_getBool(GENERATE_TREEVIEW)?"main":"index";
10031 DString name = "index";
10032 addRefItem(root->sli,
10033 name,
10034 theTranslator->trPage(true,true),
10035 name,
10036 title,
10037 DString(),nullptr
10038 );
10039 }
10040 for (const auto &e : root->children()) buildPageList(e.get());
10041}
10042
10043// search for the main page defined in this project
10044static void findMainPage(Entry *root)
10045{
10046 if (root->section.isMainpageDoc())
10047 {
10048 if (Doxygen::mainPage==nullptr && root->tagInfo()==nullptr)
10049 {
10050 //printf("mainpage: docLine=%d startLine=%d\n",root->docLine,root->startLine);
10051 //printf("Found main page! \n======\n%s\n=======\n",qPrint(root->doc));
10052 DString title=root->args.stripWhiteSpace();
10053 if (title.empty()) title = Config_getString(PROJECT_NAME);
10054 //DString indexName=Config_getBool(GENERATE_TREEVIEW)?"main":"index";
10055 DString indexName="index";
10057 indexName, root->brief+root->doc+root->inbodyDocs,title);
10058 //setFileNameForSections(root->anchors,"index",Doxygen::mainPage);
10059 Doxygen::mainPage->setBriefDescription(root->brief,root->briefFile,root->briefLine);
10060 Doxygen::mainPage->setBodySegment(root->startLine,root->startLine,-1);
10061 Doxygen::mainPage->setFileName(indexName);
10062 Doxygen::mainPage->setLocalToc(root->localToc);
10064
10066 if (si)
10067 {
10068 if (!si->ref().empty()) // we are from a tag file
10069 {
10070 // a page name is a label as well! but should no be double either
10072 Doxygen::mainPage->name(),
10073 indexName,
10074 root->startLine,
10075 Doxygen::mainPage->title(),
10077 0); // level 0
10078 }
10079 else if (si->lineNr() != -1)
10080 {
10081 warn(root->fileName,root->startLine,"multiple use of section label '{}' for main page, (first occurrence: {}, line {})",
10082 Doxygen::mainPage->name(),si->fileName(),si->lineNr());
10083 }
10084 else
10085 {
10086 warn(root->fileName,root->startLine,"multiple use of section label '{}' for main page, (first occurrence: {})",
10087 Doxygen::mainPage->name(),si->fileName());
10088 }
10089 }
10090 else
10091 {
10092 // a page name is a label as well! but should no be double either
10094 Doxygen::mainPage->name(),
10095 indexName,
10096 root->startLine,
10097 Doxygen::mainPage->title(),
10099 0); // level 0
10100 }
10101 Doxygen::mainPage->addSectionsToDefinition(root->anchors);
10102 }
10103 else if (root->tagInfo()==nullptr)
10104 {
10105 warn(root->fileName,root->startLine,
10106 "found more than one \\mainpage comment block! (first occurrence: {}, line {}), Skipping current block!",
10107 Doxygen::mainPage->docFile(),Doxygen::mainPage->getStartBodyLine());
10108 }
10109 }
10110 for (const auto &e : root->children()) findMainPage(e.get());
10111}
10112
10113// search for the main page imported via tag files and add only the section labels
10114static void findMainPageTagFiles(Entry *root)
10115{
10116 if (root->section.isMainpageDoc())
10117 {
10118 if (Doxygen::mainPage && root->tagInfo())
10119 {
10120 Doxygen::mainPage->addSectionsToDefinition(root->anchors);
10121 }
10122 }
10123 for (const auto &e : root->children()) findMainPageTagFiles(e.get());
10124}
10125
10126static void computePageRelations(Entry *root)
10127{
10128 if ((root->section.isPageDoc() || root->section.isMainpageDoc()) && !root->name.empty())
10129 {
10130 PageDef *pd = root->section.isPageDoc() ?
10132 Doxygen::mainPage.get();
10133 if (pd)
10134 {
10135 for (const BaseInfo &bi : root->extends)
10136 {
10138 if (pd==subPd)
10139 {
10140 term("page defined {} with label {} is a direct "
10141 "subpage of itself! Please remove this cyclic dependency.\n",
10142 warn_line(pd->docFile(),pd->docLine()),pd->name());
10143 }
10144 else if (subPd)
10145 {
10146 pd->addInnerCompound(subPd);
10147 //printf("*** Added subpage relation: %s->%s\n",
10148 // qPrint(pd->name()),qPrint(subPd->name()));
10149 }
10150 }
10151 }
10152 }
10153 for (const auto &e : root->children()) computePageRelations(e.get());
10154}
10155
10157{
10158 for (const auto &pd : *Doxygen::pageLinkedMap)
10159 {
10160 Definition *ppd = pd->getOuterScope();
10161 while (ppd)
10162 {
10163 if (ppd==pd.get())
10164 {
10165 term("page defined {} with label {} is a subpage "
10166 "of itself! Please remove this cyclic dependency.\n",
10167 warn_line(pd->docFile(),pd->docLine()),pd->name());
10168 }
10169 ppd=ppd->getOuterScope();
10170 }
10171 }
10172}
10173
10174//----------------------------------------------------------------------------
10175
10177{
10178 for (const auto &si : SectionManager::instance())
10179 {
10180 //printf("si->label='%s' si->definition=%s si->fileName='%s'\n",
10181 // qPrint(si->label),si->definition?qPrint(si->definition->name()):"<none>",
10182 // qPrint(si->fileName));
10183 PageDef *pd=nullptr;
10184
10185 // hack: the items of a todo/test/bug/deprecated list are all fragments from
10186 // different files, so the resulting section's all have the wrong file
10187 // name (not from the todo/test/bug/deprecated list, but from the file in
10188 // which they are defined). We correct this here by looking at the
10189 // generated section labels!
10191 {
10192 DString label="_"+rl->listName(); // "_todo", "_test", ...
10193 if (si->label().left(label.length())==label)
10194 {
10195 si->setFileName(rl->listName());
10196 si->setGenerated(true);
10197 break;
10198 }
10199 }
10200
10201 //printf("start: si->label=%s si->fileName=%s\n",qPrint(si->label),qPrint(si->fileName));
10202 if (!si->generated())
10203 {
10204 // if this section is in a page and the page is in a group, then we
10205 // have to adjust the link file name to point to the group.
10206 if (!si->fileName().empty() &&
10207 (pd=Doxygen::pageLinkedMap->find(si->fileName())) &&
10208 pd->getGroupDef())
10209 {
10210 si->setFileName(pd->getGroupDef()->getOutputFileBase());
10211 }
10212
10213 if (si->definition())
10214 {
10215 // TODO: there should be one function in Definition that returns
10216 // the file to link to, so we can avoid the following tests.
10217 const GroupDef *gd=nullptr;
10218 if (si->definition()->definitionType()==Definition::TypeMember)
10219 {
10220 gd = (toMemberDef(si->definition()))->getGroupDef();
10221 }
10222
10223 if (gd)
10224 {
10225 si->setFileName(gd->getOutputFileBase());
10226 }
10227 else
10228 {
10229 //si->fileName=si->definition->getOutputFileBase();
10230 //printf("Setting si->fileName to %s\n",qPrint(si->fileName));
10231 }
10232 }
10233 }
10234 //printf("end: si->label=%s si->fileName=%s\n",qPrint(si->label),qPrint(si->fileName));
10235 }
10236}
10237
10238
10239
10240//----------------------------------------------------------------------------
10241// generate all separate documentation pages
10242
10243
10244static void generatePageDocs()
10245{
10246 //printf("documentedPages=%d real=%d\n",documentedPages,Doxygen::pageLinkedMap->count());
10247 if (Index::instance().numDocumentedPages()==0) return;
10248 for (const auto &pd : *Doxygen::pageLinkedMap)
10249 {
10250 if (!pd->getGroupDef() && !pd->isReference())
10251 {
10252 msg("Generating docs for page {}...\n",pd->name());
10253 pd->writeDocumentation(*g_outputList);
10254 }
10255 }
10256}
10257
10258//----------------------------------------------------------------------------
10259// create a (sorted) list & dictionary of example pages
10260
10261static void buildExampleList(Entry *root)
10262{
10263 if ((root->section.isExample() || root->section.isExampleLineno()) && !root->name.empty())
10264 {
10265 if (Doxygen::exampleLinkedMap->find(root->name))
10266 {
10267 warn(root->fileName,root->startLine,"Example {} was already documented. Ignoring documentation found here.",root->name);
10268 }
10269 else
10270 {
10272 createPageDef(root->fileName,root->startLine,
10273 root->name,root->doc+" "+root->inbodyDocs,root->args));
10274 pd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
10275 pd->setFileName(convertNameToFile(pd->name()+"-example",false,true));
10277 pd->setLanguage(root->lang);
10278 pd->setShowLineNo(root->section.isExampleLineno());
10279
10280 //we don't add example to groups
10281 //addExampleToGroups(root,pd);
10282 }
10283 }
10284 for (const auto &e : root->children()) buildExampleList(e.get());
10285}
10286
10287//----------------------------------------------------------------------------
10288// prints the Entry tree (for debugging)
10289
10290void printNavTree(Entry *root,int indent)
10291{
10293 {
10294 DString indentStr;
10295 indentStr.fill(' ',indent);
10296 Debug::print(Debug::Entries,0,"{}{} at {}:{} (sec={}, spec={})\n",
10297 indentStr.empty()?"":indentStr,
10298 root->name.empty()?"<empty>":root->name,
10299 root->fileName,root->startLine,
10300 root->section.to_string(),
10301 root->spec.to_string());
10302 for (const auto &e : root->children())
10303 {
10304 printNavTree(e.get(),indent+2);
10305 }
10306 }
10307}
10308
10309
10310//----------------------------------------------------------------------------
10311// prints the Sections tree (for debugging)
10312
10314{
10316 {
10317 for (const auto &si : SectionManager::instance())
10318 {
10319 Debug::print(Debug::Sections,0,"Section = {}, file = {}, title = {}, type = {}, ref = {}\n",
10320 si->label(),si->fileName(),si->title(),si->type().level(),si->ref());
10321 }
10322 }
10323}
10324
10325
10326//----------------------------------------------------------------------------
10327// generate the example documentation
10328
10330{
10332 for (const auto &pd : *Doxygen::exampleLinkedMap)
10333 {
10334 msg("Generating docs for example {}...\n",pd->name());
10335 SrcLangExt lang = getLanguageFromFileName(pd->name(), SrcLangExt::Unknown);
10336 if (lang != SrcLangExt::Unknown)
10337 {
10338 DString ext = getFileNameExtension(pd->name());
10339 auto intf = Doxygen::parserManager->getCodeParser(ext);
10340 intf->resetCodeParserState();
10341 }
10342 DString n=pd->getOutputFileBase();
10343 startFile(*g_outputList,n,false,n,pd->name());
10345 g_outputList->docify(pd->name());
10348 DString lineNoOptStr;
10349 if (pd->showLineNo())
10350 {
10351 lineNoOptStr="{lineno}";
10352 }
10353 g_outputList->generateDoc(pd->docFile(), // file
10354 pd->docLine(), // startLine
10355 pd.get(), // context
10356 nullptr, // memberDef
10357 (pd->briefDescription().empty()?"":pd->briefDescription()+"\n\n")+
10358 pd->documentation()+"\n\n\\include"+lineNoOptStr+" "+pd->name(), // docs
10359 DocOptions()
10360 .setIndexWords(true)
10361 .setExample(pd->name()));
10362 endFile(*g_outputList); // contains g_outputList->endContents()
10363 }
10365}
10366
10367//----------------------------------------------------------------------------
10368// generate module pages
10369
10371{
10372 for (const auto &gd : *Doxygen::groupLinkedMap)
10373 {
10374 if (!gd->isReference())
10375 {
10376 gd->writeDocumentation(*g_outputList);
10377 }
10378 }
10379}
10380
10381//----------------------------------------------------------------------------
10382// generate module pages
10383
10385{
10386 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
10387 if (numThreads>1) // multi threaded processing
10388 {
10389 struct DocContext
10390 {
10391 DocContext(ClassDefMutable *cdm_,const OutputList &ol_)
10392 : cdm(cdm_), ol(ol_) {}
10393 ClassDefMutable *cdm;
10394 OutputList ol;
10395 };
10396 ThreadPool threadPool(numThreads);
10397 std::vector< std::future< std::shared_ptr<DocContext> > > results;
10398 // for each class in the namespace...
10399 for (const auto &cd : classList)
10400 {
10402 if (cdm)
10403 {
10404 auto ctx = std::make_shared<DocContext>(cdm,*g_outputList);
10405 auto processFile = [ctx]()
10406 {
10407 if ( ( ctx->cdm->isLinkableInProject() &&
10408 !ctx->cdm->isImplicitTemplateInstance()
10409 ) // skip external references, anonymous compounds and
10410 // template instances and nested classes
10411 && !ctx->cdm->isHidden() && !ctx->cdm->isEmbeddedInOuterScope()
10412 )
10413 {
10414 msg("Generating docs for compound {}...\n",ctx->cdm->displayName());
10415 ctx->cdm->writeDocumentation(ctx->ol);
10416 ctx->cdm->writeMemberList(ctx->ol);
10417 }
10418 ctx->cdm->writeDocumentationForInnerClasses(ctx->ol);
10419 return ctx;
10420 };
10421 results.emplace_back(threadPool.queue(processFile));
10422 }
10423 }
10424 // wait for the results
10425 for (auto &f : results)
10426 {
10427 auto ctx = f.get();
10428 }
10429 }
10430 else // single threaded processing
10431 {
10432 // for each class in the namespace...
10433 for (const auto &cd : classList)
10434 {
10436 if (cdm)
10437 {
10438 if ( ( cd->isLinkableInProject() &&
10439 !cd->isImplicitTemplateInstance()
10440 ) // skip external references, anonymous compounds and
10441 // template instances and nested classes
10442 && !cd->isHidden() && !cd->isEmbeddedInOuterScope()
10443 )
10444 {
10445 msg("Generating docs for compound {}...\n",cd->displayName());
10446
10449 }
10451 }
10452 }
10453 }
10454}
10455
10457{
10458 // for each concept in the namespace...
10459 for (const auto &cd : conceptList)
10460 {
10462 if ( cdm && cd->isLinkableInProject() && !cd->isHidden())
10463 {
10464 msg("Generating docs for concept {}...\n",cd->name());
10466 }
10467 }
10468}
10469
10471{
10472 bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE);
10473
10474 //writeNamespaceIndex(*g_outputList);
10475
10476 // for each namespace...
10477 for (const auto &nd : *Doxygen::namespaceLinkedMap)
10478 {
10479 if (nd->isLinkableInProject())
10480 {
10482 if (ndm)
10483 {
10484 msg("Generating docs for namespace {}\n",nd->displayName());
10486 }
10487 }
10488
10489 generateNamespaceClassDocs(nd->getClasses());
10490 if (sliceOpt)
10491 {
10492 generateNamespaceClassDocs(nd->getInterfaces());
10493 generateNamespaceClassDocs(nd->getStructs());
10494 generateNamespaceClassDocs(nd->getRecords());
10495 generateNamespaceClassDocs(nd->getExceptions());
10496 }
10497 generateNamespaceConceptDocs(nd->getConcepts());
10498 }
10499}
10500
10502{
10503 std::string oldDir = Dir::currentDirPath();
10504 Dir::setCurrent(Config_getString(HTML_OUTPUT).str());
10507 {
10508 err("failed to run html help compiler on {}\n", HtmlHelp::hhpFileName);
10509 }
10510 Dir::setCurrent(oldDir);
10511}
10512
10514{
10515 DString args = Qhp::qhpFileName + " -o \"" + Qhp::getQchFileName() + "\"";
10516 std::string oldDir = Dir::currentDirPath();
10517 Dir::setCurrent(Config_getString(HTML_OUTPUT).str());
10518
10519 DString qhgLocation=Config_getString(QHG_LOCATION);
10520 if (Debug::isFlagSet(Debug::Qhp)) // produce info for debugging
10521 {
10522 // run qhelpgenerator -v and extract the Qt version used
10523 DString cmd=qhgLocation+ " -v 2>&1";
10524 Debug::print(Debug::ExtCmd,0,"Executing popen(`{}`)\n",cmd);
10525 FILE *f=Portable::popen(cmd,"r");
10526 if (!f)
10527 {
10528 err("could not execute {}\n",qhgLocation);
10529 }
10530 else
10531 {
10532 const size_t bufSize = 1024;
10533 char inBuf[bufSize+1];
10534 size_t numRead=fread(inBuf,1,bufSize,f);
10535 inBuf[numRead] = '\0';
10536 Debug::print(Debug::Qhp,0,"{}",inBuf);
10538
10539 int qtVersion=0;
10540 static const reg::Ex versionReg(R"(Qt (\d+)\.(\d+)\.(\d+))");
10541 reg::Match match;
10542 std::string s = inBuf;
10543 if (reg::search(s,match,versionReg))
10544 {
10545 qtVersion = 10000*DString(match[1].str()).toInt() +
10546 100*DString(match[2].str()).toInt() +
10547 DString(match[3].str()).toInt();
10548 }
10549 if (qtVersion>0 && (qtVersion<60000 || qtVersion >= 60205))
10550 {
10551 // dump the output of qhelpgenerator -c file.qhp
10552 // Qt<6 or Qt>=6.2.5 or higher, see https://bugreports.qt.io/browse/QTBUG-101070
10553 cmd=qhgLocation+ " -c " + Qhp::qhpFileName + " 2>&1";
10554 Debug::print(Debug::ExtCmd,0,"Executing popen(`{}`)\n",cmd);
10555 f=Portable::popen(cmd,"r");
10556 if (!f)
10557 {
10558 err("could not execute {}\n",qhgLocation);
10559 }
10560 else
10561 {
10562 std::string output;
10563 while ((numRead=fread(inBuf,1,bufSize,f))>0)
10564 {
10565 inBuf[numRead] = '\0';
10566 output += inBuf;
10567 }
10569 Debug::print(Debug::Qhp,0,"{}",output);
10570 }
10571 }
10572 }
10573 }
10574
10575 if (Portable::system(qhgLocation, args, false))
10576 {
10577 err("failed to run qhelpgenerator on {}\n",Qhp::qhpFileName);
10578 }
10579 Dir::setCurrent(oldDir);
10580}
10581
10582//----------------------------------------------------------------------------
10583
10585{
10586 // check dot path
10587 DString dotPath = Config_getString(DOT_PATH);
10588 if (!dotPath.empty())
10589 {
10590 FileInfo fi(dotPath.str());
10591 if (!(fi.exists() && fi.isFile()) )// not an existing user specified path + exec
10592 {
10593 dotPath = dotPath+"/dot"+Portable::commandExtension();
10594 FileInfo dp(dotPath.str());
10595 if (!dp.exists() || !dp.isFile())
10596 {
10597 warn_uncond("the dot tool could not be found as '{}'\n",dotPath);
10598 dotPath = "dot";
10599 dotPath += Portable::commandExtension();
10600 }
10601 else if (dp.isRelative())
10602 {
10603 dotPath = fi.dirPath() + "/" + dotPath;
10604 }
10605 }
10606#if defined(_WIN32) // convert slashes
10607 size_t l=dotPath.length();
10608 for (size_t i=0;i<l;i++) if (dotPath.at(i)=='/') dotPath.at(i)='\\';
10609#endif
10610 }
10611 else
10612 {
10613 dotPath = "dot";
10614 dotPath += Portable::commandExtension();
10615 }
10616 Doxygen::verifiedDotPath = dotPath;
10618}
10619
10620//----------------------------------------------------------------------------
10621
10622/*! Generate a template version of the configuration file.
10623 * If the \a shortList parameter is true a configuration file without
10624 * comments will be generated.
10625 */
10626static void generateConfigFile(const DString &configFile,bool shortList,
10627 bool updateOnly=false)
10628{
10629 std::ofstream f;
10630 bool fileOpened=openOutputFile(configFile,f);
10631 bool writeToStdout=configFile=="-";
10632 if (fileOpened)
10633 {
10634 TextStream t(&f);
10635 Config::writeTemplate(t,shortList,updateOnly);
10636 if (!writeToStdout)
10637 {
10638 if (!updateOnly)
10639 {
10640 msg("\n\nConfiguration file '{}' created.\n\n",configFile);
10641 msg("Now edit the configuration file and enter\n\n");
10642 if (configFile!="Doxyfile" && configFile!="doxyfile")
10643 msg(" doxygen {}\n\n",configFile);
10644 else
10645 msg(" doxygen\n\n");
10646 msg("to generate the documentation for your project\n\n");
10647 }
10648 else
10649 {
10650 msg("\n\nConfiguration file '{}' updated.\n\n",configFile);
10651 }
10652 }
10653 }
10654 else
10655 {
10656 term("Cannot open file {} for writing\n",configFile);
10657 }
10658}
10659
10661{
10662 std::ofstream f;
10663 bool fileOpened=openOutputFile("-",f);
10664 if (fileOpened)
10665 {
10666 TextStream t(&f);
10667 Config::compareDoxyfile(t,diffList);
10668 }
10669 else
10670 {
10671 term("Cannot open stdout for writing\n");
10672 }
10673}
10674
10675//----------------------------------------------------------------------------
10676// read and parse a tag file
10677
10678static void readTagFile(const std::shared_ptr<Entry> &root,const DString &tagLine)
10679{
10680 DString fileName;
10681 DString destName;
10682 if (size_t eqPos = tagLine.find('='); eqPos!=DString::npos) // tag command contains a destination
10683 {
10684 fileName = tagLine.left(eqPos).stripWhiteSpace();
10685 destName = tagLine.mid(eqPos+1).stripWhiteSpace();
10686 if (fileName.empty() || destName.empty()) return;
10687 //printf("insert tagDestination %s->%s\n",qPrint(fi.fileName()),qPrint(destName));
10688 }
10689 else
10690 {
10691 fileName = tagLine;
10692 }
10693
10694 FileInfo fi(fileName.str());
10695 if (!fi.exists() || !fi.isFile())
10696 {
10697 err("Tag file '{}' does not exist or is not a file. Skipping it...\n",fileName);
10698 return;
10699 }
10700
10701 if (Doxygen::tagFileSet.find(fi.absFilePath()) != Doxygen::tagFileSet.end()) return;
10702
10703 Doxygen::tagFileSet.emplace(fi.absFilePath());
10704
10705 if (!destName.empty())
10706 {
10707 Doxygen::tagDestinationMap.emplace(fi.absFilePath(), destName.str());
10708 msg("Reading tag file '{}', location '{}'...\n",fileName,destName);
10709 }
10710 else
10711 {
10712 msg("Reading tag file '{}'...\n",fileName);
10713 }
10714
10715 parseTagFile(root,fi.absFilePath().c_str());
10716}
10717
10718//----------------------------------------------------------------------------
10720{
10721 StringVector latexExtraStyleSheet = Config_getList(LATEX_EXTRA_STYLESHEET);
10722 for (const auto &sheet : latexExtraStyleSheet)
10723 {
10724 std::string fileName = sheet;
10725 if (!fileName.empty())
10726 {
10727 FileInfo fi(fileName);
10728 if (!fi.exists())
10729 {
10730 err("Style sheet '{}' specified by LATEX_EXTRA_STYLESHEET does not exist!\n",fileName);
10731 }
10732 else if (fi.isDir())
10733 {
10734 err("Style sheet '{}' specified by LATEX_EXTRA_STYLESHEET is a directory, it has to be a file!\n", fileName);
10735 }
10736 else
10737 {
10738 DString destFileName = Config_getString(LATEX_OUTPUT)+"/"+fi.fileName();
10740 {
10741 destFileName += LATEX_STYLE_EXTENSION;
10742 }
10743 copyFile(fileName, destFileName);
10744 }
10745 }
10746 }
10747}
10748
10749//----------------------------------------------------------------------------
10750static void copyStyleSheet()
10751{
10752 DString htmlStyleSheet = Config_getString(HTML_STYLESHEET);
10753 if (!htmlStyleSheet.empty())
10754 {
10755 if (!htmlStyleSheet.startsWith("http:") && !htmlStyleSheet.startsWith("https:"))
10756 {
10757 FileInfo fi(htmlStyleSheet.str());
10758 if (!fi.exists())
10759 {
10760 err("Style sheet '{}' specified by HTML_STYLESHEET does not exist!\n",htmlStyleSheet);
10761 htmlStyleSheet = Config_updateString(HTML_STYLESHEET,""); // revert to the default
10762 }
10763 else if (fi.isDir())
10764 {
10765 err("Style sheet '{}' specified by HTML_STYLESHEET is a directory, it has to be a file!\n",htmlStyleSheet);
10766 htmlStyleSheet = Config_updateString(HTML_STYLESHEET,""); // revert to the default
10767 }
10768 else
10769 {
10770 DString destFileName = Config_getString(HTML_OUTPUT)+"/"+fi.fileName();
10771 copyFile(htmlStyleSheet,destFileName);
10772 }
10773 }
10774 }
10775 StringVector htmlExtraStyleSheet = Config_getList(HTML_EXTRA_STYLESHEET);
10776 for (const auto &sheet : htmlExtraStyleSheet)
10777 {
10778 DString fileName(sheet);
10779 if (!fileName.empty() && !fileName.startsWith("http:") && !fileName.startsWith("https:"))
10780 {
10781 FileInfo fi(fileName.str());
10782 if (!fi.exists())
10783 {
10784 err("Style sheet '{}' specified by HTML_EXTRA_STYLESHEET does not exist!\n",fileName);
10785 }
10786 else if (fi.fileName()=="doxygen.css" || fi.fileName()=="tabs.css" || fi.fileName()=="navtree.css")
10787 {
10788 err("Style sheet '{}' specified by HTML_EXTRA_STYLESHEET is already a built-in stylesheet. Please use a different name\n",fi.fileName());
10789 }
10790 else if (fi.isDir())
10791 {
10792 err("Style sheet '{}' specified by HTML_EXTRA_STYLESHEET is a directory, it has to be a file!\n",fileName);
10793 }
10794 else
10795 {
10796 DString destFileName = Config_getString(HTML_OUTPUT)+"/"+fi.fileName();
10797 copyFile(fileName, destFileName);
10798 }
10799 }
10800 }
10801}
10802
10803static void copyLogo(const DString &outputOption, bool toIndex)
10804{
10805 DString projectLogo = projectLogoFile();
10806 if (!projectLogo.empty())
10807 {
10808 FileInfo fi(projectLogo.str());
10809 if (!fi.exists())
10810 {
10811 err("Project logo '{}' specified by PROJECT_LOGO does not exist!\n",projectLogo);
10812 projectLogo = Config_updateString(PROJECT_LOGO,""); // revert to the default
10813 }
10814 else if (fi.isDir())
10815 {
10816 err("Project logo '{}' specified by PROJECT_LOGO is a directory, it has to be a file!\n",projectLogo);
10817 projectLogo = Config_updateString(PROJECT_LOGO,""); // revert to the default
10818 }
10819 else
10820 {
10821 DString destFileName = outputOption+"/"+fi.fileName();
10822 copyFile(projectLogo,destFileName);
10823 if (toIndex) Doxygen::indexList->addImageFile(fi.fileName());
10824 }
10825 }
10826}
10827
10828static void copyIcon(const DString &outputOption, bool toIndex)
10829{
10830 DString projectIcon = Config_getString(PROJECT_ICON);
10831 if (!projectIcon.empty())
10832 {
10833 FileInfo fi(projectIcon.str());
10834 if (!fi.exists())
10835 {
10836 err("Project icon '{}' specified by PROJECT_ICON does not exist!\n",projectIcon);
10837 projectIcon = Config_updateString(PROJECT_ICON,""); // revert to the default
10838 }
10839 else if (fi.isDir())
10840 {
10841 err("Project icon '{}' specified by PROJECT_ICON is a directory, it has to be a file!\n",projectIcon);
10842 projectIcon = Config_updateString(PROJECT_ICON,""); // revert to the default
10843 }
10844 else
10845 {
10846 DString destFileName = outputOption+"/"+fi.fileName();
10847 copyFile(projectIcon,destFileName);
10848 if (toIndex) Doxygen::indexList->addImageFile(fi.fileName());
10849 }
10850 }
10851}
10852
10853static inline void copyExtraFiles(StringVector files,const DString &filesOption,const DString &outputOption, bool toIndex)
10854{
10855 for (const auto &fileName : files)
10856 {
10857 if (!fileName.empty())
10858 {
10859 FileInfo fi(fileName);
10860 if (!fi.exists())
10861 {
10862 err("Extra file '{}' specified in {} does not exist!\n", fileName,filesOption);
10863 }
10864 else if (fi.isDir())
10865 {
10866 err("Extra file '{}' specified in {} is a directory, it has to be a file!\n", fileName,filesOption);
10867 }
10868 else
10869 {
10870 DString destFileName = outputOption+"/"+fi.fileName();
10871 copyFile(fileName, destFileName);
10872 if (toIndex) Doxygen::indexList->addImageFile(fi.fileName());
10873 }
10874 }
10875 }
10876}
10877
10878//----------------------------------------------------------------------------
10879
10881{
10882 for (const auto &fn : *Doxygen::inputNameLinkedMap)
10883 {
10884 struct FileEntry
10885 {
10886 FileEntry(const DString &p,FileDef *fd) : path(p), fileDef(fd) {}
10887 DString path;
10888 FileDef *fileDef;
10889 };
10890
10891 // collect the entry for which to compute the longest common prefix (LCP) of the path
10892 std::vector<FileEntry> fileEntries;
10893 for (const auto &fd : *fn)
10894 {
10895 if (!fd->isReference()) // skip external references
10896 {
10897 fileEntries.emplace_back(fd->getPath(),fd.get());
10898 }
10899 }
10900
10901 size_t size = fileEntries.size();
10902
10903 if (size==1) // name if unique, so diskname is simply the name
10904 {
10905 FileDef *fd = fileEntries[0].fileDef;
10906 fd->setDiskName(fn->fileName());
10907 }
10908 else if (size>1) // multiple occurrences of the same file name
10909 {
10910 // sort the array
10911 std::stable_sort(fileEntries.begin(),
10912 fileEntries.end(),
10913 [](const FileEntry &fe1,const FileEntry &fe2)
10914 { return dstricmp_sort(fe1.path,fe2.path)<0; }
10915 );
10916
10917 // since the entries are sorted, the common prefix of the whole array is same
10918 // as the common prefix between the first and last entry
10919 const FileEntry &first = fileEntries[0];
10920 const FileEntry &last = fileEntries[size-1];
10921 int first_path_size = static_cast<int>(first.path.size())-1; // -1 to skip trailing slash
10922 int last_path_size = static_cast<int>(last.path.size())-1; // -1 to skip trailing slash
10923 int j=0;
10924 int i=0;
10925 for (i=0;i<first_path_size && i<last_path_size;i++)
10926 {
10927 if (first.path[i]=='/') j=i;
10928 if (first.path[i]!=last.path[i]) break;
10929 }
10930 if (i==first_path_size && i<last_path_size && last.path[i]=='/')
10931 {
10932 // case first='some/path' and last='some/path/more' => match is 'some/path'
10933 j=first_path_size;
10934 }
10935 else if (i==last_path_size && i<first_path_size && first.path[i]=='/')
10936 {
10937 // case first='some/path/more' and last='some/path' => match is 'some/path'
10938 j=last_path_size;
10939 }
10940
10941 // add non-common part of the path to the name
10942 for (auto &fileEntry : fileEntries)
10943 {
10944 DString prefix = fileEntry.path.right(fileEntry.path.length()-j-1);
10945 fileEntry.fileDef->setName(prefix+fn->fileName());
10946 //printf("!!!!!!!! non unique disk name=%s:%s\n",qPrint(prefix),fn->fileName());
10947 fileEntry.fileDef->setDiskName(prefix+fn->fileName());
10948 }
10949 }
10950 }
10951}
10952
10953
10954
10955//----------------------------------------------------------------------------
10956
10957static std::unique_ptr<OutlineParserInterface> getParserForFile(const DString &fn)
10958{
10959 DString fileName=fn;
10960 DString extension;
10961 size_t sep = fileName.rfind('/');
10962 size_t ei = fileName.rfind('.');
10963 if (ei!=DString::npos && (sep==DString::npos || ei>sep)) // matches dir/file.ext but not dir.1/file
10964 {
10965 extension=fileName.mid(ei);
10966 }
10967 else
10968 {
10969 extension = ".no_extension";
10970 }
10971
10972 return Doxygen::parserManager->getOutlineParser(extension);
10973}
10974
10975static std::shared_ptr<Entry> parseFile(OutlineParserInterface &parser,
10976 FileDef *fd,const DString &fn,
10977 ClangTUParser *clangParser,bool newTU)
10978{
10979 DString fileName=fn;
10980 AUTO_TRACE("fileName={}",fileName);
10981 DString extension;
10982 if (size_t ei = fileName.rfind('.'); ei!=DString::npos)
10983 {
10984 extension=fileName.mid(ei);
10985 }
10986 else
10987 {
10988 extension = ".no_extension";
10989 }
10990
10991 FileInfo fi(fileName.str());
10992 std::string preBuf;
10993
10994 if (Config_getBool(ENABLE_PREPROCESSING) &&
10995 parser.needsPreprocessing(extension))
10996 {
10997 Preprocessor preprocessor;
10998 StringVector includePath = Config_getList(INCLUDE_PATH);
10999 for (const auto &s : includePath)
11000 {
11001 std::string absPath = FileInfo(s).absFilePath();
11002 preprocessor.addSearchDir(absPath);
11003 }
11004 std::string inBuf;
11005 msg("Preprocessing {}...\n",fn);
11006 readInputFile(fileName,inBuf);
11007 addTerminalCharIfMissing(inBuf,'\n');
11008 preprocessor.processFile(fileName,inBuf,preBuf);
11009 }
11010 else // no preprocessing
11011 {
11012 msg("Reading {}...\n",fn);
11013 readInputFile(fileName,preBuf);
11014 addTerminalCharIfMissing(preBuf,'\n');
11015 }
11016
11017 std::string convBuf;
11018 convBuf.reserve(preBuf.size()+1024);
11019
11020 // convert multi-line C++ comments to C style comments
11021 convertCppComments(preBuf,convBuf,fileName.str());
11022
11023 std::shared_ptr<Entry> fileRoot = std::make_shared<Entry>();
11024 // use language parse to parse the file
11025 if (clangParser)
11026 {
11027 if (newTU) clangParser->parse();
11028 clangParser->switchToFile(fd);
11029 }
11030 parser.parseInput(fileName,convBuf.data(),fileRoot,clangParser);
11031 fileRoot->setFileDef(fd);
11032 return fileRoot;
11033}
11034
11035//! parse the list of input files
11036static void parseFilesMultiThreading(const std::shared_ptr<Entry> &root)
11037{
11038 AUTO_TRACE();
11039#if USE_LIBCLANG
11041 {
11042 StringUnorderedSet processedFiles;
11043
11044 // create a dictionary with files to process
11045 StringUnorderedSet filesToProcess;
11046 for (const auto &s : g_inputFiles)
11047 {
11048 filesToProcess.insert(s);
11049 }
11050
11051 std::mutex processedFilesLock;
11052 // process source files (and their include dependencies)
11053 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
11054 msg("Processing input using {} threads.\n",numThreads);
11055 ThreadPool threadPool(numThreads);
11056 using FutureType = std::vector< std::shared_ptr<Entry> >;
11057 std::vector< std::future< FutureType > > results;
11058 for (const auto &s : g_inputFiles)
11059 {
11060 bool ambig = false;
11061 DString qs = s;
11063 ASSERT(fd!=nullptr);
11064 if (fd->isSource() && !fd->isReference() && fd->getLanguage()==SrcLangExt::Cpp) // this is a source file
11065 {
11066 // lambda representing the work to executed by a thread
11067 auto processFile = [qs,&filesToProcess,&processedFilesLock,&processedFiles]() {
11068 bool ambig_l = false;
11069 std::vector< std::shared_ptr<Entry> > roots;
11070 FileDef *fd_l = Doxygen::inputNameLinkedMap->findFileDef(qs,ambig_l);
11071 auto clangParser = ClangParser::instance()->createTUParser(fd_l);
11072 auto parser = getParserForFile(qs);
11073 auto fileRoot { parseFile(*parser.get(),fd_l,qs,clangParser.get(),true) };
11074 roots.push_back(fileRoot);
11075
11076 // Now process any include files in the same translation unit
11077 // first. When libclang is used this is much more efficient.
11078 for (auto incFile : clangParser->filesInSameTU())
11079 {
11080 DString qincFile = incFile;
11081 if (filesToProcess.find(incFile)!=filesToProcess.end())
11082 {
11083 bool needsToBeProcessed = false;
11084 {
11085 std::lock_guard<std::mutex> lock(processedFilesLock);
11086 needsToBeProcessed = processedFiles.find(incFile)==processedFiles.end();
11087 if (needsToBeProcessed) processedFiles.insert(incFile);
11088 }
11089 if (qincFile!=qs && needsToBeProcessed)
11090 {
11091 FileDef *ifd=Doxygen::inputNameLinkedMap->findFileDef(qincFile,ambig_l);
11092 if (ifd && !ifd->isReference())
11093 {
11094 //printf(" Processing %s in same translation unit as %s\n",incFile,qPrint(s));
11095 fileRoot = parseFile(*parser.get(),ifd,qincFile,clangParser.get(),false);
11096 roots.push_back(fileRoot);
11097 }
11098 }
11099 }
11100 }
11101 return roots;
11102 };
11103 // dispatch the work and collect the future results
11104 results.emplace_back(threadPool.queue(processFile));
11105 }
11106 }
11107 // synchronize with the Entry result lists produced and add them to the root
11108 for (auto &f : results)
11109 {
11110 auto l = f.get();
11111 for (auto &e : l)
11112 {
11113 root->moveToSubEntryAndKeep(e);
11114 }
11115 }
11116 // process remaining files
11117 results.clear();
11118 for (const auto &s : g_inputFiles)
11119 {
11120 if (processedFiles.find(s)==processedFiles.end()) // not yet processed
11121 {
11122 // lambda representing the work to executed by a thread
11123 auto processFile = [s]() {
11124 bool ambig = false;
11125 DString qs = s;
11126 std::vector< std::shared_ptr<Entry> > roots;
11128 auto parser { getParserForFile(qs) };
11129 bool useClang = getLanguageFromFileName(qs)==SrcLangExt::Cpp;
11130 if (useClang)
11131 {
11132 auto clangParser = ClangParser::instance()->createTUParser(fd);
11133 auto fileRoot = parseFile(*parser.get(),fd,qs,clangParser.get(),true);
11134 roots.push_back(fileRoot);
11135 }
11136 else
11137 {
11138 auto fileRoot = parseFile(*parser.get(),fd,qs,nullptr,true);
11139 roots.push_back(fileRoot);
11140 }
11141 return roots;
11142 };
11143 results.emplace_back(threadPool.queue(processFile));
11144 }
11145 }
11146 // synchronize with the Entry result lists produced and add them to the root
11147 for (auto &f : results)
11148 {
11149 auto l = f.get();
11150 for (auto &e : l)
11151 {
11152 root->moveToSubEntryAndKeep(e);
11153 }
11154 }
11155 }
11156 else // normal processing
11157#endif
11158 {
11159 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
11160 msg("Processing input using {} threads.\n",numThreads);
11161 ThreadPool threadPool(numThreads);
11162 using FutureType = std::shared_ptr<Entry>;
11163 std::vector< std::future< FutureType > > results;
11164 for (const auto &s : g_inputFiles)
11165 {
11166 // lambda representing the work to executed by a thread
11167 auto processFile = [s]() {
11168 bool ambig = false;
11169 DString qs = s;
11171 auto parser = getParserForFile(qs);
11172 auto fileRoot = parseFile(*parser.get(),fd,qs,nullptr,true);
11173 return fileRoot;
11174 };
11175 // dispatch the work and collect the future results
11176 results.emplace_back(threadPool.queue(processFile));
11177 }
11178 // synchronize with the Entry results produced and add them to the root
11179 for (auto &f : results)
11180 {
11181 root->moveToSubEntryAndKeep(f.get());
11182 }
11183 }
11184}
11185
11186//! parse the list of input files
11187static void parseFilesSingleThreading(const std::shared_ptr<Entry> &root)
11188{
11189 AUTO_TRACE();
11190#if USE_LIBCLANG
11192 {
11193 StringUnorderedSet processedFiles;
11194
11195 // create a dictionary with files to process
11196 StringUnorderedSet filesToProcess;
11197 for (const auto &s : g_inputFiles)
11198 {
11199 filesToProcess.insert(s);
11200 }
11201
11202 // process source files (and their include dependencies)
11203 for (const auto &s : g_inputFiles)
11204 {
11205 bool ambig = false;
11206 DString qs =s;
11208 ASSERT(fd!=nullptr);
11209 if (fd->isSource() && !fd->isReference() && getLanguageFromFileName(qs)==SrcLangExt::Cpp) // this is a source file
11210 {
11211 auto clangParser = ClangParser::instance()->createTUParser(fd);
11212 auto parser { getParserForFile(qs) };
11213 auto fileRoot = parseFile(*parser.get(),fd,qs,clangParser.get(),true);
11214 root->moveToSubEntryAndKeep(fileRoot);
11215 processedFiles.insert(s);
11216
11217 // Now process any include files in the same translation unit
11218 // first. When libclang is used this is much more efficient.
11219 for (auto incFile : clangParser->filesInSameTU())
11220 {
11221 //printf(" file %s\n",qPrint(incFile));
11222 if (filesToProcess.find(incFile)!=filesToProcess.end() && // file need to be processed
11223 processedFiles.find(incFile)==processedFiles.end()) // and is not processed already
11224 {
11225 FileDef *ifd=Doxygen::inputNameLinkedMap->findFileDef(incFile,ambig);
11226 if (ifd && !ifd->isReference())
11227 {
11228 //printf(" Processing %s in same translation unit as %s\n",qPrint(incFile),qPrint(qs));
11229 fileRoot = parseFile(*parser.get(),ifd,incFile,clangParser.get(),false);
11230 root->moveToSubEntryAndKeep(fileRoot);
11231 processedFiles.insert(incFile);
11232 }
11233 }
11234 }
11235 }
11236 }
11237 // process remaining files
11238 for (const auto &s : g_inputFiles)
11239 {
11240 if (processedFiles.find(s)==processedFiles.end()) // not yet processed
11241 {
11242 bool ambig = false;
11243 DString qs = s;
11245 if (getLanguageFromFileName(qs)==SrcLangExt::Cpp) // not yet processed
11246 {
11247 auto clangParser = ClangParser::instance()->createTUParser(fd);
11248 auto parser { getParserForFile(qs) };
11249 auto fileRoot = parseFile(*parser.get(),fd,qs,clangParser.get(),true);
11250 root->moveToSubEntryAndKeep(fileRoot);
11251 }
11252 else
11253 {
11254 std::unique_ptr<OutlineParserInterface> parser { getParserForFile(qs) };
11255 std::shared_ptr<Entry> fileRoot = parseFile(*parser.get(),fd,qs,nullptr,true);
11256 root->moveToSubEntryAndKeep(fileRoot);
11257 }
11258 processedFiles.insert(s);
11259 }
11260 }
11261 }
11262 else // normal processing
11263#endif
11264 {
11265 for (const auto &s : g_inputFiles)
11266 {
11267 bool ambig = false;
11268 DString qs = s;
11270 ASSERT(fd!=nullptr);
11271 std::unique_ptr<OutlineParserInterface> parser { getParserForFile(qs) };
11272 std::shared_ptr<Entry> fileRoot = parseFile(*parser.get(),fd,qs,nullptr,true);
11273 root->moveToSubEntryAndKeep(std::move(fileRoot));
11274 }
11275 }
11276}
11277
11278// resolves a path that may include symlinks, if a recursive symlink is
11279// found an empty string is returned.
11280static std::string resolveSymlink(const std::string &path)
11281{
11282 size_t sepPos=0;
11283 size_t oldPos=0;
11284 StringUnorderedSet nonSymlinks;
11285 StringUnorderedSet known;
11286 DString result(path);
11287 DString oldPrefix = "/";
11288 do
11289 {
11290#if defined(_WIN32)
11291 // UNC path, skip server and share name
11292 if (sepPos==0 && (result.startsWith("//") || result.startsWith("\\\\")))
11293 sepPos = result.find('/',2);
11294 if (sepPos!=DString::npos)
11295 sepPos = result.find('/',sepPos+1);
11296#else
11297 sepPos = result.find('/',sepPos+1);
11298#endif
11299 DString prefix = sepPos==DString::npos ? result : result.left(sepPos);
11300 if (nonSymlinks.find(prefix.str())==nonSymlinks.end())
11301 {
11302 FileInfo fi(prefix.str());
11303 if (fi.isSymLink())
11304 {
11305 DString target = fi.readLink();
11306 bool isRelative = FileInfo(target.str()).isRelative();
11307 if (isRelative)
11308 {
11309 target = Dir::cleanDirPath(oldPrefix.str()+"/"+target.str());
11310 }
11311 if (sepPos!=DString::npos)
11312 {
11313 if (fi.isDir() && !target.empty() && target.at(target.length()-1)!='/')
11314 {
11315 target+='/';
11316 }
11317 target+=result.mid(sepPos);
11318 }
11319 result = Dir::cleanDirPath(target.str());
11320 if (known.find(result.str())!=known.end()) return std::string(); // recursive symlink!
11321 known.insert(result.str());
11322 if (isRelative)
11323 {
11324 sepPos = oldPos;
11325 }
11326 else // link to absolute path
11327 {
11328 sepPos = 0;
11329 oldPrefix = "/";
11330 }
11331 }
11332 else
11333 {
11334 nonSymlinks.insert(prefix.str());
11335 oldPrefix = prefix;
11336 }
11337 oldPos = sepPos;
11338 }
11339 }
11340 while (sepPos!=DString::npos);
11341 return Dir::cleanDirPath(result.str());
11342}
11343
11345
11346//----------------------------------------------------------------------------
11347// Read all files matching at least one pattern in 'patList' in the
11348// directory represented by 'fi'.
11349// The directory is read iff the recursiveFlag is set.
11350// The contents of all files is append to the input string
11351
11352static void readDir(FileInfo *fi,
11353 FileNameLinkedMap *fnMap,
11354 StringUnorderedSet *exclSet,
11355 const StringVector *patList,
11356 const StringVector *exclPatList,
11357 StringVector *resultList,
11358 StringUnorderedSet *resultSet,
11359 bool errorIfNotExist,
11360 bool recursive,
11361 StringUnorderedSet *killSet,
11362 StringUnorderedSet *paths
11363 )
11364{
11365 std::string dirName = fi->absFilePath();
11366 if (paths && !dirName.empty())
11367 {
11368 paths->insert(dirName);
11369 }
11370 //printf("%s isSymLink()=%d\n",qPrint(dirName),fi->isSymLink());
11371 if (fi->isSymLink())
11372 {
11373 dirName = resolveSymlink(dirName);
11374 if (dirName.empty())
11375 {
11376 //printf("RECURSIVE SYMLINK: %s\n",qPrint(dirName));
11377 return; // recursive symlink
11378 }
11379 }
11380
11381 if (g_pathsVisited.find(dirName)!=g_pathsVisited.end())
11382 {
11383 //printf("PATH ALREADY VISITED: %s\n",qPrint(dirName));
11384 return; // already visited path
11385 }
11386 g_pathsVisited.insert(dirName);
11387
11388 Dir dir(dirName);
11389 msg("Searching for files in directory {}\n", fi->absFilePath());
11390 //printf("killSet=%p count=%d\n",killSet,killSet ? (int)killSet->count() : -1);
11391
11392 StringVector dirResultList;
11393
11394 bool caseSenseNames = useCaseSenseNames();
11395
11396 // Process the entries in a fixed order, so that the order in which FileDefs
11397 // are created (which e.g. determines the SHORT_NAMES numbering) and in which
11398 // subdirectories are visited does not depend on the file system.
11399 StringVector entries;
11400 for (const auto &dirEntry : dir.iterator())
11401 {
11402 entries.push_back(dirEntry.path());
11403 }
11404 std::sort(entries.begin(),entries.end());
11405
11406 for (const auto &entryPath : entries)
11407 {
11408 FileInfo cfi(entryPath);
11409 auto checkPatterns = [&]() -> bool
11410 {
11411 return (patList==nullptr || cfi.match(*patList,caseSenseNames)) &&
11412 (exclPatList==nullptr || !cfi.match(*exclPatList,caseSenseNames)) &&
11413 (killSet==nullptr || killSet->find(cfi.absFilePath())==killSet->end());
11414 };
11415
11416 if (exclSet==nullptr || exclSet->find(cfi.absFilePath())==exclSet->end())
11417 { // file should not be excluded
11418 //printf("killSet->find(%s)\n",qPrint(cfi->absFilePath()));
11419 if (Config_getBool(EXCLUDE_SYMLINKS) && cfi.isSymLink())
11420 {
11421 }
11422 else if (!cfi.exists() || !cfi.isReadable())
11423 {
11424 if (errorIfNotExist && checkPatterns())
11425 {
11426 warn_uncond("source '{}' is not a readable file or directory... skipping.\n",cfi.absFilePath());
11427 }
11428 }
11429 else if (cfi.isFile() && checkPatterns())
11430 {
11431 std::string name=cfi.fileName();
11432 std::string path=cfi.dirPath()+"/";
11433 std::string fullName=path+name;
11434 if (fnMap)
11435 {
11436 auto fd = createFileDef(path,name);
11437 FileName *fn=nullptr;
11438 if (!name.empty())
11439 {
11440 fn = fnMap->add(name);
11441 fn->push_back(std::move(fd));
11442 }
11443 }
11444 dirResultList.push_back(fullName);
11445 if (resultSet) resultSet->insert(fullName);
11446 if (killSet) killSet->insert(fullName);
11447 }
11448 else if (recursive &&
11449 cfi.isDir() &&
11450 (exclPatList==nullptr || !cfi.match(*exclPatList,caseSenseNames)) &&
11451 cfi.fileName().at(0)!='.') // skip "." ".." and ".dir"
11452 {
11453 FileInfo acfi(cfi.absFilePath());
11454 readDir(&acfi,fnMap,exclSet,
11455 patList,exclPatList,&dirResultList,resultSet,errorIfNotExist,
11456 recursive,killSet,paths);
11457 }
11458 }
11459 }
11460 if (resultList && !dirResultList.empty())
11461 {
11462 // sort the resulting list to make the order platform independent.
11463 std::stable_sort(dirResultList.begin(),
11464 dirResultList.end(),
11465 [](const auto &f1,const auto &f2) { return dstricmp_sort(f1.c_str(),f2.c_str())<0; });
11466
11467 // append the sorted results to resultList
11468 resultList->insert(resultList->end(), dirResultList.begin(), dirResultList.end());
11469 }
11470}
11471
11472
11473//----------------------------------------------------------------------------
11474// read a file or all files in a directory and append their contents to the
11475// input string. The names of the files are appended to the 'fiList' list.
11476
11478 FileNameLinkedMap *fnMap,
11479 StringUnorderedSet *exclSet,
11480 const StringVector *patList,
11481 const StringVector *exclPatList,
11482 StringVector *resultList,
11483 StringUnorderedSet *resultSet,
11484 bool recursive,
11485 bool errorIfNotExist,
11486 StringUnorderedSet *killSet,
11487 StringUnorderedSet *paths
11488 )
11489{
11490 //printf("killSet count=%d\n",killSet ? (int)killSet->size() : -1);
11491 // strip trailing slashes
11492 if (s.empty()) return;
11493
11494 g_pathsVisited.clear();
11495
11496 FileInfo fi(s.str());
11497 //printf("readFileOrDirectory(%s)\n",s);
11498 {
11499 if (exclSet==nullptr || exclSet->find(fi.absFilePath())==exclSet->end())
11500 {
11501 if (Config_getBool(EXCLUDE_SYMLINKS) && fi.isSymLink())
11502 {
11503 }
11504 else if (!fi.exists() || !fi.isReadable())
11505 {
11506 if (errorIfNotExist)
11507 {
11508 warn_uncond("source '{}' is not a readable file or directory... skipping.\n",s);
11509 }
11510 }
11511 else if (fi.isFile())
11512 {
11513 std::string dirPath = fi.dirPath(true);
11514 std::string filePath = fi.absFilePath();
11515 if (paths && !dirPath.empty())
11516 {
11517 paths->insert(dirPath);
11518 }
11519 //printf("killSet.find(%s)=%d\n",qPrint(fi.absFilePath()),killSet.find(fi.absFilePath())!=killSet.end());
11520 if (killSet==nullptr || killSet->find(filePath)==killSet->end())
11521 {
11522 std::string name=fi.fileName();
11523 if (fnMap)
11524 {
11525 auto fd = createFileDef(dirPath+"/",name);
11526 if (!name.empty())
11527 {
11528 FileName *fn = fnMap->add(name);
11529 fn->push_back(std::move(fd));
11530 }
11531 }
11532 if (resultList || resultSet)
11533 {
11534 if (resultList) resultList->push_back(filePath);
11535 if (resultSet) resultSet->insert(filePath);
11536 }
11537
11538 if (killSet) killSet->insert(fi.absFilePath());
11539 }
11540 }
11541 else if (fi.isDir()) // readable dir
11542 {
11543 readDir(&fi,fnMap,exclSet,patList,
11544 exclPatList,resultList,resultSet,errorIfNotExist,
11545 recursive,killSet,paths);
11546 }
11547 }
11548 }
11549}
11550
11551//----------------------------------------------------------------------------
11552
11554{
11555 DString anchor;
11557 {
11558 MemberDef *md = toMemberDef(d);
11559 anchor=":"+md->anchor();
11560 }
11561 DString scope;
11562 DString fn = d->getOutputFileBase();
11565 {
11566 scope = fn;
11567 }
11568 t << "REPLACE INTO symbols (symbol_id,scope_id,name,file,line) VALUES('"
11569 << fn+anchor << "','"
11570 << scope << "','"
11571 << d->name() << "','"
11572 << d->getDefFileName() << "','"
11573 << d->getDefLine()
11574 << "');\n";
11575}
11576
11577static void dumpSymbolMap()
11578{
11579 std::ofstream f = Portable::openOutputStream("symbols.sql");
11580 if (f.is_open())
11581 {
11582 TextStream t(&f);
11583 for (const auto &[name,symList] : *Doxygen::symbolMap)
11584 {
11585 for (const auto &def : symList)
11586 {
11587 dumpSymbol(t,def);
11588 }
11589 }
11590 }
11591}
11592
11593// print developer options of Doxygen
11594static void devUsage()
11595{
11597 msg("Developer parameters:\n");
11598 msg(" -m dump symbol map\n");
11599 msg(" -b making messages output unbuffered\n");
11600 msg(" -c <file> process input file as a comment block and produce HTML output\n");
11601#if ENABLE_TRACING
11602 msg(" -t [<file|stdout|stderr>] trace debug info to file, stdout, or stderr (default file stdout)\n");
11603 msg(" -t_time [<file|stdout|stderr>] trace debug info to file, stdout, or stderr (default file stdout),\n"
11604 " and include time and thread information\n");
11605#endif
11606 msg(" -d <level> enable a debug level, such as (multiple invocations of -d are possible):\n");
11608}
11609
11610
11611//----------------------------------------------------------------------------
11612// print the version of Doxygen
11613
11614static void version(const bool extended)
11615{
11617 DString versionString = getFullVersion();
11618 msg("{}\n",versionString);
11619 if (extended)
11620 {
11621 DString extVers;
11622 if (!extVers.empty()) extVers+= ", ";
11623 extVers += "sqlite3 ";
11624 extVers += sqlite3_libversion();
11625#if USE_LIBCLANG
11626 if (!extVers.empty()) extVers+= ", ";
11627 extVers += "clang support ";
11628 extVers += CLANG_VERSION_STRING;
11629#endif
11630 if (!extVers.empty())
11631 {
11632 if (size_t lastComma = extVers.rfind(','); lastComma != DString::npos)
11633 {
11634 extVers = extVers.replace(lastComma,1," and");
11635 }
11636 msg(" with {}.\n",extVers);
11637 }
11638 }
11639}
11640
11641//----------------------------------------------------------------------------
11642// print the usage of Doxygen
11643
11644static void usage(const DString &name,const DString &versionString)
11645{
11647 msg("Doxygen version {0}\nCopyright Dimitri van Heesch 1997-2025\n\n"
11648 "You can use Doxygen in a number of ways:\n\n"
11649 "1) Use Doxygen to generate a template configuration file*:\n"
11650 " {1} [-s] -g [configName]\n\n"
11651 "2) Use Doxygen to update an old configuration file*:\n"
11652 " {1} [-s] -u [configName]\n\n"
11653 "3) Use Doxygen to generate documentation using an existing "
11654 "configuration file*:\n"
11655 " {1} [configName]\n\n"
11656 "4) Use Doxygen to generate a template file controlling the layout of the\n"
11657 " generated documentation:\n"
11658 " {1} -l [layoutFileName]\n\n"
11659 " In case layoutFileName is omitted DoxygenLayout.xml will be used as filename.\n"
11660 " If - is used for layoutFileName Doxygen will write to standard output.\n\n"
11661 "5) Use Doxygen to generate a template style sheet file for RTF, HTML or Latex.\n"
11662 " RTF: {1} -w rtf styleSheetFile\n"
11663 " HTML: {1} -w html headerFile footerFile styleSheetFile [configFile]\n"
11664 " LaTeX: {1} -w latex headerFile footerFile styleSheetFile [configFile]\n\n"
11665 "6) Use Doxygen to generate a rtf extensions file\n"
11666 " {1} -e rtf extensionsFile\n\n"
11667 " If - is used for extensionsFile Doxygen will write to standard output.\n\n"
11668 "7) Use Doxygen to compare the used configuration file with the template configuration file\n"
11669 " {1} -x [configFile]\n\n"
11670 " Use Doxygen to compare the used configuration file with the template configuration file\n"
11671 " without replacing the environment variables or CMake type replacement variables\n"
11672 " {1} -x_noenv [configFile]\n\n"
11673 "8) Use Doxygen to show a list of built-in emojis.\n"
11674 " {1} -f emoji outputFileName\n\n"
11675 " If - is used for outputFileName Doxygen will write to standard output.\n\n"
11676 "*) If -s is specified the comments of the configuration items in the config file will be omitted.\n"
11677 " If configName is omitted 'Doxyfile' will be used as a default.\n"
11678 " If - is used for configFile Doxygen will write / read the configuration to /from standard output / input.\n\n"
11679 "If -q is used for a Doxygen documentation run, Doxygen will see this as if QUIET=YES has been set.\n\n"
11680 "-v print version string, -V print extended version information\n"
11681 "-h,-? prints usage help information\n"
11682 "{1} -d prints additional usage flags for debugging purposes\n",versionString,name);
11683}
11684
11685//----------------------------------------------------------------------------
11686// read the argument of option 'c' from the comment argument list and
11687// update the option index 'optInd'.
11688
11689static const char *getArg(int argc,char **argv,int &optInd)
11690{
11691 char *s=nullptr;
11692 if (dstrlen(&argv[optInd][2])>0)
11693 s=&argv[optInd][2];
11694 else if (optInd+1<argc && argv[optInd+1][0]!='-')
11695 s=argv[++optInd];
11696 return s;
11697}
11698
11699//----------------------------------------------------------------------------
11700
11701/** @brief /dev/null outline parser */
11703{
11704 public:
11705 void parseInput(const DString &/* file */, const char * /* buf */,const std::shared_ptr<Entry> &, ClangTUParser*) override {}
11706 bool needsPreprocessing(const DString &) const override { return false; }
11707 void parsePrototype(const DString &) override {}
11708};
11709
11710
11711template<class T> std::function< std::unique_ptr<T>() > make_parser_factory()
11712{
11713 return []() { return std::make_unique<T>(); };
11714}
11715
11717{
11718 initResources();
11719 DString lang = Portable::getenv("LC_ALL");
11720 if (!lang.empty()) Portable::setenv("LANG",lang);
11721 std::setlocale(LC_ALL,"");
11722 std::setlocale(LC_CTYPE,"C"); // to get isspace(0xA0)==0, needed for UTF-8
11723 std::setlocale(LC_NUMERIC,"C");
11724
11726
11750
11751 // register any additional parsers here...
11752
11754
11755#if USE_LIBCLANG
11757#endif
11766 Doxygen::pageLinkedMap = new PageLinkedMap; // all doc pages
11767 Doxygen::exampleLinkedMap = new PageLinkedMap; // all examples
11768 //Doxygen::tagDestinationDict.setAutoDelete(true);
11770
11771 // initialization of these globals depends on
11772 // configuration switches so we need to postpone these
11773 Doxygen::globalScope = nullptr;
11783
11784}
11785
11818
11819void readConfiguration(int argc, char **argv)
11820{
11821 DString versionString = getFullVersion();
11822
11823 // helper that calls \a func to write to file \a fileName via a TextStream
11824 auto writeFile = [](const char *fileName,std::function<void(TextStream&)> func) -> bool
11825 {
11826 std::ofstream f;
11827 if (openOutputFile(fileName,f))
11828 {
11829 TextStream t(&f);
11830 func(t);
11831 return true;
11832 }
11833 return false;
11834 };
11835
11836
11837 /**************************************************************************
11838 * Handle arguments *
11839 **************************************************************************/
11840
11841 int optInd=1;
11842 DString configName;
11843 DString traceName;
11844 bool genConfig=false;
11845 bool shortList=false;
11846 bool traceTiming=false;
11848 bool updateConfig=false;
11849 bool quiet = false;
11850 while (optInd<argc && argv[optInd][0]=='-' &&
11851 (isalpha(argv[optInd][1]) || argv[optInd][1]=='?' ||
11852 argv[optInd][1]=='-')
11853 )
11854 {
11855 switch(argv[optInd][1])
11856 {
11857 case 'g':
11858 {
11859 genConfig=true;
11860 }
11861 break;
11862 case 'l':
11863 {
11864 DString layoutName;
11865 if (optInd+1>=argc)
11866 {
11867 layoutName="DoxygenLayout.xml";
11868 }
11869 else
11870 {
11871 layoutName=argv[optInd+1];
11872 }
11873 writeDefaultLayoutFile(layoutName);
11875 exit(0);
11876 }
11877 break;
11878 case 'c':
11879 if (optInd+1>=argc) // no file name given
11880 {
11881 msg("option \"-c\" is missing the file name to read\n");
11882 devUsage();
11884 exit(1);
11885 }
11886 else
11887 {
11888 g_commentFileName=argv[optInd+1];
11889 optInd++;
11890 }
11891 g_singleComment=true;
11892 quiet=true;
11893 break;
11894 case 'd':
11895 {
11896 DString debugLabel=getArg(argc,argv,optInd);
11897 if (debugLabel.empty())
11898 {
11899 devUsage();
11901 exit(0);
11902 }
11903 int retVal = Debug::setFlagStr(debugLabel);
11904 if (!retVal)
11905 {
11906 msg("option \"-d\" has unknown debug specifier: \"{}\".\n",debugLabel);
11907 devUsage();
11909 exit(1);
11910 }
11911 }
11912 break;
11913 case 't':
11914 {
11915#if ENABLE_TRACING
11916 if (!strcmp(argv[optInd]+1,"t_time"))
11917 {
11918 traceTiming = true;
11919 }
11920 else if (!strcmp(argv[optInd]+1,"t"))
11921 {
11922 traceTiming = false;
11923 }
11924 else
11925 {
11926 err("option should be \"-t\" or \"-t_time\", found: \"{}\".\n",argv[optInd]);
11928 exit(1);
11929 }
11930 if (optInd+1>=argc || argv[optInd+1][0] == '-') // no file name given
11931 {
11932 traceName="stdout";
11933 }
11934 else
11935 {
11936 traceName=argv[optInd+1];
11937 optInd++;
11938 }
11939#else
11940 err("support for option \"-t\" has not been compiled in (use a debug build or a release build with tracing enabled).\n");
11942 exit(1);
11943#endif
11944 }
11945 break;
11946 case 'x':
11947 if (!strcmp(argv[optInd]+1,"x_noenv")) diffList=Config::CompareMode::CompressedNoEnv;
11948 else if (!strcmp(argv[optInd]+1,"x")) diffList=Config::CompareMode::Compressed;
11949 else
11950 {
11951 err("option should be \"-x\" or \"-x_noenv\", found: \"{}\".\n",argv[optInd]);
11953 exit(1);
11954 }
11955 break;
11956 case 's':
11957 shortList=true;
11958 break;
11959 case 'u':
11960 updateConfig=true;
11961 break;
11962 case 'e':
11963 {
11964 DString formatName=getArg(argc,argv,optInd);
11965 if (formatName.empty())
11966 {
11967 err("option \"-e\" is missing format specifier rtf.\n");
11969 exit(1);
11970 }
11971 if (dstricmp(formatName.data(),"rtf")==0)
11972 {
11973 if (optInd+1>=argc)
11974 {
11975 err("option \"-e rtf\" is missing an extensions file name\n");
11977 exit(1);
11978 }
11979 writeFile(argv[optInd+1],RTFGenerator::writeExtensionsFile);
11981 exit(0);
11982 }
11983 err("option \"-e\" has invalid format specifier.\n");
11985 exit(1);
11986 }
11987 break;
11988 case 'f':
11989 {
11990 DString listName=getArg(argc,argv,optInd);
11991 if (listName.empty())
11992 {
11993 err("option \"-f\" is missing list specifier.\n");
11995 exit(1);
11996 }
11997 if (dstricmp(listName.data(),"emoji")==0)
11998 {
11999 if (optInd+1>=argc)
12000 {
12001 err("option \"-f emoji\" is missing an output file name\n");
12003 exit(1);
12004 }
12005 writeFile(argv[optInd+1],[](TextStream &t) { EmojiEntityMapper::instance().writeEmojiFile(t); });
12007 exit(0);
12008 }
12009 err("option \"-f\" has invalid list specifier.\n");
12011 exit(1);
12012 }
12013 break;
12014 case 'w':
12015 {
12016 DString formatName=getArg(argc,argv,optInd);
12017 if (formatName.empty())
12018 {
12019 err("option \"-w\" is missing format specifier rtf, html or latex\n");
12021 exit(1);
12022 }
12023 if (dstricmp(formatName.data(),"rtf")==0)
12024 {
12025 if (optInd+1>=argc)
12026 {
12027 err("option \"-w rtf\" is missing a style sheet file name\n");
12029 exit(1);
12030 }
12031 if (!writeFile(argv[optInd+1],RTFGenerator::writeStyleSheetFile))
12032 {
12033 err("error opening RTF style sheet file {}!\n",argv[optInd+1]);
12035 exit(1);
12036 }
12038 exit(0);
12039 }
12040 else if (dstricmp(formatName.data(),"html")==0)
12041 {
12042 Config::init();
12043 if (optInd+4<argc || FileInfo("Doxyfile").exists() || FileInfo("doxyfile").exists())
12044 // explicit config file mentioned or default found on disk
12045 {
12046 DString df = optInd+4<argc ? argv[optInd+4] : (FileInfo("Doxyfile").exists() ? DString("Doxyfile") : DString("doxyfile"));
12047 if (!Config::parse(df)) // parse the config file
12048 {
12049 err("error opening or reading configuration file {}!\n",argv[optInd+4]);
12051 exit(1);
12052 }
12053 }
12054 if (optInd+3>=argc)
12055 {
12056 err("option \"-w html\" does not have enough arguments\n");
12058 exit(1);
12059 }
12060 Config::postProcess(true);
12063 setTranslator(Config_getEnum(OUTPUT_LANGUAGE));
12064 writeFile(argv[optInd+1],[&](TextStream &t) { HtmlGenerator::writeHeaderFile(t,argv[optInd+3]); });
12065 writeFile(argv[optInd+2],HtmlGenerator::writeFooterFile);
12066 writeFile(argv[optInd+3],HtmlGenerator::writeStyleSheetFile);
12068 exit(0);
12069 }
12070 else if (dstricmp(formatName.data(),"latex")==0)
12071 {
12072 Config::init();
12073 if (optInd+4<argc || FileInfo("Doxyfile").exists() || FileInfo("doxyfile").exists())
12074 {
12075 DString df = optInd+4<argc ? argv[optInd+4] : (FileInfo("Doxyfile").exists() ? DString("Doxyfile") : DString("doxyfile"));
12076 if (!Config::parse(df))
12077 {
12078 err("error opening or reading configuration file {}!\n",argv[optInd+4]);
12080 exit(1);
12081 }
12082 }
12083 if (optInd+3>=argc)
12084 {
12085 err("option \"-w latex\" does not have enough arguments\n");
12087 exit(1);
12088 }
12089 Config::postProcess(true);
12092 setTranslator(Config_getEnum(OUTPUT_LANGUAGE));
12093 writeFile(argv[optInd+1],LatexGenerator::writeHeaderFile);
12094 writeFile(argv[optInd+2],LatexGenerator::writeFooterFile);
12095 writeFile(argv[optInd+3],LatexGenerator::writeStyleSheetFile);
12097 exit(0);
12098 }
12099 else
12100 {
12101 err("Illegal format specifier \"{}\": should be one of rtf, html or latex\n",formatName);
12103 exit(1);
12104 }
12105 }
12106 break;
12107 case 'm':
12108 g_dumpSymbolMap = true;
12109 break;
12110 case 'v':
12111 version(false);
12113 exit(0);
12114 break;
12115 case 'V':
12116 version(true);
12118 exit(0);
12119 break;
12120 case '-':
12121 if (dstrcmp(&argv[optInd][2],"help")==0)
12122 {
12123 usage(argv[0],versionString);
12124 exit(0);
12125 }
12126 else if (dstrcmp(&argv[optInd][2],"version")==0)
12127 {
12128 version(false);
12130 exit(0);
12131 }
12132 else if ((dstrcmp(&argv[optInd][2],"Version")==0) ||
12133 (dstrcmp(&argv[optInd][2],"VERSION")==0))
12134 {
12135 version(true);
12137 exit(0);
12138 }
12139 else
12140 {
12141 err("Unknown option \"-{}\"\n",&argv[optInd][1]);
12142 usage(argv[0],versionString);
12143 exit(1);
12144 }
12145 break;
12146 case 'b':
12147 setvbuf(stdout,nullptr,_IONBF,0);
12148 break;
12149 case 'q':
12150 quiet = true;
12151 break;
12152 case 'h':
12153 case '?':
12154 usage(argv[0],versionString);
12155 exit(0);
12156 break;
12157 default:
12158 err("Unknown option \"-{:c}\"\n",argv[optInd][1]);
12159 usage(argv[0],versionString);
12160 exit(1);
12161 }
12162 optInd++;
12163 }
12164
12165 /**************************************************************************
12166 * Parse or generate the config file *
12167 **************************************************************************/
12168
12169 initTracing(traceName.data(),traceTiming);
12170 TRACE("Doxygen version used: {}",getFullVersion());
12171 Config::init();
12172
12173 FileInfo configFileInfo1("Doxyfile"),configFileInfo2("doxyfile");
12174 if (optInd>=argc)
12175 {
12176 if (configFileInfo1.exists())
12177 {
12178 configName="Doxyfile";
12179 }
12180 else if (configFileInfo2.exists())
12181 {
12182 configName="doxyfile";
12183 }
12184 else if (genConfig)
12185 {
12186 configName="Doxyfile";
12187 }
12188 else
12189 {
12190 err("Doxyfile not found and no input file specified!\n");
12191 usage(argv[0],versionString);
12192 exit(1);
12193 }
12194 }
12195 else
12196 {
12197 FileInfo fi(argv[optInd]);
12198 if (fi.exists() || dstrcmp(argv[optInd],"-")==0 || genConfig)
12199 {
12200 configName=argv[optInd];
12201 }
12202 else
12203 {
12204 err("configuration file {} not found!\n",argv[optInd]);
12205 usage(argv[0],versionString);
12206 exit(1);
12207 }
12208 }
12209
12210 if (genConfig)
12211 {
12212 generateConfigFile(configName,shortList);
12214 exit(0);
12215 }
12216
12217 if (!Config::parse(configName,updateConfig,diffList))
12218 {
12219 err("could not open or read configuration file {}!\n",configName);
12221 exit(1);
12222 }
12223
12224 if (diffList!=Config::CompareMode::Full)
12225 {
12227 compareDoxyfile(diffList);
12229 exit(0);
12230 }
12231
12232 if (updateConfig)
12233 {
12235 generateConfigFile(configName,shortList,true);
12237 exit(0);
12238 }
12239
12240 /* Perlmod wants to know the path to the config file.*/
12241 FileInfo configFileInfo(configName.str());
12242 setPerlModDoxyfile(configFileInfo.absFilePath());
12243
12244 /* handle -q option */
12245 if (quiet) Config_updateBool(QUIET,true);
12246}
12247
12248/** check and resolve config options */
12250{
12251 AUTO_TRACE();
12252
12253 Config::postProcess(false);
12257}
12258
12259/** adjust globals that depend on configuration settings. */
12261{
12262 AUTO_TRACE();
12263 Doxygen::globalNamespaceDef = createNamespaceDef("<globalScope>",1,1,"<globalScope>");
12274
12275 setTranslator(Config_getEnum(OUTPUT_LANGUAGE));
12276
12277 /* Set the global html file extension. */
12278 Doxygen::htmlFileExtension = Config_getString(HTML_FILE_EXTENSION);
12279
12280
12282 Config_getBool(CALLER_GRAPH) ||
12283 Config_getBool(REFERENCES_RELATION) ||
12284 Config_getBool(REFERENCED_BY_RELATION);
12285
12286 /**************************************************************************
12287 * Add custom extension mappings
12288 **************************************************************************/
12289
12290 StringVector extMaps = Config_getList(EXTENSION_MAPPING);
12291 for (const auto &mapping : extMaps)
12292 {
12293 DString mapStr = mapping;
12294 if (size_t i=mapStr.find('='); i==DString::npos)
12295 {
12296 continue;
12297 }
12298 else
12299 {
12300 DString ext = mapStr.left(i).stripWhiteSpace().lower();
12301 DString language = mapStr.mid(i+1).stripWhiteSpace().lower();
12302 if (ext.empty() || language.empty())
12303 {
12304 continue;
12305 }
12306
12307 if (!updateLanguageMapping(ext,language))
12308 {
12309 err("Failed to map file extension '{}' to unsupported language '{}'.\n"
12310 "Check the EXTENSION_MAPPING setting in the config file.\n",
12311 ext,language);
12312 }
12313 else
12314 {
12315 msg("Adding custom extension mapping: '{}' will be treated as language '{}'\n",
12316 ext,language);
12317 }
12318 }
12319 }
12320 // create input file exncodings
12321
12322 // check INPUT_ENCODING
12323 void *cd = portable_iconv_open("UTF-8",Config_getString(INPUT_ENCODING).data());
12324 if (cd==reinterpret_cast<void *>(-1))
12325 {
12326 term("unsupported character conversion: '{}'->'UTF-8': {}\n"
12327 "Check the 'INPUT_ENCODING' setting in the config file!\n",
12328 Config_getString(INPUT_ENCODING),strerror(errno));
12329 }
12330 else
12331 {
12333 }
12334
12335 // check and split INPUT_FILE_ENCODING
12336 StringVector fileEncod = Config_getList(INPUT_FILE_ENCODING);
12337 for (const auto &mapping : fileEncod)
12338 {
12339 DString mapStr = mapping;
12340 if (size_t i=mapStr.find('='); i==DString::npos)
12341 {
12342 continue;
12343 }
12344 else
12345 {
12346 DString pattern = mapStr.left(i).stripWhiteSpace().lower();
12347 DString encoding = mapStr.mid(i+1).stripWhiteSpace().lower();
12348 if (pattern.empty() || encoding.empty())
12349 {
12350 continue;
12351 }
12352 cd = portable_iconv_open("UTF-8",encoding.data());
12353 if (cd==reinterpret_cast<void *>(-1))
12354 {
12355 term("unsupported character conversion: '{}'->'UTF-8': {}\n"
12356 "Check the 'INPUT_FILE_ENCODING' setting in the config file!\n",
12357 encoding,strerror(errno));
12358 }
12359 else
12360 {
12362 }
12363
12364 Doxygen::inputFileEncodingList.emplace_back(pattern, encoding);
12365 }
12366 }
12367
12368 // add predefined macro name to a dictionary
12369 StringVector expandAsDefinedList = Config_getList(EXPAND_AS_DEFINED);
12370 for (const auto &s : expandAsDefinedList)
12371 {
12373 }
12374
12375 // read aliases and store them in a dictionary
12376 readAliases();
12377
12378 // store number of spaces in a tab into Doxygen::spaces
12379 int tabSize = Config_getInt(TAB_SIZE);
12380 Doxygen::spaces.resize(tabSize);
12381 for (int sp=0; sp<tabSize; sp++) Doxygen::spaces.at(sp)=' ';
12382 Doxygen::spaces.at(tabSize)='\0';
12383}
12384
12385#ifdef HAS_SIGNALS
12386static void stopDoxygen(int)
12387{
12388 signal(SIGINT,SIG_DFL); // Re-register signal handler for default action
12389 Dir thisDir;
12390 msg("Cleaning up...\n");
12391 if (!Doxygen::filterDBFileName.empty())
12392 {
12393 thisDir.remove(Doxygen::filterDBFileName.str());
12394 }
12395 killpg(0,SIGINT);
12397 exitTracing();
12398 exit(1);
12399}
12400#endif
12401
12402static void writeTagFile()
12403{
12404 DString generateTagFile = Config_getString(GENERATE_TAGFILE);
12405 if (generateTagFile.empty()) return;
12406
12407 std::ofstream f = Portable::openOutputStream(generateTagFile);
12408 if (!f.is_open())
12409 {
12410 err("cannot open tag file {} for writing\n", generateTagFile);
12411 return;
12412 }
12413 TextStream tagFile(&f);
12414 tagFile << "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\n";
12415 tagFile << "<tagfile doxygen_version=\"" << getDoxygenVersion() << "\"";
12416 std::string gitVersion = getGitVersion();
12417 if (!gitVersion.empty())
12418 {
12419 tagFile << " doxygen_gitid=\"" << gitVersion << "\"";
12420 }
12421 tagFile << ">\n";
12422
12423 // for each file
12424 for (const auto &fn : *Doxygen::inputNameLinkedMap)
12425 {
12426 for (const auto &fd : *fn)
12427 {
12428 if (fd->isLinkableInProject()) fd->writeTagFile(tagFile);
12429 }
12430 }
12431 // for each class
12432 for (const auto &cd : *Doxygen::classLinkedMap)
12433 {
12434 ClassDefMutable *cdm = toClassDefMutable(cd.get());
12435 if (cdm && cdm->isLinkableInProject())
12436 {
12437 cdm->writeTagFile(tagFile);
12438 }
12439 }
12440 // for each concept
12441 for (const auto &cd : *Doxygen::conceptLinkedMap)
12442 {
12443 ConceptDefMutable *cdm = toConceptDefMutable(cd.get());
12444 if (cdm && cdm->isLinkableInProject())
12445 {
12446 cdm->writeTagFile(tagFile);
12447 }
12448 }
12449 // for each namespace
12450 for (const auto &nd : *Doxygen::namespaceLinkedMap)
12451 {
12453 if (ndm && nd->isLinkableInProject())
12454 {
12455 ndm->writeTagFile(tagFile);
12456 }
12457 }
12458 // for each group
12459 for (const auto &gd : *Doxygen::groupLinkedMap)
12460 {
12461 if (gd->isLinkableInProject()) gd->writeTagFile(tagFile);
12462 }
12463 // for each module
12464 for (const auto &mod : ModuleManager::instance().modules())
12465 {
12466 if (mod->isLinkableInProject()) mod->writeTagFile(tagFile);
12467 }
12468 // for each page
12469 for (const auto &pd : *Doxygen::pageLinkedMap)
12470 {
12471 if (pd->isLinkableInProject()) pd->writeTagFile(tagFile);
12472 }
12473 // for requirements
12475 // for each directory
12476 for (const auto &dd : *Doxygen::dirLinkedMap)
12477 {
12478 if (dd->isLinkableInProject()) dd->writeTagFile(tagFile);
12479 }
12480 if (Doxygen::mainPage) Doxygen::mainPage->writeTagFile(tagFile);
12481
12482 tagFile << "</tagfile>\n";
12483}
12484
12485static void exitDoxygen() noexcept
12486{
12487 if (!g_successfulRun) // premature exit
12488 {
12489 Dir thisDir;
12490 msg("Exiting...\n");
12491 if (!Doxygen::filterDBFileName.empty())
12492 {
12493 thisDir.remove(Doxygen::filterDBFileName.str());
12494 }
12495 }
12496}
12497
12498static DString createOutputDirectory(const DString &baseDirName,
12499 const DString &formatDirName,
12500 const char *defaultDirName)
12501{
12502 DString result = formatDirName;
12503 if (result.empty())
12504 {
12505 result = baseDirName + defaultDirName;
12506 }
12507 else if (formatDirName[0]!='/' && (formatDirName.length()==1 || formatDirName[1]!=':'))
12508 {
12509 result.prepend(baseDirName+"/");
12510 }
12511 Dir formatDir(result.str());
12512 if (!formatDir.exists() && !formatDir.mkdir(result.str()))
12513 {
12514 term("Could not create output directory {}\n", result);
12515 }
12516 return result;
12517}
12518
12520{
12521 StringUnorderedSet killSet;
12522
12523 StringVector exclPatterns = Config_getList(EXCLUDE_PATTERNS);
12524 bool alwaysRecursive = Config_getBool(RECURSIVE);
12525 StringUnorderedSet excludeNameSet;
12526
12527 // gather names of all files in the include path
12528 g_s.begin("Searching for include files...\n");
12529 killSet.clear();
12530 StringVector includePathList = Config_getList(INCLUDE_PATH);
12531 for (const auto &s : includePathList)
12532 {
12533 size_t plSize = Config_getList(INCLUDE_FILE_PATTERNS).size();
12534 StringVector pl = plSize==0 ? Config_getList(FILE_PATTERNS) :
12535 Config_getList(INCLUDE_FILE_PATTERNS);
12536 readFileOrDirectory(s, // s
12538 nullptr, // exclSet
12539 &pl, // patList
12540 &exclPatterns, // exclPatList
12541 nullptr, // resultList
12542 nullptr, // resultSet
12543 false, // INCLUDE_PATH isn't recursive
12544 true, // errorIfNotExist
12545 &killSet); // killSet
12546 }
12547 g_s.end();
12548
12549 g_s.begin("Searching for example files...\n");
12550 killSet.clear();
12551 StringVector examplePathList = Config_getList(EXAMPLE_PATH);
12552 for (const auto &s : examplePathList)
12553 {
12554 StringVector patterns = Config_getList(EXAMPLE_PATTERNS);
12555 readFileOrDirectory(s, // s
12557 nullptr, // exclSet
12558 &patterns, // patList
12559 nullptr, // exclPatList
12560 nullptr, // resultList
12561 nullptr, // resultSet
12562 (alwaysRecursive || Config_getBool(EXAMPLE_RECURSIVE)), // recursive
12563 true, // errorIfNotExist
12564 &killSet); // killSet
12565 }
12566 g_s.end();
12567
12568 g_s.begin("Searching for images...\n");
12569 killSet.clear();
12570 StringVector imagePathList=Config_getList(IMAGE_PATH);
12571 for (const auto &s : imagePathList)
12572 {
12573 readFileOrDirectory(s, // s
12575 nullptr, // exclSet
12576 nullptr, // patList
12577 nullptr, // exclPatList
12578 nullptr, // resultList
12579 nullptr, // resultSet
12580 alwaysRecursive, // recursive
12581 true, // errorIfNotExist
12582 &killSet); // killSet
12583 }
12584 g_s.end();
12585
12586 g_s.begin("Searching for dot files...\n");
12587 killSet.clear();
12588 StringVector dotFileList=Config_getList(DOTFILE_DIRS);
12589 for (const auto &s : dotFileList)
12590 {
12591 readFileOrDirectory(s, // s
12593 nullptr, // exclSet
12594 nullptr, // patList
12595 nullptr, // exclPatList
12596 nullptr, // resultList
12597 nullptr, // resultSet
12598 alwaysRecursive, // recursive
12599 true, // errorIfNotExist
12600 &killSet); // killSet
12601 }
12602 g_s.end();
12603
12604 g_s.begin("Searching for msc files...\n");
12605 killSet.clear();
12606 StringVector mscFileList=Config_getList(MSCFILE_DIRS);
12607 for (const auto &s : mscFileList)
12608 {
12609 readFileOrDirectory(s, // s
12611 nullptr, // exclSet
12612 nullptr, // patList
12613 nullptr, // exclPatList
12614 nullptr, // resultList
12615 nullptr, // resultSet
12616 alwaysRecursive, // recursive
12617 true, // errorIfNotExist
12618 &killSet); // killSet
12619 }
12620 g_s.end();
12621
12622 g_s.begin("Searching for dia files...\n");
12623 killSet.clear();
12624 StringVector diaFileList=Config_getList(DIAFILE_DIRS);
12625 for (const auto &s : diaFileList)
12626 {
12627 readFileOrDirectory(s, // s
12629 nullptr, // exclSet
12630 nullptr, // patList
12631 nullptr, // exclPatList
12632 nullptr, // resultList
12633 nullptr, // resultSet
12634 alwaysRecursive, // recursive
12635 true, // errorIfNotExist
12636 &killSet); // killSet
12637 }
12638 g_s.end();
12639
12640 g_s.begin("Searching for plantuml files...\n");
12641 killSet.clear();
12642 StringVector plantUmlFileList=Config_getList(PLANTUMLFILE_DIRS);
12643 for (const auto &s : plantUmlFileList)
12644 {
12645 readFileOrDirectory(s, // s
12647 nullptr, // exclSet
12648 nullptr, // patList
12649 nullptr, // exclPatList
12650 nullptr, // resultList
12651 nullptr, // resultSet
12652 alwaysRecursive, // recursive
12653 true, // errorIfNotExist
12654 &killSet); // killSet
12655 }
12656 g_s.end();
12657
12658 g_s.begin("Searching for mermaid files...\n");
12659 killSet.clear();
12660 StringVector mermaidFileList=Config_getList(MERMAIDFILE_DIRS);
12661 for (const auto &s : mermaidFileList)
12662 {
12663 readFileOrDirectory(s, // s
12665 nullptr, // exclSet
12666 nullptr, // patList
12667 nullptr, // exclPatList
12668 nullptr, // resultList
12669 nullptr, // resultSet
12670 alwaysRecursive, // recursive
12671 true, // errorIfNotExist
12672 &killSet); // killSet
12673 }
12674 g_s.end();
12675
12676 g_s.begin("Searching for files to exclude\n");
12677 StringVector excludeList = Config_getList(EXCLUDE);
12678 for (const auto &s : excludeList)
12679 {
12680 StringVector filePatterns = Config_getList(FILE_PATTERNS);
12681 readFileOrDirectory(s, // s
12682 nullptr, // fnDict
12683 nullptr, // exclSet
12684 &filePatterns, // patList
12685 nullptr, // exclPatList
12686 nullptr, // resultList
12687 &excludeNameSet, // resultSet
12688 alwaysRecursive, // recursive
12689 false); // errorIfNotExist
12690 }
12691 g_s.end();
12692
12693 /**************************************************************************
12694 * Determine Input Files *
12695 **************************************************************************/
12696
12697 g_s.begin("Searching INPUT for files to process...\n");
12698 killSet.clear();
12699 Doxygen::inputPaths.clear();
12700 StringVector inputList=Config_getList(INPUT);
12701 for (const auto &s : inputList)
12702 {
12703 DString path = s;
12704 size_t l = path.length();
12705 if (l>0)
12706 {
12707 // strip trailing slashes
12708 if (path.at(l-1)=='\\' || path.at(l-1)=='/') path=path.left(l-1);
12709
12710 StringVector filePatterns = Config_getList(FILE_PATTERNS);
12712 path, // s
12714 &excludeNameSet, // exclSet
12715 &filePatterns, // patList
12716 &exclPatterns, // exclPatList
12717 &g_inputFiles, // resultList
12718 nullptr, // resultSet
12719 alwaysRecursive, // recursive
12720 true, // errorIfNotExist
12721 &killSet, // killSet
12722 &Doxygen::inputPaths); // paths
12723 }
12724 }
12725
12726 // Sort the FileDef objects by full path to get a predictable ordering over multiple runs
12727 for (auto &fileName : *Doxygen::inputNameLinkedMap)
12728 {
12729 if (fileName->size()>1)
12730 {
12731 std::stable_sort(fileName->begin(),fileName->end(),[](const auto &f1,const auto &f2)
12732 {
12733 return dstricmp_sort(f1->absFilePath(),f2->absFilePath())<0;
12734 });
12735 }
12736 }
12737 std::stable_sort(Doxygen::inputNameLinkedMap->begin(),
12739 [](const auto &f1,const auto &f2)
12740 {
12741 return dstricmp_sort(f1->front()->absFilePath(),f2->front()->absFilePath())<0;
12742 });
12743 if (Doxygen::inputNameLinkedMap->empty())
12744 {
12745 warn_uncond("No files to be processed, please check your settings, in particular INPUT, FILE_PATTERNS, and RECURSIVE\n");
12746 }
12747 g_s.end();
12748}
12749
12750
12752{
12753 if (Config_getBool(MARKDOWN_SUPPORT))
12754 {
12755 DString mdfileAsMainPage = Config_getString(USE_MDFILE_AS_MAINPAGE);
12756 if (mdfileAsMainPage.empty()) return;
12757 FileInfo fi(mdfileAsMainPage.data());
12758 if (!fi.exists())
12759 {
12760 warn_uncond("Specified markdown mainpage '{}' does not exist\n",mdfileAsMainPage);
12761 return;
12762 }
12763 bool ambig = false;
12764 if (Doxygen::inputNameLinkedMap->findFileDef(fi.absFilePath(),ambig)==nullptr)
12765 {
12766 warn_uncond("Specified markdown mainpage '{}' has not been defined as input file\n",mdfileAsMainPage);
12767 return;
12768 }
12769 }
12770}
12771
12773{
12774 AUTO_TRACE();
12775 std::atexit(exitDoxygen);
12776
12777 Portable::correctPath(Config_getList(EXTERNAL_TOOL_PATH));
12778
12779#if USE_LIBCLANG
12780 Doxygen::clangAssistedParsing = Config_getBool(CLANG_ASSISTED_PARSING);
12781#endif
12782
12783 // we would like to show the versionString earlier, but we first have to handle the configuration file
12784 // to know the value of the QUIET setting.
12785 DString versionString = getFullVersion();
12786 msg("Doxygen version used: {}\n",versionString);
12787
12789
12790 /**************************************************************************
12791 * Make sure the output directory exists
12792 **************************************************************************/
12793 DString outputDirectory = Config_getString(OUTPUT_DIRECTORY);
12794 if (!g_singleComment)
12795 {
12796 if (outputDirectory.empty())
12797 {
12798 outputDirectory = Config_updateString(OUTPUT_DIRECTORY,Dir::currentDirPath());
12799 }
12800 else
12801 {
12802 Dir dir(outputDirectory.str());
12803 if (!dir.exists())
12804 {
12806 if (!dir.mkdir(outputDirectory.str()))
12807 {
12808 term("tag OUTPUT_DIRECTORY: Output directory '{}' does not "
12809 "exist and cannot be created\n",outputDirectory);
12810 }
12811 else
12812 {
12813 msg("Notice: Output directory '{}' does not exist. "
12814 "I have created it for you.\n", outputDirectory);
12815 }
12816 dir.setPath(outputDirectory.str());
12817 }
12818 outputDirectory = Config_updateString(OUTPUT_DIRECTORY,dir.absPath());
12819 }
12820 }
12821 AUTO_TRACE_ADD("outputDirectory={}",outputDirectory);
12822
12823 /**************************************************************************
12824 * Initialize global lists and dictionaries
12825 **************************************************************************/
12826
12827#ifdef HAS_SIGNALS
12828 signal(SIGINT, stopDoxygen);
12829#endif
12830
12831 uint32_t pid = Portable::pid();
12832 Doxygen::filterDBFileName.sprintf("doxygen_filterdb_%d.tmp",pid);
12833 Doxygen::filterDBFileName.prepend(outputDirectory+"/");
12834
12835 /**************************************************************************
12836 * Check/create output directories *
12837 **************************************************************************/
12838
12839 bool generateHtml = Config_getBool(GENERATE_HTML);
12840 bool generateDocbook = Config_getBool(GENERATE_DOCBOOK);
12841 bool generateXml = Config_getBool(GENERATE_XML);
12842 bool generateLatex = Config_getBool(GENERATE_LATEX);
12843 bool generateRtf = Config_getBool(GENERATE_RTF);
12844 bool generateMan = Config_getBool(GENERATE_MAN);
12845 bool generateSql = Config_getBool(GENERATE_SQLITE3);
12846 DString htmlOutput;
12847 DString docbookOutput;
12848 DString xmlOutput;
12849 DString latexOutput;
12850 DString rtfOutput;
12851 DString manOutput;
12852 DString sqlOutput;
12853
12854 if (!g_singleComment)
12855 {
12856 if (generateHtml)
12857 {
12858 htmlOutput = createOutputDirectory(outputDirectory,Config_getString(HTML_OUTPUT),"/html");
12859 Config_updateString(HTML_OUTPUT,htmlOutput);
12860
12861 DString sitemapUrl = Config_getString(SITEMAP_URL);
12862 bool generateSitemap = !sitemapUrl.empty();
12863 if (generateSitemap && !sitemapUrl.endsWith("/"))
12864 {
12865 Config_updateString(SITEMAP_URL,sitemapUrl+"/");
12866 }
12867
12868 // add HTML indexers that are enabled
12869 bool generateHtmlHelp = Config_getBool(GENERATE_HTMLHELP);
12870 bool generateEclipseHelp = Config_getBool(GENERATE_ECLIPSEHELP);
12871 bool generateQhp = Config_getBool(GENERATE_QHP);
12872 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
12873 bool generateDocSet = Config_getBool(GENERATE_DOCSET);
12874 if (generateEclipseHelp) Doxygen::indexList->addIndex<EclipseHelp>();
12875 if (generateHtmlHelp) Doxygen::indexList->addIndex<HtmlHelp>();
12876 if (generateQhp) Doxygen::indexList->addIndex<Qhp>();
12877 if (generateSitemap) Doxygen::indexList->addIndex<Sitemap>();
12878 if (generateTreeView) Doxygen::indexList->addIndex<FTVHelp>(true);
12879 if (generateDocSet) Doxygen::indexList->addIndex<DocSets>();
12882 }
12883
12884 if (generateDocbook)
12885 {
12886 docbookOutput = createOutputDirectory(outputDirectory,Config_getString(DOCBOOK_OUTPUT),"/docbook");
12887 Config_updateString(DOCBOOK_OUTPUT,docbookOutput);
12888 }
12889
12890 if (generateXml)
12891 {
12892 xmlOutput = createOutputDirectory(outputDirectory,Config_getString(XML_OUTPUT),"/xml");
12893 Config_updateString(XML_OUTPUT,xmlOutput);
12894 }
12895
12896 if (generateLatex)
12897 {
12898 latexOutput = createOutputDirectory(outputDirectory,Config_getString(LATEX_OUTPUT), "/latex");
12899 Config_updateString(LATEX_OUTPUT,latexOutput);
12900 }
12901
12902 if (generateRtf)
12903 {
12904 rtfOutput = createOutputDirectory(outputDirectory,Config_getString(RTF_OUTPUT),"/rtf");
12905 Config_updateString(RTF_OUTPUT,rtfOutput);
12906 }
12907
12908 if (generateMan)
12909 {
12910 manOutput = createOutputDirectory(outputDirectory,Config_getString(MAN_OUTPUT),"/man");
12911 Config_updateString(MAN_OUTPUT,manOutput);
12912 }
12913
12914 if (generateSql)
12915 {
12916 sqlOutput = createOutputDirectory(outputDirectory,Config_getString(SQLITE3_OUTPUT),"/sqlite3");
12917 Config_updateString(SQLITE3_OUTPUT,sqlOutput);
12918 }
12919 }
12920
12921 if (Config_getBool(HAVE_DOT))
12922 {
12923 DString curFontPath = Config_getString(DOT_FONTPATH);
12924 if (curFontPath.empty())
12925 {
12926 Portable::getenv("DOTFONTPATH");
12927 DString newFontPath = ".";
12928 if (!curFontPath.empty())
12929 {
12930 newFontPath+=Portable::pathListSeparator();
12931 newFontPath+=curFontPath;
12932 }
12933 Portable::setenv("DOTFONTPATH",qPrint(newFontPath));
12934 }
12935 else
12936 {
12937 Portable::setenv("DOTFONTPATH",qPrint(curFontPath));
12938 }
12939 }
12940
12941 /**************************************************************************
12942 * Handle layout file *
12943 **************************************************************************/
12944
12946 DString layoutFileName = Config_getString(LAYOUT_FILE);
12947 bool defaultLayoutUsed = false;
12948 if (layoutFileName.empty())
12949 {
12950 layoutFileName = Config_updateString(LAYOUT_FILE,"DoxygenLayout.xml");
12951 defaultLayoutUsed = true;
12952 }
12953 AUTO_TRACE_ADD("defaultLayoutUsed={}, layoutFileName={}",defaultLayoutUsed,layoutFileName);
12954
12955 FileInfo fi(layoutFileName.str());
12956 if (fi.exists())
12957 {
12958 msg("Parsing layout file {}...\n",layoutFileName);
12959 LayoutDocManager::instance().parse(layoutFileName);
12960 }
12961 else if (!defaultLayoutUsed)
12962 {
12963 warn_uncond("failed to open layout file '{}' for reading! Using default settings.\n",layoutFileName);
12964 }
12965 printLayout();
12966
12967 /**************************************************************************
12968 * Read and preprocess input *
12969 **************************************************************************/
12970
12971 // prevent search in the output directories
12972 StringVector exclPatterns = Config_getList(EXCLUDE_PATTERNS);
12973 if (generateHtml) exclPatterns.push_back(htmlOutput.str());
12974 if (generateDocbook) exclPatterns.push_back(docbookOutput.str());
12975 if (generateXml) exclPatterns.push_back(xmlOutput.str());
12976 if (generateLatex) exclPatterns.push_back(latexOutput.str());
12977 if (generateRtf) exclPatterns.push_back(rtfOutput.str());
12978 if (generateMan) exclPatterns.push_back(manOutput.str());
12979 Config_updateList(EXCLUDE_PATTERNS,exclPatterns);
12980
12981 if (!g_singleComment)
12982 {
12984
12986 }
12987
12988 // Notice: the order of the function calls below is very important!
12989
12990 if (generateHtml && !Config_getBool(USE_MATHJAX))
12991 {
12993 }
12994 if (generateRtf)
12995 {
12997 }
12998 if (generateDocbook)
12999 {
13001 }
13002
13004
13005 /**************************************************************************
13006 * Handle Tag Files *
13007 **************************************************************************/
13008
13009 std::shared_ptr<Entry> root = std::make_shared<Entry>();
13010
13011 if (!g_singleComment)
13012 {
13013 msg("Reading and parsing tag files\n");
13014 StringVector tagFileList = Config_getList(TAGFILES);
13015 for (const auto &s : tagFileList)
13016 {
13017 readTagFile(root,s.c_str());
13018 }
13019 }
13020
13021 /**************************************************************************
13022 * Parse source files *
13023 **************************************************************************/
13024
13025 addSTLSupport(root);
13026
13027 g_s.begin("Parsing files\n");
13028 if (g_singleComment)
13029 {
13030 //printf("Parsing comment %s\n",qPrint(g_commentFileName));
13031 if (g_commentFileName=="-")
13032 {
13033 std::string text = fileToString(g_commentFileName).str();
13034 addTerminalCharIfMissing(text,'\n');
13035 generateHtmlForComment("stdin.md",text);
13036 }
13037 else if (FileInfo(g_commentFileName.str()).isFile())
13038 {
13039 std::string text;
13041 addTerminalCharIfMissing(text,'\n');
13043 }
13044 else
13045 {
13046 }
13048 exit(0);
13049 }
13050 else
13051 {
13052 if (Config_getInt(NUM_PROC_THREADS)==1)
13053 {
13055 }
13056 else
13057 {
13059 }
13060 }
13061 g_s.end();
13062
13063 /**************************************************************************
13064 * Gather information *
13065 **************************************************************************/
13066
13067 g_s.begin("Building macro definition list...\n");
13069 g_s.end();
13070
13071 g_s.begin("Building group list...\n");
13072 buildGroupList(root.get());
13073 organizeSubGroups(root.get());
13074 g_s.end();
13075
13076 g_s.begin("Building directory list...\n");
13078 findDirDocumentation(root.get());
13079 g_s.end();
13080
13081 g_s.begin("Building namespace list...\n");
13082 buildNamespaceList(root.get());
13083 findUsingDirectives(root.get());
13084 g_s.end();
13085
13086 g_s.begin("Building file list...\n");
13087 buildFileList(root.get());
13088 g_s.end();
13089
13090 g_s.begin("Building class list...\n");
13091 buildClassList(root.get());
13092 g_s.end();
13093
13094 g_s.begin("Building concept list...\n");
13095 buildConceptList(root.get());
13096 g_s.end();
13097
13098 // build list of using declarations here (global list)
13099 buildListOfUsingDecls(root.get());
13100 g_s.end();
13101
13102 g_s.begin("Computing nesting relations for classes...\n");
13104 g_s.end();
13105 // 1.8.2-20121111: no longer add nested classes to the group as well
13106 //distributeClassGroupRelations();
13107
13108 // calling buildClassList may result in cached relations that
13109 // become invalid after resolveClassNestingRelations(), that's why
13110 // we need to clear the cache here
13112 // we don't need the list of using declaration anymore
13113 g_usingDeclarations.clear();
13114
13115 g_s.begin("Associating documentation with classes...\n");
13116 buildClassDocList(root.get());
13117 g_s.end();
13118
13119 g_s.begin("Associating documentation with concepts...\n");
13120 buildConceptDocList(root.get());
13122 g_s.end();
13123
13124 g_s.begin("Associating documentation with modules...\n");
13125 findModuleDocumentation(root.get());
13126 g_s.end();
13127
13128 g_s.begin("Building example list...\n");
13129 buildExampleList(root.get());
13130 g_s.end();
13131
13132 g_s.begin("Searching for enumerations...\n");
13133 findEnums(root.get());
13134 g_s.end();
13135
13136 // Since buildVarList calls isVarWithConstructor
13137 // and this calls getResolvedClass we need to process
13138 // typedefs first so the relations between classes via typedefs
13139 // are properly resolved. See bug 536385 for an example.
13140 g_s.begin("Searching for documented typedefs...\n");
13141 buildTypedefList(root.get());
13142 g_s.end();
13143
13144 if (Config_getBool(OPTIMIZE_OUTPUT_SLICE))
13145 {
13146 g_s.begin("Searching for documented sequences...\n");
13147 buildSequenceList(root.get());
13148 g_s.end();
13149
13150 g_s.begin("Searching for documented dictionaries...\n");
13151 buildDictionaryList(root.get());
13152 g_s.end();
13153 }
13154
13155 g_s.begin("Searching for members imported via using declarations...\n");
13156 // this should be after buildTypedefList in order to properly import
13157 // used typedefs
13158 findUsingDeclarations(root.get(),true); // do for python packages first
13159 findUsingDeclarations(root.get(),false); // then the rest
13160 g_s.end();
13161
13162 g_s.begin("Searching for included using directives...\n");
13164 g_s.end();
13165
13166 g_s.begin("Searching for documented variables...\n");
13167 buildVarList(root.get());
13168 g_s.end();
13169
13170 g_s.begin("Building interface member list...\n");
13171 buildInterfaceAndServiceList(root.get()); // UNO IDL
13172
13173 g_s.begin("Building member list...\n"); // using class info only !
13174 buildFunctionList(root.get());
13175 g_s.end();
13176
13177 g_s.begin("Searching for friends...\n");
13178 findFriends();
13179 g_s.end();
13180
13181 g_s.begin("Searching for documented defines...\n");
13182 findDefineDocumentation(root.get());
13183 g_s.end();
13184
13185 g_s.begin("Computing class inheritance relations...\n");
13186 findClassEntries(root.get());
13188 g_s.end();
13189
13190 g_s.begin("Computing class usage relations...\n");
13192 g_s.end();
13193
13194 g_s.begin("Flushing cached template relations that have become invalid...\n");
13196 g_s.end();
13197
13198 g_s.begin("Warn for undocumented namespaces...\n");
13200 g_s.end();
13201
13202 g_s.begin("Computing class relations...\n");
13205 if (Config_getBool(OPTIMIZE_OUTPUT_VHDL))
13206 {
13208 }
13210 g_classEntries.clear();
13211 g_s.end();
13212
13213 g_s.begin("Add enum values to enums...\n");
13214 addEnumValuesToEnums(root.get());
13215 findEnumDocumentation(root.get());
13216 g_s.end();
13217
13218 g_s.begin("Searching for member function documentation...\n");
13219 findObjCMethodDefinitions(root.get());
13220 findMemberDocumentation(root.get()); // may introduce new members !
13221 findUsingDeclImports(root.get()); // may introduce new members !
13222 g_usingClassMap.clear();
13226 g_s.end();
13227
13228 // moved to after finding and copying documentation,
13229 // as this introduces new members see bug 722654
13230 g_s.begin("Creating members for template instances...\n");
13232 g_s.end();
13233
13234 g_s.begin("Searching for tag less structs...\n");
13236 g_s.end();
13237
13238 g_s.begin("Building page list...\n");
13239 buildPageList(root.get());
13240 g_s.end();
13241
13242 g_s.begin("Building requirements list...\n");
13243 buildRequirementsList(root.get());
13244 g_s.end();
13245
13246 g_s.begin("Search for main page...\n");
13247 findMainPage(root.get());
13248 findMainPageTagFiles(root.get());
13249 g_s.end();
13250
13251 g_s.begin("Computing page relations...\n");
13252 computePageRelations(root.get());
13254 g_s.end();
13255
13256 g_s.begin("Determining the scope of groups...\n");
13257 findGroupScope(root.get());
13258 g_s.end();
13259
13260 g_s.begin("Computing module relations...\n");
13261 auto &mm = ModuleManager::instance();
13262 mm.resolvePartitions();
13263 mm.resolveImports();
13264 mm.collectExportedSymbols();
13265 g_s.end();
13266
13267 auto memberNameComp = [](const MemberNameLinkedMap::Ptr &n1,const MemberNameLinkedMap::Ptr &n2)
13268 {
13269 return dstricmp_sort(n1->memberName().data()+getPrefixIndex(n1->memberName()),
13270 n2->memberName().data()+getPrefixIndex(n2->memberName())
13271 )<0;
13272 };
13273
13274 auto classComp = [](const ClassLinkedMap::Ptr &c1,const ClassLinkedMap::Ptr &c2)
13275 {
13276 if (Config_getBool(SORT_BY_SCOPE_NAME))
13277 {
13278 return dstricmp_sort(c1->name(), c2->name())<0;
13279 }
13280 else
13281 {
13282 int i = dstricmp_sort(c1->className(), c2->className());
13283 return i==0 ? dstricmp_sort(c1->name(), c2->name())<0 : i<0;
13284 }
13285 };
13286
13287 auto namespaceComp = [](const NamespaceLinkedMap::Ptr &n1,const NamespaceLinkedMap::Ptr &n2)
13288 {
13289 return dstricmp_sort(n1->name(),n2->name())<0;
13290 };
13291
13292 auto conceptComp = [](const ConceptLinkedMap::Ptr &c1,const ConceptLinkedMap::Ptr &c2)
13293 {
13294 return dstricmp_sort(c1->name(),c2->name())<0;
13295 };
13296
13297 g_s.begin("Sorting lists...\n");
13298 std::stable_sort(Doxygen::memberNameLinkedMap->begin(),
13300 memberNameComp);
13301 std::stable_sort(Doxygen::functionNameLinkedMap->begin(),
13303 memberNameComp);
13304 std::stable_sort(Doxygen::hiddenClassLinkedMap->begin(),
13306 classComp);
13307 std::stable_sort(Doxygen::classLinkedMap->begin(),
13309 classComp);
13310 std::stable_sort(Doxygen::conceptLinkedMap->begin(),
13312 conceptComp);
13313 std::stable_sort(Doxygen::namespaceLinkedMap->begin(),
13315 namespaceComp);
13316 g_s.end();
13317
13318 g_s.begin("Determining which enums are documented\n");
13320 g_s.end();
13321
13322 g_s.begin("Computing member relations...\n");
13325 g_s.end();
13326
13327 g_s.begin("Building full member lists recursively...\n");
13329 g_s.end();
13330
13331 g_s.begin("Adding members to member groups.\n");
13333 g_s.end();
13334
13335 if (Config_getBool(DISTRIBUTE_GROUP_DOC))
13336 {
13337 g_s.begin("Distributing member group documentation.\n");
13339 g_s.end();
13340 }
13341
13342 g_s.begin("Computing member references...\n");
13344 g_s.end();
13345
13346 if (Config_getBool(INHERIT_DOCS))
13347 {
13348 g_s.begin("Inheriting documentation...\n");
13350 g_s.end();
13351 }
13352
13353
13354 // compute the shortest possible names of all files
13355 // without losing the uniqueness of the file names.
13356 g_s.begin("Generating disk names...\n");
13358 g_s.end();
13359
13360 g_s.begin("Adding source references...\n");
13362 g_s.end();
13363
13364 g_s.begin("Adding xrefitems...\n");
13367 g_s.end();
13368
13369 g_s.begin("Adding requirements...\n");
13372 g_s.end();
13373
13374 g_s.begin("Sorting member lists...\n");
13376 g_s.end();
13377
13378 g_s.begin("Setting anonymous enum type...\n");
13380 g_s.end();
13381
13382 g_s.begin("Computing dependencies between directories...\n");
13384 g_s.end();
13385
13386 g_s.begin("Generating citations page...\n");
13388 g_s.end();
13389
13390 g_s.begin("Counting data structures...\n");
13392 g_s.end();
13393
13394 g_s.begin("Resolving user defined references...\n");
13396 g_s.end();
13397
13398 g_s.begin("Finding anchors and sections in the documentation...\n");
13400 g_s.end();
13401
13402 g_s.begin("Transferring function references...\n");
13404 g_s.end();
13405
13406 g_s.begin("Combining using relations...\n");
13408 g_s.end();
13409
13411 g_s.begin("Adding members to index pages...\n");
13413 addToIndices();
13414 g_s.end();
13415
13416 g_s.begin("Correcting members for VHDL...\n");
13418 g_s.end();
13419
13420 g_s.begin("Computing tooltip texts...\n");
13422 g_s.end();
13423
13424 if (Config_getBool(SORT_GROUP_NAMES))
13425 {
13426 std::stable_sort(Doxygen::groupLinkedMap->begin(),
13428 [](const auto &g1,const auto &g2)
13429 { return g1->groupTitle() < g2->groupTitle(); });
13430
13431 for (const auto &gd : *Doxygen::groupLinkedMap)
13432 {
13433 gd->sortSubGroups();
13434 }
13435 }
13436
13437 printNavTree(root.get(),0);
13439}
13440
13442{
13443 AUTO_TRACE();
13444 /**************************************************************************
13445 * Initialize output generators *
13446 **************************************************************************/
13447
13448 /// add extra languages for which we can only produce syntax highlighted code
13450
13451 //// dump all symbols
13452 if (g_dumpSymbolMap)
13453 {
13454 dumpSymbolMap();
13455 exit(0);
13456 }
13457
13458 bool generateHtml = Config_getBool(GENERATE_HTML);
13459 bool generateLatex = Config_getBool(GENERATE_LATEX);
13460 bool generateMan = Config_getBool(GENERATE_MAN);
13461 bool generateRtf = Config_getBool(GENERATE_RTF);
13462 bool generateDocbook = Config_getBool(GENERATE_DOCBOOK);
13463
13464
13466 if (generateHtml)
13467 {
13471 }
13472 if (generateLatex)
13473 {
13476 }
13477 if (generateDocbook)
13478 {
13481 }
13482 if (generateMan)
13483 {
13486 }
13487 if (generateRtf)
13488 {
13491 }
13492 if (Config_getBool(USE_HTAGS))
13493 {
13494 Htags::useHtags = true;
13495 DString htmldir = Config_getString(HTML_OUTPUT);
13496 if (!Htags::execute(htmldir))
13497 err("USE_HTAGS is YES but htags(1) failed. \n");
13498 else if (!Htags::loadFilemap(htmldir))
13499 err("htags(1) ended normally but failed to load the filemap. \n");
13500 }
13501
13502 /**************************************************************************
13503 * Generate documentation *
13504 **************************************************************************/
13505
13506 g_s.begin("Generating style sheet...\n");
13507 //printf("writing style info\n");
13508 g_outputList->writeStyleInfo(0); // write first part
13509 g_s.end();
13510
13511 bool searchEngine = Config_getBool(SEARCHENGINE);
13512 bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
13513
13514 g_s.begin("Generating search indices...\n");
13515 if (searchEngine && !serverBasedSearch && generateHtml)
13516 {
13518 }
13519
13520 // generate search indices (need to do this before writing other HTML
13521 // pages as these contain a drop down menu with options depending on
13522 // what categories we find in this function.
13523 if (generateHtml && searchEngine)
13524 {
13525 DString searchDirName = Config_getString(HTML_OUTPUT)+"/search";
13526 Dir searchDir(searchDirName.str());
13527 if (!searchDir.exists() && !searchDir.mkdir(searchDirName.str()))
13528 {
13529 term("Could not create search results directory '{}' $PWD='{}'\n",
13530 searchDirName,Dir::currentDirPath());
13531 }
13532 HtmlGenerator::writeSearchData(searchDirName);
13533 if (!serverBasedSearch) // client side search index
13534 {
13536 }
13537 }
13538 g_s.end();
13539
13540 // copy static stuff
13541 if (generateHtml)
13542 {
13544 copyLogo(Config_getString(HTML_OUTPUT),true);
13545 copyIcon(Config_getString(HTML_OUTPUT),true);
13546 copyExtraFiles(Config_getList(HTML_EXTRA_FILES),"HTML_EXTRA_FILES",Config_getString(HTML_OUTPUT),true);
13547 }
13548 if (generateLatex)
13549 {
13551 copyLogo(Config_getString(LATEX_OUTPUT),false);
13552 copyIcon(Config_getString(LATEX_OUTPUT),false);
13553 copyExtraFiles(Config_getList(LATEX_EXTRA_FILES),"LATEX_EXTRA_FILES",Config_getString(LATEX_OUTPUT),false);
13554 }
13555 if (generateDocbook)
13556 {
13557 copyLogo(Config_getString(DOCBOOK_OUTPUT),false);
13558 copyIcon(Config_getString(DOCBOOK_OUTPUT),false);
13559 }
13560 if (generateRtf)
13561 {
13562 copyLogo(Config_getString(RTF_OUTPUT),false);
13563 copyIcon(Config_getString(RTF_OUTPUT),false);
13564 copyExtraFiles(Config_getList(RTF_EXTRA_FILES),"RTF_EXTRA_FILES",Config_getString(RTF_OUTPUT),false);
13565 }
13566
13568 if (fm.hasFormulas() && generateHtml
13569 && !Config_getBool(USE_MATHJAX))
13570 {
13571 g_s.begin("Generating images for formulas in HTML...\n");
13572 fm.generateImages(Config_getString(HTML_OUTPUT), true, Config_getEnum(HTML_FORMULA_FORMAT)==HTML_FORMULA_FORMAT_t::svg ?
13574 g_s.end();
13575 }
13576 if (fm.hasFormulas() && generateRtf)
13577 {
13578 g_s.begin("Generating images for formulas in RTF...\n");
13580 g_s.end();
13581 }
13582
13583 if (fm.hasFormulas() && generateDocbook)
13584 {
13585 g_s.begin("Generating images for formulas in Docbook...\n");
13587 g_s.end();
13588 }
13589
13590 g_s.begin("Generating example documentation...\n");
13592 g_s.end();
13593
13594 g_s.begin("Generating file sources...\n");
13596 g_s.end();
13597
13598 g_s.begin("Counting members...\n");
13599 // needs to be done after generating the sources
13600 // but before generating the compound documentation, see bug #12233
13601 countMembers();
13602 g_s.end();
13603
13604 g_s.begin("Generating file documentation...\n");
13606 g_s.end();
13607
13608 g_s.begin("Generating page documentation...\n");
13610 g_s.end();
13611
13612 g_s.begin("Generating group documentation...\n");
13614 g_s.end();
13615
13616 g_s.begin("Generating class documentation...\n");
13618 g_s.end();
13619
13620 g_s.begin("Generating concept documentation...\n");
13622 g_s.end();
13623
13624 g_s.begin("Generating module documentation...\n");
13626 g_s.end();
13627
13628 g_s.begin("Generating namespace documentation...\n");
13630 g_s.end();
13631
13632 if (Config_getBool(GENERATE_LEGEND))
13633 {
13634 g_s.begin("Generating graph info page...\n");
13636 g_s.end();
13637 }
13638
13639 g_s.begin("Generating directory documentation...\n");
13641 g_s.end();
13642
13643 if (g_outputList->size()>0)
13644 {
13646 }
13647
13648 g_s.begin("finalizing index lists...\n");
13650 g_s.end();
13651
13652 g_s.begin("writing tag file...\n");
13653 writeTagFile();
13654 g_s.end();
13655
13656 if (Config_getBool(GENERATE_XML))
13657 {
13658 g_s.begin("Generating XML output...\n");
13660 generateXML();
13662 g_s.end();
13663 }
13664 if (Config_getBool(GENERATE_SQLITE3))
13665 {
13666 g_s.begin("Generating SQLITE3 output...\n");
13668 g_s.end();
13669 }
13670
13671 if (Config_getBool(GENERATE_AUTOGEN_DEF))
13672 {
13673 g_s.begin("Generating AutoGen DEF output...\n");
13674 generateDEF();
13675 g_s.end();
13676 }
13677 if (Config_getBool(GENERATE_PERLMOD))
13678 {
13679 g_s.begin("Generating Perl module output...\n");
13681 g_s.end();
13682 }
13683 if (generateHtml && searchEngine && serverBasedSearch)
13684 {
13685 g_s.begin("Generating search index\n");
13686 if (Doxygen::searchIndex.kind()==SearchIndexIntf::Internal) // write own search index
13687 {
13689 Doxygen::searchIndex.write(Config_getString(HTML_OUTPUT)+"/search/search.idx");
13690 }
13691 else // write data for external search index
13692 {
13694 DString searchDataFile = Config_getString(SEARCHDATA_FILE);
13695 if (searchDataFile.empty())
13696 {
13697 searchDataFile="searchdata.xml";
13698 }
13699 if (!Portable::isAbsolutePath(searchDataFile.data()))
13700 {
13701 searchDataFile.prepend(Config_getString(OUTPUT_DIRECTORY)+"/");
13702 }
13703 Doxygen::searchIndex.write(searchDataFile);
13704 }
13705 g_s.end();
13706 }
13707
13708 if (generateRtf)
13709 {
13710 g_s.begin("Combining RTF output...\n");
13711 if (!RTFGenerator::preProcessFileInplace(Config_getString(RTF_OUTPUT),"refman.rtf"))
13712 {
13713 err("An error occurred during post-processing the RTF files!\n");
13714 }
13715 g_s.end();
13716 }
13717
13718 if (PlantumlManager::instance().needToRun())
13719 {
13720 g_s.begin("Running plantuml with JAVA...\n");
13722 g_s.end();
13723 }
13724
13725 if (MermaidManager::instance().needToRun())
13726 {
13727 g_s.begin("Running mermaid (mmdc)...\n");
13729 g_s.end();
13730 }
13731
13732 if (Config_getBool(HAVE_DOT) && DotManager::instance()->needToRun())
13733 {
13734 g_s.begin("Running dot...\n");
13736 g_s.end();
13737 }
13738
13739 if (generateHtml &&
13740 Config_getBool(GENERATE_HTMLHELP) &&
13741 !Config_getString(HHC_LOCATION).empty())
13742 {
13743 g_s.begin("Running html help compiler...\n");
13745 g_s.end();
13746 }
13747
13748 if ( generateHtml &&
13749 Config_getBool(GENERATE_QHP) &&
13750 !Config_getString(QHG_LOCATION).empty())
13751 {
13752 g_s.begin("Running qhelpgenerator...\n");
13754 g_s.end();
13755 }
13756
13759
13761
13763 {
13764
13765 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
13766 if (numThreads<1) numThreads=1;
13767 msg("Total elapsed time: {:.6f} seconds\n(of which an average of {:.6f} seconds per thread waiting for external tools to finish)\n",
13768 (static_cast<double>(Debug::elapsedTime())),
13769 Portable::getSysElapsedTime()/static_cast<double>(numThreads)
13770 );
13771 g_s.print();
13772
13774 msg("finished...\n");
13776 }
13777 else
13778 {
13779 msg("finished...\n");
13780 }
13781
13782
13783 /**************************************************************************
13784 * Start cleaning up *
13785 **************************************************************************/
13786
13788
13790 Dir thisDir;
13791 thisDir.remove(Doxygen::filterDBFileName.str());
13793 exitTracing();
13795 delete Doxygen::clangUsrMap;
13796 g_successfulRun=true;
13797
13798 //dumpDocNodeSizes();
13799}
void readAliases()
Definition aliases.cpp:162
constexpr auto prefix
Definition anchor.cpp:47
This class contains the information about the argument of a function or template.
Definition arguments.h:27
DString defval
Definition arguments.h:47
DString array
Definition arguments.h:46
DString name
Definition arguments.h:45
DString type
Definition arguments.h:43
This class represents an function or template argument list.
Definition arguments.h:66
RefQualifierType refQualifier() const
Definition arguments.h:117
bool noParameters() const
Definition arguments.h:118
bool pureSpecifier() const
Definition arguments.h:114
iterator end()
Definition arguments.h:95
bool hasParameters() const
Definition arguments.h:77
DString trailingReturnType() const
Definition arguments.h:115
bool isDeleted() const
Definition arguments.h:116
size_t size() const
Definition arguments.h:101
void setPureSpecifier(bool b)
Definition arguments.h:122
bool constSpecifier() const
Definition arguments.h:112
void setTrailingReturnType(const DString &s)
Definition arguments.cpp:40
void push_back(const Argument &a)
Definition arguments.h:103
bool empty() const
Definition arguments.h:100
void setConstSpecifier(bool b)
Definition arguments.h:120
void setRefQualifier(RefQualifierType t)
Definition arguments.h:127
void setIsDeleted(bool b)
Definition arguments.h:126
iterator begin()
Definition arguments.h:94
bool volatileSpecifier() const
Definition arguments.h:113
void setNoParameters(bool b)
Definition arguments.h:128
void setVolatileSpecifier(bool b)
Definition arguments.h:121
static CitationManager & instance()
Definition cite.cpp:90
void clear()
clears the database
Definition cite.cpp:115
void generatePage()
Generate the citations page.
Definition cite.cpp:336
std::unique_ptr< ClangTUParser > createTUParser(const FileDef *fd) const
static ClangParser * instance()
Returns the one and only instance of the class.
Clang parser object for a single translation unit, which consists of a source file and the directly o...
Definition clangparser.h:25
void switchToFile(const FileDef *fd)
Switches to another file within the translation unit started with start().
void parse()
Parse the file given at construction time as a translation unit This file should already be preproces...
A abstract class representing of a compound symbol.
Definition classdef.h:100
virtual DString requiresClause() const =0
virtual const MemberDef * getMemberByName(const DString &) const =0
Returns the member with the given name.
virtual const ArgumentList & templateArguments() const =0
Returns the template arguments of this class.
virtual void writeDocumentation(OutputList &ol) const =0
virtual void writeMemberList(OutputList &ol) const =0
virtual bool isTemplate() const =0
Returns true if this class is a template.
virtual const BaseClassList & baseClasses() const =0
Returns the list of base classes from which this class directly inherits.
virtual int isBaseClass(const ClassDef *bcd, bool followInstances, const DString &templSpec=DString()) const =0
Returns true iff bcd is a direct or indirect base class of this class.
virtual const TemplateInstanceList & getTemplateInstances() const =0
Returns a sorted dictionary with all template instances found for this template class.
virtual ArgumentLists getTemplateParameterLists() const =0
Returns the template parameter lists that form the template declaration of this class.
virtual Protection protection() const =0
Return the protection level (Public,Protected,Private) in which this compound was found.
virtual DString compoundTypeString() const =0
Returns the type of compound as a string.
virtual MemberList * getMemberList(MemberListType lt) const =0
Returns the members in the list identified by lt.
virtual std::unique_ptr< ClassDef > deepCopy(const DString &name) const =0
virtual bool isForwardDeclared() const =0
Returns true if this class represents a forward declaration of a template class.
virtual bool isSubClass(ClassDef *bcd, int level=0) const =0
Returns true iff bcd is a direct or indirect sub class of this class.
virtual void moveTo(Definition *)=0
virtual const TemplateNameMap & getTemplateBaseClassNames() const =0
virtual DString qualifiedNameWithTemplateParameters(const ArgumentLists *actualParams=nullptr, uint32_t *actualParamIndex=nullptr) const =0
virtual bool isEmbeddedInOuterScope() const =0
virtual const MemberNameInfoLinkedMap & memberNameInfoLinkedMap() const =0
Returns a dictionary of all members.
virtual bool isImplicitTemplateInstance() const =0
virtual const ClassDef * templateMaster() const =0
Returns the template master of which this class is an instance.
CompoundType
The various compound types.
Definition classdef.h:105
@ Singleton
Definition classdef.h:114
@ Interface
Definition classdef.h:109
@ Exception
Definition classdef.h:112
virtual CompoundType compoundType() const =0
Returns the type of compound this is, i.e. class/struct/union/...
virtual bool containsOverload(const MemberDef *md) const =0
virtual ClassLinkedRefMap getClasses() const =0
returns the classes nested into this class
virtual FileDef * getFileDef() const =0
Returns the file in which this compound's definition can be found.
virtual void writeTagFile(TextStream &) const =0
virtual void writeDocumentationForInnerClasses(OutputList &ol) const =0
virtual void computeAnchors()=0
virtual void addTypeConstraints()=0
virtual void overrideCollaborationGraph(bool e)=0
virtual void addUsedClass(ClassDef *cd, const DString &accessName, Protection prot)=0
virtual void insertExplicitTemplateInstance(ClassDef *instance, const DString &spec)=0
virtual void countMembers()=0
virtual void addMembersToMemberGroup()=0
virtual void setPrimaryConstructorParams(const ArgumentList &list)=0
virtual void setTemplateBaseClassNames(const TemplateNameMap &templateNames)=0
virtual ClassDef * insertTemplateInstance(const DString &fileName, int startLine, size_t startColumn, const DString &templSpec, bool &freshInstance)=0
virtual void setClassName(const DString &name)=0
virtual void setFileDef(FileDef *fd)=0
virtual void reclassifyMember(MemberDefMutable *md, MemberType t)=0
virtual void setTemplateArguments(const ArgumentList &al)=0
virtual void setTemplateMaster(const ClassDef *tm)=0
virtual void makeTemplateArgument(bool b=true)=0
virtual void mergeCategory(ClassDef *category)=0
virtual void addQualifiers(const StringVector &qualifiers)=0
virtual void setClassSpecifier(TypeSpecifier spec)=0
virtual void insertUsedFile(const FileDef *)=0
virtual void setTaglessParent(const ClassDef *cd)=0
virtual void setUsedOnly(bool b)=0
virtual void sortMemberLists()=0
virtual void setProtection(Protection p)=0
virtual void setTypeConstraints(const ArgumentList &al)=0
virtual void overrideInheritanceGraph(CLASS_GRAPH_t e)=0
virtual void setAnonymousEnumType()=0
virtual void setCompoundType(CompoundType t)=0
virtual void distributeMemberGroupDocumentation()=0
virtual void setMetaData(const DString &md)=0
virtual void findSectionsInDocumentation()=0
virtual void insertMember(MemberDef *)=0
virtual void sortAllMembersList()=0
virtual void mergeMembers()=0
virtual void setIsStatic(bool b)=0
virtual void addMembersToTemplateInstance(const ClassDef *cd, const ArgumentList &templateArguments, const DString &templSpec)=0
virtual void insertSubClass(ClassDef *, Protection p, Specifier s, const DString &t=DString())=0
virtual void addUsedByClass(ClassDef *cd, const DString &accessName, Protection prot)=0
virtual void setSubGrouping(bool enabled)=0
virtual void setRequiresClause(const DString &req)=0
virtual void insertBaseClass(ClassDef *, const DString &name, Protection p, Specifier s, const DString &t=DString())=0
virtual void setHasNamedVariable(bool b)=0
virtual void addDocPart(const DString &doc, int lineNr, size_t colNr)=0
virtual void addCodePart(const DString &code, int lineNr, size_t colNr)=0
virtual void setFileDef(FileDef *fd)=0
virtual void writeTagFile(TextStream &)=0
virtual void writeDocumentation(OutputList &ol)=0
virtual void setGroupId(int id)=0
virtual void setInitializer(const DString &init)=0
virtual void findSectionsInDocumentation()=0
virtual void setTemplateArguments(const ArgumentList &al)=0
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
void clear()
Definition dstring.h:214
DString & setNum(short n)
Definition dstring.h:552
void resize(size_t newlen)
Definition dstring.h:209
size_t rfind(char c, size_t pos=npos) const
Definition dstring.h:244
DString fill(char c, size_t len)
Fills a string with a predefined character.
Definition dstring.h:278
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
DString lower() const
Definition dstring.h:326
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
DString & replace(size_t index, size_t len, const char *s)
Definition dstring.cpp:154
DString substr(size_t pos=0, size_t count=npos) const
Returns a substring of length count starting at pos.
Definition dstring.h:223
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:178
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:686
bool findAndRemoveWord(const char *word)
removes occurrences of whole word from this string, while keeping internal spaces and reducing multip...
Definition dstring.cpp:660
DString right(size_t len) const
Definition dstring.h:311
size_t size() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:154
DString & prepend(const char *s)
Definition dstring.h:515
size_t find(char c, size_t pos=0) const
Definition dstring.h:239
DString & sprintf(const char *format,...)
Definition dstring.cpp:34
int toInt(bool *ok=nullptr, int base=10) const
Definition dstring.cpp:191
@ ExplicitSize
Definition dstring.h:131
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition dstring.h:337
DString left(size_t len) const
Definition dstring.h:306
const std::string & str() const
Definition dstring.h:645
bool stripPrefix(const DString &prefix)
Definition dstring.h:290
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157
bool startsWith(const char *s) const
Definition dstring.h:600
bool endsWith(const char *s) const
Definition dstring.h:617
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
@ ExtCmd
Definition debug.h:37
@ Sections
Definition debug.h:49
@ Time
Definition debug.h:36
@ Qhp
Definition debug.h:45
@ Entries
Definition debug.h:48
static void printFlags()
Definition debug.cpp:137
static void clearFlag(const DebugMask mask)
Definition debug.cpp:122
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Definition debug.h:78
static double elapsedTime()
Definition debug.cpp:200
static void startTimer()
Definition debug.cpp:195
static bool setFlagStr(const DString &label)
Definition debug.cpp:103
static void setFlag(const DebugMask mask)
Definition debug.cpp:117
The common base class of all entity definitions found in the sources.
Definition definition.h:77
virtual DString briefDescription(bool abbreviate=false) const =0
virtual DString inbodyFile() const =0
virtual int getEndBodyLine() const =0
virtual DString briefFile() const =0
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
virtual int docLine() const =0
virtual DString getDefFileName() const =0
virtual DString documentation() const =0
virtual bool isLinkable() const =0
virtual DString inbodyDocumentation() const =0
virtual int getDefLine() const =0
virtual DefType definitionType() const =0
virtual const DString & name() const =0
virtual const DString & localName() const =0
virtual int inbodyLine() const =0
virtual const FileDef * getBodyDef() const =0
virtual int briefLine() const =0
virtual bool hasDocumentation() const =0
virtual bool isLinkableInProject() const =0
virtual size_t getDefColumn() const =0
virtual bool isAnonymous() const =0
virtual DString displayName(bool includeScope=true) const =0
virtual DString qualifiedName() const =0
virtual bool isHidden() const =0
virtual DString anchor() const =0
virtual int getStartDefLine() const =0
virtual const GroupList & partOfGroups() const =0
virtual bool isArtificial() const =0
virtual Definition * getOuterScope() const =0
virtual DString docFile() const =0
virtual int getStartBodyLine() const =0
virtual bool isReference() const =0
virtual const Definition * findInnerCompound(const DString &name) const =0
virtual DString getOutputFileBase() const =0
virtual void mergeReferencedBy(const Definition *other)=0
virtual void setName(const DString &name)=0
virtual void setExported(bool b)=0
virtual void setBodySegment(int defLine, int bls, int ble)=0
virtual void setHidden(bool b)=0
virtual void setReference(const DString &r)=0
virtual void mergeReferences(const Definition *other)=0
virtual void setInbodyDocumentation(const DString &d, const DString &docFile, int docLine)=0
virtual void setDocumentation(const DString &d, const DString &docFile, int docLine, bool stripWhiteSpace=true)=0
virtual void addInnerCompound(Definition *d)=0
virtual void setDefFile(const DString &df, int defLine, size_t defColumn)=0
virtual void addSectionsToDefinition(const std::vector< const SectionInfo * > &anchorList)=0
virtual void setLanguage(SrcLangExt lang)=0
virtual void setOuterScope(Definition *d)=0
virtual void setArtificial(bool b)=0
virtual void setBriefDescription(const DString &b, const DString &briefFile, int briefLine)=0
virtual void makePartOfGroup(GroupDef *gd)=0
virtual void setBodyDef(const FileDef *fd)=0
virtual void setRequirementReferences(const RequirementRefs &rqli)=0
virtual void setId(const DString &name)=0
virtual void setRefItems(const RefItemVector &sli)=0
virtual void computeTooltip()=0
A model of a directory symbol.
Definition dirdef.h:108
virtual void overrideDirectoryGraph(bool e)=0
Class representing a directory in the file system.
Definition dir.h:73
static std::string currentDirPath()
Definition dir.cpp:347
std::string absPath() const
Definition dir.cpp:369
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:300
void setPath(const std::string &path)
Definition dir.cpp:234
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:319
DirIterator iterator() const
Definition dir.cpp:244
static std::string cleanDirPath(const std::string &path)
Definition dir.cpp:362
static bool setCurrent(const std::string &path)
Definition dir.cpp:355
bool exists() const
Definition dir.cpp:262
A linked map of directories.
Definition dirdef.h:173
A class that generates docset files.
Definition docsets.h:35
static void init()
bool run()
Definition dot.cpp:119
static DotManager * instance()
Definition dot.cpp:78
static NamespaceLinkedMap * namespaceLinkedMap
Definition doxygen.h:108
static ConceptLinkedMap * conceptLinkedMap
Definition doxygen.h:90
static bool suppressDocWarnings
Definition doxygen.h:123
static FileNameLinkedMap * plantUmlFileNameLinkedMap
Definition doxygen.h:102
static bool parseSourcesNeeded
Definition doxygen.h:116
static StringUnorderedSet inputPaths
Definition doxygen.h:96
static std::unique_ptr< PageDef > mainPage
Definition doxygen.h:93
static bool clangAssistedParsing
Definition doxygen.h:129
static StringUnorderedSet expandAsDefinedSet
Definition doxygen.h:112
static FileNameLinkedMap * inputNameLinkedMap
Definition doxygen.h:97
static DString filterDBFileName
Definition doxygen.h:124
static ParserManager * parserManager
Definition doxygen.h:122
static InputFileEncodingList inputFileEncodingList
Definition doxygen.h:131
static DString verifiedDotPath
Definition doxygen.h:130
static ClassLinkedMap * classLinkedMap
Definition doxygen.h:88
static MemberNameLinkedMap * functionNameLinkedMap
Definition doxygen.h:105
static PageLinkedMap * exampleLinkedMap
Definition doxygen.h:91
static FileNameLinkedMap * dotFileNameLinkedMap
Definition doxygen.h:99
static NamespaceDefMutable * globalScope
Definition doxygen.h:114
static FileNameLinkedMap * imageNameLinkedMap
Definition doxygen.h:98
static FileNameLinkedMap * mscFileNameLinkedMap
Definition doxygen.h:100
static FileNameLinkedMap * mermaidFileNameLinkedMap
Definition doxygen.h:103
static MemberGroupInfoMap memberGroupInfoMap
Definition doxygen.h:111
static IndexList * indexList
Definition doxygen.h:125
static StaticInitMap staticInitMap
Definition doxygen.h:134
static StringMap tagDestinationMap
Definition doxygen.h:109
static std::mutex countFlowKeywordsMutex
Definition doxygen.h:132
static ClassLinkedMap * hiddenClassLinkedMap
Definition doxygen.h:89
static FileNameLinkedMap * diaFileNameLinkedMap
Definition doxygen.h:101
static DString spaces
Definition doxygen.h:126
static PageLinkedMap * pageLinkedMap
Definition doxygen.h:92
static bool generatingXmlOutput
Definition doxygen.h:127
static std::unique_ptr< NamespaceDef > globalNamespaceDef
Definition doxygen.h:113
static DString htmlFileExtension
Definition doxygen.h:115
static DefinesPerFileList macroDefinitions
Definition doxygen.h:128
static DirLinkedMap * dirLinkedMap
Definition doxygen.h:120
static NamespaceAliasInfoMap namespaceAliasMap
Definition doxygen.h:106
static MemberNameLinkedMap * memberNameLinkedMap
Definition doxygen.h:104
static SymbolMap< Definition > * symbolMap
Definition doxygen.h:118
static StringUnorderedSet tagFileSet
Definition doxygen.h:110
static FileNameLinkedMap * includeNameLinkedMap
Definition doxygen.h:94
static FileNameLinkedMap * exampleNameLinkedMap
Definition doxygen.h:95
static SearchIndexIntf searchIndex
Definition doxygen.h:117
static DirRelationLinkedMap dirRelations
Definition doxygen.h:121
static std::mutex addExampleMutex
Definition doxygen.h:133
static ClangUsrMap * clangUsrMap
Definition doxygen.h:119
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:107
Generator for Eclipse help files.
Definition eclipsehelp.h:42
static EmojiEntityMapper & instance()
Returns the one and only instance of the Emoji entity mapper.
Definition emoji.cpp:1981
void writeEmojiFile(TextStream &t)
Writes the list of supported emojis to the given file.
Definition emoji.cpp:2002
Represents an unstructured piece of information, about an entity found in the sources.
Definition entry.h:115
TextStream initializer
initial value (for variables)
Definition entry.h:197
VhdlSpecifier vhdlSpec
VHDL specifiers.
Definition entry.h:182
bool subGrouping
automatically group class members?
Definition entry.h:187
RequirementRefs rqli
references to requirements
Definition entry.h:227
const std::vector< std::shared_ptr< Entry > > & children() const
Definition entry.h:138
bool proto
prototype ?
Definition entry.h:186
GroupDocType groupDocType
Definition entry.h:231
int docLine
line number at which the documentation was found
Definition entry.h:201
DString includeName
include name (3 arg of \class)
Definition entry.h:199
DString bitfields
member's bit fields
Definition entry.h:192
ArgumentList typeConstr
where clause (C#) for type constraints
Definition entry.h:215
void markAsProcessed() const
Definition entry.h:166
int endBodyLine
line number where the definition ends
Definition entry.h:218
DString write
property write accessor
Definition entry.h:212
bool exported
is the symbol exported from a C++20 module
Definition entry.h:188
const TagInfo * tagInfo() const
Definition entry.h:176
DString includeFile
include file (2 arg of \class, must be unique)
Definition entry.h:198
DString fileName
file this entry was extracted from
Definition entry.h:223
ArgumentLists tArgLists
template argument declarations
Definition entry.h:195
DString docFile
file in which the documentation was found
Definition entry.h:202
LocalToc localToc
Definition entry.h:233
MethodTypes mtype
signal, slot, (dcop) method, or property?
Definition entry.h:180
@ GROUPDOC_NORMAL
defgroup
Definition entry.h:120
DString args
member argument string
Definition entry.h:191
SrcLangExt lang
programming language in which this entry was found
Definition entry.h:228
Entry * parent() const
Definition entry.h:133
DString inside
name of the class in which documents are found
Definition entry.h:213
DString doc
documentation block (partly parsed)
Definition entry.h:200
DString req
C++20 requires clause.
Definition entry.h:235
bool explicitExternal
explicitly defined as external?
Definition entry.h:185
DString brief
brief description (doc block)
Definition entry.h:203
std::vector< const SectionInfo * > anchors
list of anchors defined in this entry
Definition entry.h:222
RelatesType relatesType
how relates is handled
Definition entry.h:210
std::vector< Grouping > groups
list of groups this entry belongs to
Definition entry.h:221
CommandOverrides commandOverrides
store info for commands whose default can be overridden
Definition entry.h:189
int startLine
start line of entry in the source
Definition entry.h:224
size_t startColumn
start column of entry in the source
Definition entry.h:225
ArgumentList argList
member arguments as a list
Definition entry.h:194
DString type
member type
Definition entry.h:172
int inbodyLine
line number at which the body doc was found
Definition entry.h:207
EntryType section
entry type (see Sections);
Definition entry.h:171
int bodyLine
line number of the body in the source
Definition entry.h:216
DString exception
throw specification
Definition entry.h:214
DString relates
related class (doc block)
Definition entry.h:209
int mGrpId
member group id
Definition entry.h:219
std::vector< BaseInfo > extends
list of base classes
Definition entry.h:220
DString inbodyFile
file in which the body doc was found
Definition entry.h:208
Specifier virt
virtualness of the entry
Definition entry.h:190
DString metaData
Slice metadata.
Definition entry.h:234
std::vector< std::string > qualifiers
qualifiers specified with the qualifier command
Definition entry.h:236
DString name
member name
Definition entry.h:173
RefItemVector sli
special lists (test/todo/bug/deprecated/..) this entry is in
Definition entry.h:226
Protection protection
class protection
Definition entry.h:179
bool artificial
Artificially introduced item.
Definition entry.h:230
bool hidden
does this represent an entity that is hidden from the output
Definition entry.h:229
DString inbodyDocs
documentation inside the body of a function
Definition entry.h:206
int briefLine
line number at which the brief desc. was found
Definition entry.h:204
FileDef * fileDef() const
Definition entry.h:168
DString id
libclang id
Definition entry.h:232
int initLines
define/variable initializer lines to show
Definition entry.h:183
bool isStatic
static ?
Definition entry.h:184
TypeSpecifier spec
class/member specifiers
Definition entry.h:181
DString briefFile
file in which the brief desc. was found
Definition entry.h:205
DString read
property read accessor
Definition entry.h:211
Wrapper class for the Entry type.
Definition types.h:859
constexpr bool isCompoundDoc() const noexcept
Definition types.h:869
constexpr bool isFile() const noexcept
Definition types.h:868
constexpr bool isDoc() const noexcept
Definition types.h:870
ENTRY_TYPES constexpr bool isCompound() const noexcept
Definition types.h:866
std::string to_string() const
Definition types.h:871
static EntryType guessSection(const DString &name)
Definition types.cpp:22
constexpr bool isScope() const noexcept
Definition types.h:867
A class that generates a dynamic tree view side panel.
Definition ftvhelp.h:41
A model of a file symbol.
Definition filedef.h:97
virtual void addUsingDeclaration(const Definition *d)=0
virtual void removeMember(MemberDef *md)=0
virtual void insertClass(ClassDef *cd)=0
virtual void setDiskName(const DString &name)=0
virtual void insertConcept(ConceptDef *cd)=0
virtual void overrideIncludeGraph(bool e)=0
virtual void writeSourceHeader(OutputList &ol)=0
virtual bool generateSourceFile() const =0
virtual DString absFilePath() const =0
virtual const DString & docName() const =0
virtual const LinkedRefMap< NamespaceDef > & getUsedNamespaces() const =0
virtual bool isSource() const =0
virtual void parseSource(ClangTUParser *clangParser)=0
virtual void getAllIncludeFilesRecursively(StringVector &incFiles) const =0
virtual void writeSourceFooter(OutputList &ol)=0
virtual void writeSourceBody(OutputList &ol, ClangTUParser *clangParser)=0
virtual void addUsingDirective(NamespaceDef *nd)=0
virtual void overrideIncludedByGraph(bool e)=0
virtual void insertMember(MemberDef *md)=0
virtual void insertNamespace(NamespaceDef *nd)=0
Minimal replacement for QFileInfo.
Definition fileinfo.h:26
std::string readLink() const
Definition fileinfo.cpp:89
bool isRelative() const
Definition fileinfo.cpp:63
bool isSymLink() const
Definition fileinfo.cpp:82
bool exists() const
Definition fileinfo.cpp:35
bool match(const PatternList &patList, bool caseSenseNames, PatternElem *elem=nullptr, PatternGet getter=[](const std::string &s){ return s;}) const
Match the file name against a list of patterns.
Definition fileinfo.h:60
std::string fileName() const
Definition fileinfo.cpp:123
bool isReadable() const
Definition fileinfo.cpp:49
bool isDir() const
Definition fileinfo.cpp:75
bool isFile() const
Definition fileinfo.cpp:68
std::string dirPath(bool absPath=true) const
Definition fileinfo.cpp:142
std::string absFilePath() const
Definition fileinfo.cpp:106
Class representing all files with a certain base name.
Definition filename.h:31
Ordered dictionary of FileName objects.
Definition filename.h:70
DString showFileDefMatches(const DString &n) const
Returns a list of file definitions in fnMap that match the file name n.
Definition filename.cpp:131
FileDef * findFileDef(const DString &n, bool &ambig) const
Returns the file definition in fnMap that matches the file name n.
Definition filename.cpp:38
bool hasFormulas() const
Definition formula.cpp:720
void initFromRepository(const DString &dir)
Definition formula.cpp:60
void checkRepositories()
Definition formula.cpp:173
static FormulaManager & instance()
Definition formula.cpp:54
void generateImages(const DString &outputDir, bool toIndex, Format format, HighDPI hd=HighDPI::Off)
Definition formula.cpp:635
A model of a group of symbols.
Definition groupdef.h:48
virtual DString groupTitle() const =0
virtual void overrideGroupGraph(bool e)=0
virtual bool addClass(ClassDef *def)=0
virtual bool containsFile(const FileDef *def) const =0
virtual bool addNamespace(NamespaceDef *def)=0
virtual void setGroupScope(Definition *d)=0
virtual void addFile(FileDef *def)=0
virtual void setGroupTitle(const DString &newtitle)=0
virtual MemberList * getMemberList(MemberListType lt) const =0
virtual bool hasGroupTitle() const =0
Generator for HTML output.
Definition htmlgen.h:93
static void writeSearchData(const DString &dir)
Definition htmlgen.cpp:1461
static void init()
Definition htmlgen.cpp:1281
static void writeSearchPage()
Definition htmlgen.cpp:3291
static void writeHeaderFile(TextStream &t, const DString &cssname)
Definition htmlgen.cpp:1629
static void writeFooterFile(TextStream &t)
Definition htmlgen.cpp:1635
static void writeTabData()
Additional initialization after indices have been created.
Definition htmlgen.cpp:1445
static void writeExternalSearchPage()
Definition htmlgen.cpp:3390
static void writeStyleSheetFile(TextStream &t)
Definition htmlgen.cpp:1623
A class that generated the HTML Help specific files.
Definition htmlhelp.h:37
static const DString hhpFileName
Definition htmlhelp.h:90
static Index & instance()
Definition index.cpp:112
void countDataStructures()
Definition index.cpp:270
A list of index interfaces.
Definition indexlist.h:65
void initialize()
Definition indexlist.h:101
void addIndexItem(const Definition *context, const MemberDef *md, const DString &sectionAnchor=DString(), const DString &title=DString())
Definition indexlist.h:118
void addIndex(As &&... args)
Add an index generator to the list, using a syntax similar to std::make_unique<T>().
Definition indexlist.h:98
void addImageFile(const DString &name)
Definition indexlist.h:124
void finalize()
Definition indexlist.h:104
Generator for LaTeX output.
Definition latexgen.h:96
static void writeFooterFile(TextStream &t)
Definition latexgen.cpp:696
static void writeStyleSheetFile(TextStream &t)
Definition latexgen.cpp:702
static void writeHeaderFile(TextStream &t)
Definition latexgen.cpp:690
static void init()
Definition latexgen.cpp:632
void parse(const DString &fileName, const char *data=nullptr)
Parses a user provided layout.
Definition layout.cpp:1509
static LayoutDocManager & instance()
Returns a reference to this singleton.
Definition layout.cpp:1476
void clear()
Definition linkedmap.h:212
std::unique_ptr< RefList > Ptr
Definition linkedmap.h:38
size_t size() const
Definition linkedmap.h:210
T * add(const char *k, Args &&... args)
Definition linkedmap.h:90
const T * find(const std::string &key) const
Definition linkedmap.h:47
Container class representing a vector of objects with keys.
Definition linkedmap.h:232
const T * find(const std::string &key) const
Definition linkedmap.h:243
bool empty() const
Definition linkedmap.h:374
Generator for Man page output.
Definition mangen.h:69
static void init()
Definition mangen.cpp:275
A model of a class/file/namespace member symbol.
Definition memberdef.h:45
virtual DString requiresClause() const =0
virtual bool isFriend() const =0
virtual DString argsString() const =0
virtual bool isForeign() const =0
virtual bool isRelated() const =0
virtual DString definition() const =0
virtual const ClassDef * getCachedTypedefVal() const =0
virtual const ClassDef * getClassDef() const =0
virtual DString excpString() const =0
virtual const ArgumentList & templateArguments() const =0
virtual const DString & initializer() const =0
virtual GroupDef * getGroupDef()=0
virtual bool isCSharpProperty() const =0
virtual bool isTypedef() const =0
virtual const MemberVector & enumFieldList() const =0
virtual void moveTo(Definition *)=0
virtual const FileDef * getFileDef() const =0
virtual const ArgumentList & argumentList() const =0
virtual bool isStrongEnumValue() const =0
virtual VhdlSpecifier getVhdlSpecifiers() const =0
virtual bool isFunction() const =0
virtual bool isExternal() const =0
virtual int getMemberGroupId() const =0
virtual DString bitfieldString() const =0
virtual bool isStatic() const =0
virtual const MemberDef * reimplements() const =0
virtual StringVector getQualifiers() const =0
virtual bool isTypedefValCached() const =0
virtual bool isDocsForDefinition() const =0
virtual bool isDefine() const =0
virtual const NamespaceDef * getNamespaceDef() const =0
virtual bool isObjCProperty() const =0
virtual Protection protection() const =0
virtual TypeSpecifier getMemberSpecifiers() const =0
virtual bool isEnumerate() const =0
virtual MemberType memberType() const =0
virtual ClassDef * relatedAlso() const =0
virtual bool isVariable() const =0
virtual bool isStrong() const =0
virtual DString typeString() const =0
virtual Specifier virtualness(int count=0) const =0
virtual int redefineCount() const =0
virtual int initializerLines() const =0
virtual const MemberDef * getEnumScope() const =0
virtual bool isEnumValue() const =0
virtual bool isPrototype() const =0
virtual void setRequiresClause(const DString &req)=0
virtual void setClassDefOfAnonymousType(const ClassDef *cd)=0
virtual void setMemberClass(ClassDef *cd)=0
virtual void setProtection(Protection p)=0
virtual void setDefinition(const DString &d)=0
virtual void setMemberGroupId(int id)=0
virtual void setDocumentedEnumValues(bool value)=0
virtual void setMemberSpecifiers(TypeSpecifier s)=0
virtual ClassDefMutable * getClassDefMutable()=0
virtual void setArgsString(const DString &as)=0
virtual void setEnumScope(MemberDef *md, bool livesInsideEnum=false)=0
virtual void setDefinitionTemplateParameterLists(const ArgumentLists &lists)=0
virtual void invalidateTypedefValCache()=0
virtual void setVhdlSpecifiers(VhdlSpecifier s)=0
virtual void setEnumClassScope(ClassDef *cd)=0
virtual void setInitializer(const DString &i)=0
virtual void setMaxInitLines(int lines)=0
virtual void setInheritsDocsFrom(const MemberDef *md)=0
virtual void setFileDef(FileDef *fd)=0
virtual void setPrototype(bool p, const DString &df, int line, size_t column)=0
virtual void setRelatedAlso(ClassDef *cd)=0
virtual void setAnonymousMemberForDeclaration(const MemberDef *md)=0
virtual void overrideReferencesRelation(bool e)=0
virtual void setAnonymousMemberForDetails(const MemberDef *md)=0
virtual void makeForeign()=0
virtual void overrideReferencedByRelation(bool e)=0
virtual void setDocsForDefinition(bool b)=0
virtual void overrideCallGraph(bool e)=0
virtual void overrideInlineSource(bool e)=0
virtual void setBitfields(const DString &s)=0
virtual void copyArgumentNames(const MemberDef *bmd)=0
virtual void overrideEnumValues(bool e)=0
virtual void mergeMemberSpecifiers(TypeSpecifier s)=0
virtual void addQualifiers(const StringVector &qualifiers)=0
virtual void setExplicitExternal(bool b, const DString &df, int line, size_t column)=0
virtual void insertEnumField(MemberDef *md)=0
virtual void moveDeclArgumentList(std::unique_ptr< ArgumentList > al)=0
virtual void setDeclFile(const DString &df, int line, size_t column)=0
virtual void setAnonymousEnumType(const MemberDef *md)=0
virtual void overrideCallerGraph(bool e)=0
virtual void setReimplements(MemberDef *md)=0
virtual void invalidateCachedArgumentTypes()=0
virtual void setNamespace(NamespaceDef *nd)=0
virtual void moveArgumentList(std::unique_ptr< ArgumentList > al)=0
virtual void makeRelated()=0
virtual void insertReimplementedBy(MemberDef *md)=0
virtual void setAnchor()=0
A list of MemberDef objects as shown in documentation sections.
Definition memberlist.h:126
Wrapper class for the MemberListType type.
Definition types.h:346
Ptr & front()
Definition membername.h:49
size_t size() const
Definition membername.h:46
iterator begin()
Definition membername.h:35
iterator end()
Definition membername.h:36
void push_back(Ptr &&p)
Definition membername.h:52
Ordered dictionary of MemberName objects.
Definition membername.h:61
MemberName::Ptr take(const DString &key, const MemberDef *value)
Definition membername.h:63
const MemberDef * findRev(const DString &name) const
Definition memberlist.h:107
const MemberDef * find(const DString &name) const
Definition memberlist.h:94
void run()
Run mmdc tool for all collected diagrams.
Definition mermaid.cpp:255
static MermaidManager & instance()
Definition mermaid.cpp:38
void sortMemberLists()
static ModuleManager & instance()
void addDocs(const Entry *root)
void addConceptToModule(const Entry *root, ConceptDef *cd)
void addClassToModule(const Entry *root, ClassDef *cd)
void addMemberToModule(const Entry *root, MemberDef *md)
void writeDocumentation(OutputList &ol)
void addMembersToMemberGroup()
void findSectionsInDocumentation()
void distributeMemberGroupDocumentation()
An abstract interface of a namespace symbol.
virtual const LinkedRefMap< NamespaceDef > & getUsedNamespaces() const =0
virtual bool isInline() const =0
virtual void insertUsedFile(FileDef *fd)=0
virtual void findSectionsInDocumentation()=0
virtual void countMembers()=0
virtual void addUsingDirective(NamespaceDef *nd)=0
virtual void setFileName(const DString &fn)=0
virtual void insertMember(MemberDef *md)=0
virtual void setMetaData(const DString &m)=0
virtual void addUsingDeclaration(const Definition *d)=0
virtual void distributeMemberGroupDocumentation()=0
virtual void writeTagFile(TextStream &)=0
virtual void writeDocumentation(OutputList &ol)=0
virtual void setInline(bool isInline)=0
virtual void computeAnchors()=0
virtual void combineUsingRelations(NamespaceDefSet &visitedNamespace)=0
virtual void sortMemberLists()=0
virtual void addMembersToMemberGroup()=0
/dev/null outline parser
void parseInput(const DString &, const char *, const std::shared_ptr< Entry > &, ClangTUParser *) override
Parses a single input file with the goal to build an Entry tree.
void parsePrototype(const DString &) override
Callback function called by the comment block scanner.
bool needsPreprocessing(const DString &) const override
Returns true if the language identified by extension needs the C preprocessor to be run before feed t...
Abstract interface for outline parsers.
Definition parserintf.h:41
virtual bool needsPreprocessing(const DString &extension) const =0
Returns true if the language identified by extension needs the C preprocessor to be run before feed t...
virtual void parseInput(const DString &fileName, const char *fileBuf, const std::shared_ptr< Entry > &root, ClangTUParser *clangParser)=0
Parses a single input file with the goal to build an Entry tree.
Class representing a list of output generators that are written to in parallel.
Definition outputlist.h:311
void disable(OutputType o)
void add()
Definition outputlist.h:348
void enable(OutputType o)
size_t size() const
Definition outputlist.h:357
void docify(const DString &s)
Definition outputlist.h:433
void writeStyleInfo(int part)
Definition outputlist.h:391
void generateDoc(const DString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const DString &docStr, const DocOptions &options)
void cleanup()
Definition outputlist.h:748
void startContents()
Definition outputlist.h:614
A model of a page symbol.
Definition pagedef.h:27
virtual void setLocalToc(const LocalToc &tl)=0
virtual void setFileName(const DString &name)=0
virtual void setShowLineNo(bool)=0
virtual void setPageScope(Definition *)=0
virtual const GroupDef * getGroupDef() const =0
Manages programming language parsers.
Definition parserintf.h:182
std::unique_ptr< CodeParserInterface > getCodeParser(const DString &extension)
Gets the interface to the parser associated with a given extension.
Definition parserintf.h:253
void registerParser(const DString &name, const OutlineParserFactory &outlineParserFactory, const CodeParserFactory &codeParserFactory)
Registers an additional parser.
Definition parserintf.h:215
std::unique_ptr< OutlineParserInterface > getOutlineParser(const DString &extension)
Gets the interface to the parser associated with a given extension.
Definition parserintf.h:244
static PlantumlManager & instance()
Definition plantuml.cpp:236
void run()
Run plant UML tool for all images.
Definition plantuml.cpp:432
void processFile(const DString &fileName, const std::string &input, std::string &output)
Definition pre.l:4410
void addSearchDir(const DString &dir)
Definition pre.l:4392
Definition qhp.h:29
static DString getQchFileName()
Definition qhp.cpp:430
static const DString qhpFileName
Definition qhp.h:49
Generator for RTF output.
Definition rtfgen.h:80
static void init()
Definition rtfgen.cpp:464
static bool preProcessFileInplace(const DString &path, const DString &name)
This is an API to a VERY brittle RTF preprocessor that combines nested RTF files.
Definition rtfgen.cpp:2468
static void writeStyleSheetFile(TextStream &t)
Definition rtfgen.cpp:397
static void writeExtensionsFile(TextStream &t)
Definition rtfgen.cpp:412
static RefListManager & instance()
Definition reflist.h:122
static RequirementManager & instance()
void writeTagFile(TextStream &tagFile)
void addRequirement(Entry *e)
Abstract proxy interface for non-javascript based search indices.
void addWord(const DString &word, bool hiPriority)
void setCurrentDoc(const Definition *ctx, const DString &anchor, bool isSourceFile)
void write(const DString &file)
class that provide information about a section.
Definition section.h:58
DString fileName() const
Definition section.h:74
int lineNr() const
Definition section.h:73
DString ref() const
Definition section.h:72
SectionInfo * replace(const DString &label, const DString &fileName, int lineNr, const DString &title, SectionType type, int level, const DString &ref=DString())
Definition section.h:157
SectionInfo * add(const SectionInfo &si)
Definition section.h:139
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:179
static constexpr int Page
Definition section.h:31
std::vector< stat > stats
Definition doxygen.cpp:273
void print()
Definition doxygen.cpp:250
void begin(const char *name)
Definition doxygen.cpp:237
void end()
Definition doxygen.cpp:243
std::chrono::steady_clock::time_point startTime
Definition doxygen.cpp:274
static void showCacheUsage()
Show usage of the type lookup cache.
static void clearTypeLookupCache(ClearScope scope)
ClassDefMutable * resolveClassMutable(const Definition *scope, const DString &name, bool mayBeUnlinkable=false, bool mayBeHidden=false)
Wrapper around resolveClass that returns a mutable interface to the class object or a nullptr if the ...
const ClassDef * resolveClass(const Definition *scope, const DString &name, bool maybeUnlinkable=false, bool mayBeHidden=false)
Find the class definition matching name within the scope set.
const Definition * resolveSymbol(const Definition *scope, const DString &name, const DString &args=DString(), bool checkCV=false, bool insideCode=false, bool onlyLinkable=false)
Find the symbool definition matching name within the scope set.
DString getTemplateSpec() const
In case a call to resolveClass() points to a template specialization, the template part is return via...
const MemberDef * getTypedef() const
In case a call to resolveClass() resolves to a type member (e.g. an enum) this method will return it.
This struct is used to capture the tag file information for an Entry.
Definition entry.h:101
DString tagName
Definition entry.h:103
DString fileName
Definition entry.h:104
Text streaming class that buffers data.
Definition textstream.h:36
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:232
Class managing a pool of worker threads.
Definition threadpool.h:48
auto queue(F &&f, Args &&... args) -> std::future< decltype(f(args...))>
Queue the callable function f for the threads to execute.
Definition threadpool.h:77
virtual DString trOverloadText()=0
virtual DString trPage(bool first_capital, bool singular)=0
virtual DString trMainPage()=0
Wrapper class for a number of boolean properties.
Definition types.h:696
std::string to_string() const
Definition types.h:740
static void correctMemberProperties(MemberDefMutable *md)
static void computeVhdlComponentRelations()
ClassDefMutable * toClassDefMutable(Definition *d)
ClassDef * getClass(const DString &n)
std::unique_ptr< ClassDef > createClassDefAlias(const Definition *newScope, const ClassDef *cd)
Definition classdef.cpp:817
std::unique_ptr< ClassDef > createClassDef(const DString &fileName, int startLine, size_t startColumn, const DString &name, ClassDef::CompoundType ct, const DString &ref, const DString &fName, bool isSymbol, bool isJavaEnum)
Factory method to create a new ClassDef object.
Definition classdef.cpp:584
ClassDef * toClassDef(Definition *d)
std::unordered_set< const ClassDef * > ClassDefSet
Definition classdef.h:91
std::map< std::string, int > TemplateNameMap
Definition classdef.h:89
ClassDefMutable * getClassMutable(const DString &key)
Definition classdef.h:469
Class representing a regular expression.
Definition regex.h:39
Class to iterate through matches.
Definition regex.h:245
Object representing the matching results.
Definition regex.h:160
First pass comment processing.
void convertCppComments(const std::string &inBuf, std::string &outBuf, const std::string &fn)
Converts the comments in a file.
ConceptDefMutable * toConceptDefMutable(Definition *d)
std::unique_ptr< ConceptDef > createConceptDef(const DString &fileName, int startLine, size_t startColumn, const DString &name, const DString &tagRef, const DString &tagFile)
ConceptDefMutable * getConceptMutable(const DString &key)
Definition conceptdef.h:106
#define Config_getInt(name)
Definition config.h:34
#define Config_getList(name)
Definition config.h:38
#define Config_updateString(name, value)
Definition config.h:39
#define Config_updateBool(name, value)
Definition config.h:40
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
#define Config_updateList(name,...)
Definition config.h:43
#define Config_getEnum(name)
Definition config.h:35
std::set< std::string > StringSet
Definition containers.h:31
std::unordered_set< std::string > StringUnorderedSet
Definition containers.h:29
std::map< std::string, std::string > StringMap
Definition containers.h:30
std::vector< std::string > StringVector
Definition containers.h:33
void parseFuncDecl(const DString &decl, const SrcLangExt lang, DString &clName, DString &type, DString &name, DString &args, DString &funcTempList, DString &exceptions)
Definition declinfo.l:330
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const DString &argsString, DString *extraTypeChars=nullptr)
Definition defargs.l:822
void generateDEF()
Definition defgen.cpp:463
std::unordered_map< std::string, DefineList > DefinesPerFileList
Definition define.h:50
Definition * toDefinition(DefinitionMutable *dm)
DefinitionMutable * toDefinitionMutable(Definition *d)
DirIterator begin(DirIterator it) noexcept
Definition dir.cpp:175
DirIterator end(const DirIterator &) noexcept
Definition dir.cpp:180
void buildDirectories()
Definition dirdef.cpp:1099
void computeDirDependencies()
Definition dirdef.cpp:1173
void generateDirDocs(OutputList &ol)
Definition dirdef.cpp:1190
#define AUTO_TRACE_ADD(...)
Definition docnode.cpp:54
#define AUTO_TRACE(...)
Definition docnode.cpp:53
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:55
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Definition docnode.h:1335
static void findInheritedTemplateInstances()
Definition doxygen.cpp:5557
void printNavTree(Entry *root, int indent)
static void addClassToContext(const Entry *root)
Definition doxygen.cpp:954
static void makeTemplateInstanceRelation(const Entry *root, ClassDefMutable *cd)
Definition doxygen.cpp:5572
static StringUnorderedSet g_pathsVisited(1009)
static void buildGroupList(const Entry *root)
Definition doxygen.cpp:540
static void insertMemberAlias(Definition *outerScope, const MemberDef *md)
Definition doxygen.cpp:6954
static void findUsingDeclarations(const Entry *root, bool filterPythonPackages)
Definition doxygen.cpp:2330
static void flushCachedTemplateRelations()
Definition doxygen.cpp:9745
static void copyLatexStyleSheet()
static void generateDocsForClassList(const std::vector< ClassDefMutable * > &classList)
Definition doxygen.cpp:9405
static int findFunctionPtr(const std::string &type, SrcLangExt lang, int *pLength=nullptr)
Definition doxygen.cpp:3174
static bool isSpecialization(const ArgumentLists &srcTempArgLists, const ArgumentLists &dstTempArgLists)
Definition doxygen.cpp:6243
static void computeTemplateClassRelations()
Definition doxygen.cpp:5651
static std::string resolveSymlink(const std::string &path)
void adjustConfiguration()
adjust globals that depend on configuration settings.
static void findDEV(const MemberNameLinkedMap &mnsd)
Definition doxygen.cpp:8420
static void runQHelpGenerator()
static void addConceptToContext(const Entry *root)
Definition doxygen.cpp:1179
static void addRelatedPage(Entry *root)
Definition doxygen.cpp:436
void initDoxygen()
static StringVector g_inputFiles
Definition doxygen.cpp:191
void printSectionsTree()
class Statistics g_s
static void generateXRefPages()
Definition doxygen.cpp:5830
static Definition * buildScopeFromQualifiedName(const DString &name_, SrcLangExt lang, const TagInfo *tagInfo)
Definition doxygen.cpp:724
static void findUsingDeclImports(const Entry *root)
Definition doxygen.cpp:2483
static void copyStyleSheet()
static void addIncludeFile(Def *def, FileDef *ifd, const Entry *root)
Definition doxygen.cpp:311
FindBaseClassRelation_Mode
Definition doxygen.cpp:290
@ Undocumented
Definition doxygen.cpp:293
@ TemplateInstances
Definition doxygen.cpp:291
@ DocumentedOnly
Definition doxygen.cpp:292
void distributeClassGroupRelations()
Definition doxygen.cpp:1515
static void generateGroupDocs()
static void findDirDocumentation(const Entry *root)
Definition doxygen.cpp:9945
void checkConfiguration()
check and resolve config options
static bool findClassRelation(const Entry *root, Definition *context, ClassDefMutable *cd, const BaseInfo *bi, const TemplateNameMap &templateNames, FindBaseClassRelation_Mode mode, bool isArtificial)
Definition doxygen.cpp:5158
static void resolveTemplateInstanceInType(const Entry *root, const Definition *scope, const MemberDef *md)
Definition doxygen.cpp:5088
static void organizeSubGroupsFiltered(const Entry *root, bool additional)
Definition doxygen.cpp:580
static void warnUndocumentedNamespaces()
Definition doxygen.cpp:5606
static TemplateNameMap getTemplateArgumentsInName(const ArgumentList &templateArguments, const std::string &name)
Definition doxygen.cpp:4767
static void buildConceptList(const Entry *root)
Definition doxygen.cpp:1340
static void addMemberSpecialization(const Entry *root, MemberName *mn, ClassDefMutable *cd, const DString &funcType, const DString &funcName, const DString &funcArgs, const DString &funcDecl, const DString &exceptions, TypeSpecifier spec)
Definition doxygen.cpp:6821
static void resolveClassNestingRelations()
Definition doxygen.cpp:1395
static void generateNamespaceConceptDocs(const ConceptLinkedRefMap &conceptList)
static MemberDef * addVariableToFile(const Entry *root, MemberType mtype, const DString &scope, const DString &type, const DString &name, const DString &args)
Definition doxygen.cpp:2921
static void findClassEntries(const Entry *root)
Definition doxygen.cpp:5522
static void vhdlCorrectMemberProperties()
Definition doxygen.cpp:8664
static void addMemberFunction(const Entry *root, MemberName *mn, const DString &scopeName, const DString &namespaceName, const DString &className, const DString &funcTyp, const DString &funcName, const DString &funcArgs, const DString &funcTempList, const DString &exceptions, const DString &type, const DString &args, bool isFriend, TypeSpecifier spec, const DString &relates, const DString &funcDecl, bool overloaded, bool isFunc)
Definition doxygen.cpp:6456
static void generateExampleDocs()
void generateOutput()
static void stopDoxygen(int)
static void substituteTemplatesInArgList(const ArgumentLists &srcTempArgLists, const ArgumentLists &dstTempArgLists, const ArgumentList &src, ArgumentList &dst)
Definition doxygen.cpp:6357
static void copyLogo(const DString &outputOption, bool toIndex)
static void computeMemberReferences()
Definition doxygen.cpp:5720
static void transferRelatedFunctionDocumentation()
Definition doxygen.cpp:4681
static void addMembersToMemberGroup()
Definition doxygen.cpp:9610
static void findMainPageTagFiles(Entry *root)
static void addLocalObjCMethod(const Entry *root, const DString &scopeName, const DString &funcType, const DString &funcName, const DString &funcArgs, const DString &exceptions, const DString &funcDecl, TypeSpecifier spec)
Definition doxygen.cpp:6401
static void distributeConceptGroups()
Definition doxygen.cpp:1362
static NamespaceDef * findUsedNamespace(const LinkedRefMap< NamespaceDef > &unl, const DString &name)
Definition doxygen.cpp:2160
static void transferFunctionDocumentation()
Definition doxygen.cpp:4600
static void setAnonymousEnumType()
Definition doxygen.cpp:9350
static void sortMemberLists()
Definition doxygen.cpp:9255
static void findMember(const Entry *root, const DString &relates, const DString &type, const DString &args, DString funcDecl, bool overloaded, bool isFunc)
Definition doxygen.cpp:6997
static void createTemplateInstanceMembers()
Definition doxygen.cpp:8832
void transferStaticInstanceInitializers()
Definition doxygen.cpp:4730
static void findObjCMethodDefinitions(const Entry *root)
Definition doxygen.cpp:7808
static void addMemberDocs(const Entry *root, MemberDefMutable *md, const DString &funcDecl, const ArgumentList *al, bool over_load, TypeSpecifier spec)
Definition doxygen.cpp:5844
static void dumpSymbolMap()
static void buildTypedefList(const Entry *root)
Definition doxygen.cpp:3666
static void findGroupScope(const Entry *root)
Definition doxygen.cpp:555
static void generateFileDocs()
Definition doxygen.cpp:9068
static int findEndOfTemplate(const DString &s, size_t startPos)
Definition doxygen.cpp:3377
static void findDefineDocumentation(Entry *root)
Definition doxygen.cpp:9858
static void findUsedClassesForClass(const Entry *root, Definition *context, ClassDefMutable *masterCd, ClassDefMutable *instanceCd, bool isArtificial, const ArgumentList *actualArgs=nullptr, const TemplateNameMap &templateNames=TemplateNameMap())
Definition doxygen.cpp:4830
void parseInput()
static void findMemberDocumentation(const Entry *root)
Definition doxygen.cpp:7778
static void distributeMemberGroupDocumentation()
Definition doxygen.cpp:9648
static void generateNamespaceClassDocs(const ClassLinkedRefMap &classList)
static void addEnumValuesToEnums(const Entry *root)
Definition doxygen.cpp:8012
static void generatePageDocs()
static void resolveUserReferences()
static void buildRequirementsList(Entry *root)
static void compareDoxyfile(Config::CompareMode diffList)
static void addPageToContext(PageDef *pd, Entry *root)
Definition doxygen.cpp:417
static std::shared_ptr< Entry > parseFile(OutlineParserInterface &parser, FileDef *fd, const DString &fn, ClangTUParser *clangParser, bool newTU)
static void buildVarList(const Entry *root)
Definition doxygen.cpp:3803
static void copyIcon(const DString &outputOption, bool toIndex)
static void buildSequenceList(const Entry *root)
Definition doxygen.cpp:3766
static void generateFileSources()
Definition doxygen.cpp:8902
static void copyExtraFiles(StringVector files, const DString &filesOption, const DString &outputOption, bool toIndex)
static void generateClassDocs()
Definition doxygen.cpp:9503
static int findTemplateSpecializationPosition(const DString &name)
Definition doxygen.cpp:5128
static void buildNamespaceList(const Entry *root)
Definition doxygen.cpp:1989
static void findIncludedUsingDirectives()
Definition doxygen.cpp:2733
static void addDefineDoc(const Entry *root, MemberDefMutable *md)
Definition doxygen.cpp:9831
static void countMembers()
Definition doxygen.cpp:9364
void clearAll()
Definition doxygen.cpp:205
static void devUsage()
static ClassDef * findClassWithinClassContext(Definition *context, ClassDef *cd, const DString &name)
Definition doxygen.cpp:4795
static void organizeSubGroups(const Entry *root)
Definition doxygen.cpp:599
static void applyMemberOverrideOptions(const Entry *root, MemberDefMutable *md)
Definition doxygen.cpp:2422
void searchInputFiles()
static void addOverloaded(const Entry *root, MemberName *mn, const DString &funcType, const DString &funcName, const DString &funcArgs, const DString &funcDecl, const DString &exceptions, TypeSpecifier spec)
Definition doxygen.cpp:6885
static void findFriends()
Definition doxygen.cpp:4503
static void findEnums(const Entry *root)
Definition doxygen.cpp:7836
static void generateConfigFile(const DString &configFile, bool shortList, bool updateOnly=false)
static DString g_commentFileName
Definition doxygen.cpp:196
static void dumpSymbol(TextStream &t, Definition *d)
static void addClassAndNestedClasses(std::vector< ClassDefMutable * > &list, ClassDefMutable *cd)
Definition doxygen.cpp:9480
static ClassDefMutable * createTagLessInstance(const Definition *root, const ClassDef *templ, const DString &fieldName, bool hasNamedVariable)
Definition doxygen.cpp:1576
static void addEnumDocs(const Entry *root, MemberDefMutable *md)
Definition doxygen.cpp:8260
static void addListReferences()
Definition doxygen.cpp:5821
static void exitDoxygen() noexcept
static bool findGlobalMember(const Entry *root, const DString &namespaceName, const DString &type, const DString &name, const DString &tempArg, const DString &, const DString &decl, TypeSpecifier)
Definition doxygen.cpp:6035
static bool isClassSection(const Entry *root)
Definition doxygen.cpp:5500
static void processTagLessClasses(const Definition *root, const Container *def, const TagContainer *tagParent, MemberListType varFilter, MemberListType typeFilter, const DString &prefix, int count)
Look through the members of class cd and its public members.
Definition doxygen.cpp:1901
static void buildGroupListFiltered(const Entry *root, bool additional, bool includeExternal)
Definition doxygen.cpp:467
static void runHtmlHelpCompiler()
static void addMembersToIndex()
Definition doxygen.cpp:8454
static bool g_dumpSymbolMap
Definition doxygen.cpp:195
static void version(const bool extended)
static OutputList * g_outputList
Definition doxygen.cpp:192
static DString extractClassName(const Entry *root)
Definition doxygen.cpp:5531
static void findMainPage(Entry *root)
static ClassDef::CompoundType convertToCompoundType(EntryType section, TypeSpecifier specifier)
Definition doxygen.cpp:908
DString stripTemplateSpecifiers(const DString &s)
Definition doxygen.cpp:697
static void findUsingDirectives(const Entry *root)
Definition doxygen.cpp:2173
static void addInterfaceOrServiceToServiceOrSingleton(const Entry *root, ClassDefMutable *cd, DString const &rname)
Definition doxygen.cpp:3835
static bool g_successfulRun
Definition doxygen.cpp:194
static bool tryAddEnumDocsToGroupMember(const Entry *root, const DString &name)
Definition doxygen.cpp:8302
static void addSourceReferences()
Definition doxygen.cpp:9128
static void associateVariableWithAnonymousEnumType(const MemberDef *md, const Container *cd, const MemberDef *enumTypeMember, MemberListType mlFilter)
Definition doxygen.cpp:1549
static void createUsingMemberImportForClass(const Entry *root, ClassDefMutable *cd, const MemberDef *md, const DString &fileName, const DString &memName)
Definition doxygen.cpp:2434
static DString substituteTemplatesInString(const ArgumentLists &srcTempArgLists, const ArgumentLists &dstTempArgLists, const std::string &src)
Definition doxygen.cpp:6273
std::function< std::unique_ptr< T >() > make_parser_factory()
static void buildExampleList(Entry *root)
static void inheritDocumentation()
Definition doxygen.cpp:9550
static void flushUnresolvedRelations()
Definition doxygen.cpp:9787
static bool isSymbolHidden(const Definition *d)
Definition doxygen.cpp:9297
void readConfiguration(int argc, char **argv)
static void readDir(FileInfo *fi, FileNameLinkedMap *fnMap, StringUnorderedSet *exclSet, const StringVector *patList, const StringVector *exclPatList, StringVector *resultList, StringUnorderedSet *resultSet, bool errorIfNotExist, bool recursive, StringUnorderedSet *killSet, StringUnorderedSet *paths)
static void findTemplateInstanceRelation(const Entry *root, Definition *context, ClassDefMutable *templateClass, const DString &templSpec, const TemplateNameMap &templateNames, bool isArtificial)
Definition doxygen.cpp:5037
static void findDocumentedEnumValues()
Definition doxygen.cpp:8446
static void findTagLessClasses()
Definition doxygen.cpp:1936
static void generateDiskNames()
static void addToIndices()
Definition doxygen.cpp:8496
static void computeClassRelations()
Definition doxygen.cpp:5626
static void buildFunctionList(const Entry *root)
Definition doxygen.cpp:4198
static void checkPageRelations()
static void addGlobalFunction(const Entry *root, const DString &rname, const DString &sc)
Definition doxygen.cpp:4088
static void findModuleDocumentation(const Entry *root)
Definition doxygen.cpp:1330
static MemberDef * addVariableToClass(const Entry *root, ClassDefMutable *cd, MemberType mtype, const DString &type, const DString &name, const DString &args, Protection prot, Relationship related)
Definition doxygen.cpp:2750
static void readTagFile(const std::shared_ptr< Entry > &root, const DString &tagLine)
static void findEnumDocumentation(const Entry *root)
Definition doxygen.cpp:8335
static void computePageRelations(Entry *root)
static void processTagLessClassesForList(const Definition *root, const Container *def, const TagContainer *tagParent, MemberListType varFilter, MemberListType typeFilter, const DString &prefix, int count)
Definition doxygen.cpp:1794
static void addMethodToClass(const Entry *root, ClassDefMutable *cd, const DString &rtype, const DString &rname, const DString &rargs, bool isFriend, Protection protection, bool stat, Specifier virt, TypeSpecifier spec, const DString &relates)
Definition doxygen.cpp:3951
void initResources()
static bool isVarWithConstructor(const Entry *root)
Definition doxygen.cpp:3234
static StringSet g_usingDeclarations
Definition doxygen.cpp:193
static void buildDictionaryList(const Entry *root)
Definition doxygen.cpp:3784
static bool haveEqualFileNames(const Entry *root, const MemberDef *md)
Definition doxygen.cpp:9820
void readFileOrDirectory(const DString &s, FileNameLinkedMap *fnMap, StringUnorderedSet *exclSet, const StringVector *patList, const StringVector *exclPatList, StringVector *resultList, StringUnorderedSet *resultSet, bool recursive, bool errorIfNotExist, StringUnorderedSet *killSet, StringUnorderedSet *paths)
static void generateNamespaceDocs()
static void computeMemberRelationsForBaseClass(const ClassDef *cd, const BaseClassDef *bcd, const ArgumentList *actualArgs)
Definition doxygen.cpp:8696
static void buildClassDocList(const Entry *root)
Definition doxygen.cpp:1165
static void buildPageList(Entry *root)
static void writeTagFile()
static void addRequirementReferences()
Definition doxygen.cpp:5813
static void computeVerifiedDotPath()
static bool g_singleComment
Definition doxygen.cpp:197
static void findSectionsInDocumentation()
Definition doxygen.cpp:9686
static void mergeCategories()
Definition doxygen.cpp:8851
static const StringUnorderedSet g_compoundKeywords
Definition doxygen.cpp:202
static bool scopeIsTemplate(const Definition *d)
Definition doxygen.cpp:6259
static void buildFileList(const Entry *root)
Definition doxygen.cpp:611
static void buildClassList(const Entry *root)
Definition doxygen.cpp:1155
static void usage(const DString &name, const DString &versionString)
static void findUsedTemplateInstances()
Definition doxygen.cpp:5590
static void computeTooltipTexts()
Definition doxygen.cpp:9304
static void addVariable(const Entry *root, int isFuncPtr=-1)
Definition doxygen.cpp:3445
void cleanUpDoxygen()
static void findBaseClassesForClass(const Entry *root, Definition *context, ClassDefMutable *masterCd, ClassDefMutable *instanceCd, FindBaseClassRelation_Mode mode, bool isArtificial, const ArgumentList *actualArgs=nullptr, const TemplateNameMap &templateNames=TemplateNameMap())
Definition doxygen.cpp:4986
static void parseFilesSingleThreading(const std::shared_ptr< Entry > &root)
parse the list of input files
static void buildCompleteMemberLists()
Definition doxygen.cpp:8872
static const ClassDef * findClassDefinition(FileDef *fd, NamespaceDef *nd, const DString &scopeName)
Definition doxygen.cpp:5996
static void filterMemberDocumentation(const Entry *root, const DString &relates)
Definition doxygen.cpp:7629
static void generateConceptDocs()
Definition doxygen.cpp:9529
static bool isRecursiveBaseClass(const DString &scope, const DString &name)
Definition doxygen.cpp:5117
static std::unique_ptr< OutlineParserInterface > getParserForFile(const DString &fn)
static void combineUsingRelations()
Definition doxygen.cpp:9585
static const char * getArg(int argc, char **argv, int &optInd)
std::unique_ptr< ArgumentList > getTemplateArgumentsFromName(const DString &name, const ArgumentLists &tArgLists)
Definition doxygen.cpp:878
static void checkMarkdownMainfile()
static std::unordered_map< std::string, std::vector< ClassDefMutable * > > g_usingClassMap
Definition doxygen.cpp:2481
static void buildConceptDocList(const Entry *root)
Definition doxygen.cpp:1350
static bool isEntryInGroupOfMember(const Entry *root, const MemberDef *md, bool allowNoGroup=false)
Definition doxygen.cpp:6011
static void applyToAllDefinitions(Func func)
Definition doxygen.cpp:5756
static void parseFilesMultiThreading(const std::shared_ptr< Entry > &root)
parse the list of input files
static DString createOutputDirectory(const DString &baseDirName, const DString &formatDirName, const char *defaultDirName)
static void transferFunctionReferences()
Definition doxygen.cpp:4633
static void buildDefineList()
Definition doxygen.cpp:9207
static void buildInterfaceAndServiceList(const Entry *root)
Definition doxygen.cpp:3899
static Definition * findScopeFromQualifiedName(NamespaceDefMutable *startScope, const DString &n, FileDef *fileScope, const TagInfo *tagInfo)
Definition doxygen.cpp:793
static void computeMemberRelations()
Definition doxygen.cpp:8815
static void buildListOfUsingDecls(const Entry *root)
Definition doxygen.cpp:2317
static std::multimap< std::string, const Entry * > g_classEntries
Definition doxygen.cpp:190
std::vector< InputFileEncoding > InputFileEncodingList
Definition doxygen.h:73
std::unordered_map< std::string, BodyInfo > StaticInitMap
Definition doxygen.h:77
std::unordered_map< std::string, NamespaceAliasInfo > NamespaceAliasInfoMap
Definition doxygen.h:79
std::unordered_map< std::string, const Definition * > ClangUsrMap
Definition doxygen.h:75
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
Definition dstring.cpp:485
int dstricmp(const char *s1, const char *s2)
Definition dstring.cpp:444
uint32_t dstrlen(const char *str)
Returns the length of string str, or 0 if a null pointer is passed.
Definition dstring.h:39
int dstricmp_sort(const char *str1, const char *str2)
Definition dstring.h:67
int dstrcmp(const char *str1, const char *str2)
Definition dstring.h:50
const char * qPrint(const char *s)
Definition dstring.h:783
FileDef * toFileDef(Definition *d)
Definition filedef.cpp:2054
std::unique_ptr< FileDef > createFileDef(const DString &p, const DString &n, const DString &ref, const DString &dn)
Definition filedef.cpp:270
std::unordered_set< const FileDef * > FileDefSet
Definition filedef.h:41
void addNamespaceToGroups(const Entry *root, NamespaceDef *nd)
void addGroupToGroups(const Entry *root, GroupDef *subGroup)
void addClassToGroups(const Entry *root, ClassDef *cd)
void addDirToGroups(const Entry *root, DirDef *dd)
std::unique_ptr< GroupDef > createGroupDef(const DString &fileName, int line, const DString &name, const DString &title, const DString &refFileName)
Definition groupdef.cpp:184
void addConceptToGroups(const Entry *root, ConceptDef *cd)
void addMemberToGroups(const Entry *root, MemberDef *md)
void writeGraphInfo(OutputList &ol)
Definition index.cpp:4150
void endTitle(OutputList &ol, const DString &fileName, const DString &name)
Definition index.cpp:404
void writeIndexHierarchy(OutputList &ol)
Definition index.cpp:5902
void endFile(OutputList &ol, bool skipNavIndex, bool skipEndContents, const DString &navPath)
Definition index.cpp:437
void startTitle(OutputList &ol, const DString &fileName, const DefinitionMutable *def)
Definition index.cpp:394
void startFile(OutputList &ol, const DString &name, bool isSource, const DString &manName, const DString &title, HighlightedItem hli, bool additionalIndices, const DString &altSidebarName, int hierarchyLevel, const DString &allMembersFile)
Definition index.cpp:411
Translator * theTranslator
Definition language.cpp:76
void setTranslator(OUTPUT_LANGUAGE_t langName)
Definition language.cpp:78
#define LATEX_STYLE_EXTENSION
Definition latexgen.h:24
void writeDefaultLayoutFile(const DString &fileName)
Definition layout.cpp:1773
void printLayout()
Definition layout.cpp:1861
std::unique_ptr< MemberDef > createMemberDef(const DString &defFileName, int defLine, size_t defColumn, const DString &type, const DString &name, const DString &args, const DString &excp, Protection prot, Specifier virt, bool stat, Relationship related, MemberType t, const ArgumentList &tal, const ArgumentList &al, const DString &metaData)
Factory method to create a new instance of a MemberDef.
std::unique_ptr< MemberDef > createMemberDefAlias(const Definition *newScope, const MemberDef *aliasMd)
MemberDefMutable * toMemberDefMutable(Definition *d)
void mergeMemberOverrideOptions(MemberDefMutable *md1, MemberDefMutable *md2)
void combineDeclarationAndDefinition(MemberDefMutable *mdec, MemberDefMutable *mdef)
MemberDef * toMemberDef(Definition *d)
std::unordered_map< int, std::unique_ptr< MemberGroupInfo > > MemberGroupInfoMap
#define DOX_NOGROUP
Definition membergroup.h:26
void initWarningFormat()
Definition message.cpp:233
void warn_flush()
Definition message.cpp:226
DString warn_line(const DString &file, int line)
Definition message.cpp:211
void finishWarnExit()
Definition message.cpp:291
#define warn_undoc(file, line, fmt,...)
Definition message.h:102
#define warn_uncond(fmt,...)
Definition message.h:122
#define warn(file, line, fmt,...)
Definition message.h:97
#define msg(fmt,...)
Definition message.h:94
#define err(fmt,...)
Definition message.h:127
#define ASSERT(x)
Definition message.h:142
#define term(fmt,...)
Definition message.h:137
void postProcess(bool clearHeaderAndFooter, CompareMode compareMode=CompareMode::Full)
CompareMode
Definition config.h:54
void checkAndCorrect(bool quiet, const bool check)
void compareDoxyfile(TextStream &t, CompareMode compareMode)
void writeTemplate(TextStream &t, bool shortList, bool updateOnly=false)
void deinit()
void init()
void updateObsolete()
bool parse(const DString &fileName, bool update=false, CompareMode compareMode=CompareMode::Full)
void correctPath(const StringVector &list)
Correct a possible wrong PATH variable.
Definition portable.cpp:532
FILE * popen(const DString &name, const DString &type)
Definition portable.cpp:495
double getSysElapsedTime()
Definition portable.cpp:113
void setenv(const DString &variable, const DString &value)
Definition portable.cpp:302
uint32_t pid()
Definition portable.cpp:264
int system(const DString &command, const DString &args, bool commandHasConsole=true)
Definition portable.cpp:121
int pclose(FILE *stream)
Definition portable.cpp:504
DString getenv(const DString &variable)
Definition portable.cpp:337
bool isAbsolutePath(const DString &fileName)
Definition portable.cpp:513
DString pathListSeparator()
Definition portable.cpp:399
std::ofstream openOutputStream(const DString &name, bool append=false)
Definition portable.cpp:679
const char * commandExtension()
Definition portable.cpp:477
void setShortDir()
Definition portable.cpp:569
DString trunc(const DString &s, size_t numChars=15)
Definition trace.h:56
std::unique_ptr< NamespaceDef > createNamespaceDef(const DString &defFileName, int defLine, size_t defColumn, const DString &name, const DString &ref, const DString &refFile, const DString &type, bool isPublished)
Factory method to create new NamespaceDef instance.
std::unique_ptr< NamespaceDef > createNamespaceDefAlias(const Definition *newScope, const NamespaceDef *nd)
Factory method to create an alias of an existing namespace.
void replaceNamespaceAliases(DString &name)
NamespaceDef * getResolvedNamespace(const DString &name)
NamespaceDef * toNamespaceDef(Definition *d)
NamespaceDefMutable * toNamespaceDefMutable(Definition *d)
NamespaceDefMutable * getResolvedNamespaceMutable(const DString &key)
std::unordered_set< const NamespaceDef * > NamespaceDefSet
bool search(std::string_view str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition regex.cpp:850
std::unique_ptr< PageDef > createPageDef(const DString &f, int l, const DString &n, const DString &d, const DString &t)
Definition pagedef.cpp:89
void generatePerlMod()
void setPerlModDoxyfile(const DString &qs)
Portable versions of functions that are platform dependent.
int portable_iconv_close(void *cd)
void * portable_iconv_open(const char *tocode, const char *fromcode)
void addRefItem(const RefItemVector &sli, const DString &key, const DString &prefix, const DString &name, const DString &title, const DString &args, const Definition *scope)
Definition reflist.h:136
void initSearchIndexer()
void finalizeSearchIndexer()
void createJavaScriptSearchIndex()
void writeJavaScriptSearchIndex()
Javascript based search engine.
void generateHtmlForComment(const std::string &fn, const std::string &text)
Helper for implemented the -c option of doxygen, which produces HTML output for a given doxygen forma...
void generateSqlite3()
void addSTLSupport(std::shared_ptr< Entry > &root)
Add stub entries for the most used classes in the standard template library.
Some helper functions for std::string.
void addTerminalCharIfMissing(std::string &s, char c)
Definition stringutil.h:87
Class that contains information about an inheritance relation.
Definition classdef.h:51
ClassDef * classDef
Class definition that this relation inherits from.
Definition classdef.h:56
This class stores information about an inheritance relation.
Definition entry.h:88
Protection prot
inheritance type
Definition entry.h:93
Specifier virt
virtualness
Definition entry.h:94
DString name
the name of the base class
Definition entry.h:92
Data associated with description found in the body.
Definition definition.h:64
Helper class to pass options when calling OutputList::generateDoc().
Definition docoptions.h:24
Grouping info.
Definition types.h:227
DString groupname
name of the group
Definition types.h:257
static constexpr const char * getGroupPriName(GroupPri_t priority) noexcept
Definition types.h:240
@ GROUPING_INGROUP
membership in group was defined by @ingroup
Definition types.h:236
GroupPri_t pri
priority of this definition
Definition types.h:258
static bool execute(const DString &htmldir)
Definition htags.cpp:41
static bool loadFilemap(const DString &htmldir)
Definition htags.cpp:110
static bool useHtags
Definition htags.h:23
stat(const char *n, double el)
Definition doxygen.cpp:271
const char * name
Definition doxygen.cpp:268
void parseTagFile(const std::shared_ptr< Entry > &root, const char *fullName)
void exitTracing()
Definition trace.cpp:55
void initTracing(const DString &logFile, bool timing)
Definition trace.cpp:25
#define TRACE(...)
Definition trace.h:77
MemberType
Definition types.h:571
bool isTypeAClassFriend(const DString &type)
Definition types.h:923
Protection
Definition types.h:32
SrcLangExt
Definition types.h:207
Relationship
Definition types.h:167
Specifier
Definition types.h:80
bool readInputFile(const DString &fileName, std::string &contents, const ReadInputFileOptions &options)
read a file name fileName and optionally filter and transcode it
Definition util.cpp:4383
bool useCaseSenseNames()
Returns true if the names of the symbols can be case sensitive.
Definition util.cpp:2688
DString substituteTemplateArgumentsInString(const DString &nm, const ArgumentList &formalArgs, const ArgumentList *actualArgs)
Definition util.cpp:3533
bool protectionLevelVisible(Protection prot)
Definition util.cpp:4684
DString stripFromIncludePath(const DString &path)
Definition util.cpp:227
DString mergeScopes(const DString &leftScope, const DString &rightScope)
Definition util.cpp:3762
DString filterTitle(const DString &title)
Definition util.cpp:4467
bool matchTemplateArguments(const ArgumentList &srcAl, const ArgumentList &dstAl)
Definition util.cpp:1841
void addCodeOnlyMappings()
Definition util.cpp:4171
bool rightScopeMatch(const DString &scope, const DString &name)
Definition util.cpp:734
bool checkIfTypedef(const Definition *scope, const FileDef *fileScope, const DString &n)
Definition util.cpp:4280
DString replaceAnonymousScopes(const DString &s, const DString &replacement)
Definition util.cpp:155
void cleanupInlineGraphs()
Definition util.cpp:5435
int computeQualifiedIndex(const DString &name)
Return the index of the last :: in the string name that is still before the first <.
Definition util.cpp:5312
DString removeRedundantWhiteSpace(const DString &s)
Definition util.cpp:427
bool checkExtension(const DString &fName, const DString &ext)
Definition util.cpp:3935
DString convertNameToFile(const DString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:2872
bool leftScopeMatch(const DString &scope, const DString &name)
Definition util.cpp:745
DString tempArgListToString(const ArgumentList &al, SrcLangExt lang, bool includeDefault)
Definition util.cpp:908
DString getFileNameExtension(const DString &fn)
Definition util.cpp:4219
DString resolveTypeDef(const Definition *context, const DString &qualifiedName, const Definition **typedefContext)
Definition util.cpp:232
DString normalizeNonTemplateArgumentsInString(const DString &name, const Definition *context, const ArgumentList &formalArgs)
Definition util.cpp:3474
SrcLangExt getLanguageFromFileName(const DString &fileName, SrcLangExt defLang)
Definition util.cpp:4177
bool matchArguments2(const Definition *srcScope, const FileDef *srcFileScope, const DString &srcReturnType, const ArgumentList *srcAl, const Definition *dstScope, const FileDef *dstFileScope, const DString &dstReturnType, const ArgumentList *dstAl, bool checkCV, SrcLangExt lang)
Definition util.cpp:1597
void initDefaultExtensionMapping()
Definition util.cpp:4104
void addHtmlExtensionIfMissing(DString &fName)
Definition util.cpp:3940
DString fileToString(const DString &name, bool filter, bool isSourceCode)
Definition util.cpp:1058
void extractNamespaceName(const DString &scopeName, DString &className, DString &namespaceName, bool allowEmptyClass)
Definition util.cpp:3035
DString stripTemplateSpecifiersFromScope(const DString &fullName, bool parentOnly, DString *pLastScopeStripped, DString scopeName, bool allowArtificial)
Definition util.cpp:3695
DString argListToString(const ArgumentList &al, bool useCanonicalType, bool showDefVals)
Definition util.cpp:864
DString projectLogoFile()
Definition util.cpp:2589
bool copyFile(const DString &src, const DString &dest)
Copies the contents of file with name src to the newly created file with name dest.
Definition util.cpp:4632
int getPrefixIndex(const DString &name)
Definition util.cpp:2660
DString getLanguageSpecificSeparator(SrcLangExt lang, bool classScope)
Definition util.cpp:4642
bool updateLanguageMapping(const DString &extension, const DString &language)
Definition util.cpp:4072
DString mangleCSharpGenericName(const DString &name)
Definition util.cpp:5354
void mergeArguments(ArgumentList &srcAl, ArgumentList &dstAl, bool forceNameOverwrite)
Definition util.cpp:1697
int getScopeFragment(const DString &s, int p, int *l)
Definition util.cpp:3807
int extractClassNameFromType(const DString &type, int &pos, DString &name, DString &templSpec, SrcLangExt lang)
Definition util.cpp:3389
DString removeAnonymousScopes(const DString &str)
Definition util.cpp:98
bool openOutputFile(const DString &outFile, std::ofstream &f)
Definition util.cpp:4999
DString stripAnonymousNamespaceScope(const DString &s)
Definition util.cpp:167
A bunch of utility functions.
void generateXML()
Definition xmlgen.cpp:2357