@@ -384,12 +384,10 @@ EntryType guessSection(const QCString &name)
384384QCString resolveTypeDef (const Definition *context,const QCString &qualifiedName,
385385 const Definition **typedefContext)
386386{
387- // printf("<<resolveTypeDef(%s,%s)\n",
388- // context ? qPrint(context->name()) : "<none>",qPrint(qualifiedName));
387+ AUTO_TRACE (" context='{}' qualifiedName='{}'" ,context?context->name ():" " ,qualifiedName);
389388 QCString result;
390389 if (qualifiedName.isEmpty ())
391390 {
392- // printf(" qualified name empty!\n");
393391 return result;
394392 }
395393
@@ -399,7 +397,7 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName,
399397 // see if the qualified name has a scope part
400398 if (qualifiedName.find (' <' )!=-1 )
401399 {
402- // printf(" templates cannot be typedefs!\n ");
400+ AUTO_TRACE_EXIT ( " template " );
403401 return result;
404402 }
405403 int scopeIndex = qualifiedName.findRev (" ::" );
@@ -409,8 +407,7 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName,
409407 resName=qualifiedName.right (qualifiedName.length ()-scopeIndex-2 );
410408 if (resName.isEmpty ())
411409 {
412- // qualifiedName was of form A:: !
413- // printf(" qualified name of form A::!\n");
410+ AUTO_TRACE_EXIT (" invalid format" );
414411 return result;
415412 }
416413 }
@@ -438,40 +435,57 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName,
438435 ps=is+l;
439436 }
440437 }
441- // printf ("resScope=%s\n ",resScope? qPrint( resScope->name()) : "<none>" );
438+ AUTO_TRACE_ADD (" resScope='{}' resName='{}' " ,resScope?resScope->name (): " " ,resName );
442439
443440 // step 2: get the member
444441 if (resScope) // no scope or scope found in the current context
445442 {
446443 // printf("scope found: %s, look for typedef %s\n",
447444 // qPrint(resScope->qualifiedName()),qPrint(resName));
448445 MemberNameLinkedMap *mnd=nullptr ;
446+ bool searchRelated=false ;
447+ bool mustBeRelated=false ;
449448 if (resScope->definitionType ()==Definition::TypeClass)
450449 {
451450 mnd=Doxygen::memberNameLinkedMap;
452451 }
453452 else
454453 {
455454 mnd=Doxygen::functionNameLinkedMap;
455+ searchRelated=true ;
456456 }
457457 MemberName *mn=mnd->find (resName);
458+ if (mn==0 && searchRelated)
459+ {
460+ mn=Doxygen::memberNameLinkedMap->find (resName);
461+ mustBeRelated=true ;
462+ }
458463 if (mn)
459464 {
460465 int minDist=-1 ;
461466 for (const auto &tmd_p : *mn)
462467 {
463468 const MemberDef *tmd = tmd_p.get ();
469+ AUTO_TRACE_ADD (" found candidate member '{}' isTypeDef={}' isRelated={} mustBeRelated={}" ,
470+ tmd->name (),tmd->isTypedef (),tmd->isRelated (),mustBeRelated);
464471 // printf("Found member %s resScope=%s outerScope=%s mContext=%p\n",
465472 // qPrint(tmd->name()),qPrint( resScope->name()),
466473 // qPrint(tmd->getOuterScope()->name()), mContext);
467- if (tmd->isTypedef () /* && tmd->getOuterScope()==resScope */ )
474+ if (tmd->isTypedef ())
468475 {
469- SymbolResolver resolver;
470- int dist=resolver.isAccessibleFrom (resScope,tmd);
471- if (dist!=-1 && (md==nullptr || dist<minDist))
476+ if (resScope==Doxygen::globalScope && tmd->isRelated () && mustBeRelated)
472477 {
473478 md = tmd;
474- minDist = dist;
479+ }
480+ else
481+ {
482+ SymbolResolver resolver;
483+ int dist=resolver.isAccessibleFrom (resScope,tmd);
484+ if (dist!=-1 && (md==nullptr || dist<minDist))
485+ {
486+ md = tmd;
487+ minDist = dist;
488+ }
475489 }
476490 }
477491 }
@@ -480,6 +494,7 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName,
480494 mContext =mContext ->getOuterScope ();
481495 }
482496
497+ AUTO_TRACE_ADD (" md='{}'" ,md?md->name ():" " );
483498 // step 3: get the member's type
484499 if (md)
485500 {
@@ -503,8 +518,8 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName,
503518 // printf(">>resolveTypeDef: Typedef '%s' not found in scope '%s'!\n",
504519 // qPrint(qualifiedName),context ? qPrint(context->name()) : "<global>");
505520 }
521+ AUTO_TRACE_EXIT (" result='{}'" ,result);
506522 return result;
507-
508523}
509524
510525// -------------------------------------------------------------------------
@@ -1561,6 +1576,8 @@ static QCString getCanonicalTypeForIdentifier(
15611576 if (tSpec && !tSpec->isEmpty ())
15621577 templSpec = stripDeclKeywords (getCanonicalTemplateSpec (d,fs,*tSpec,lang));
15631578
1579+ AUTO_TRACE (" d='{}' fs='{}' word='{}' templSpec='{}'" ,d?d->name ():" " ,fs?fs->name ():" " ,word,templSpec);
1580+
15641581 if (word.findRev (" ::" )!=-1 && !(tmpName=stripScope (word)).isEmpty ())
15651582 {
15661583 symName=tmpName; // name without scope
@@ -1569,10 +1586,6 @@ static QCString getCanonicalTypeForIdentifier(
15691586 {
15701587 symName=word;
15711588 }
1572- // printf("getCanonicalTypeForIdentifier(%s d=%s fs=%s ,[%s->%s]) start\n",
1573- // qPrint(word),
1574- // d ? qPrint(d->name()) : "<null>", fs ? qPrint(fs->name()) : "<null>",
1575- // tSpec ? qPrint(tSpec) : "<none>", qPrint(templSpec));
15761589
15771590 // lookup class / class template instance
15781591 SymbolResolver resolver (fs);
@@ -1592,6 +1605,8 @@ static QCString getCanonicalTypeForIdentifier(
15921605 }
15931606 if (cd && cd->isUsedOnly ()) cd=nullptr ; // ignore types introduced by usage relations
15941607
1608+ AUTO_TRACE_ADD (" cd='{}' mType='{}' ts='{}' resolvedType='{}'" ,
1609+ cd?cd->name ():" " ,mType ?mType ->name ():" " ,ts,resolvedType);
15951610 // printf("cd=%p mtype=%p\n",cd,mType);
15961611 // printf(" getCanonicalTypeForIdentifier: symbol=%s word=%s cd=%s d=%s fs=%s cd->isTemplate=%d\n",
15971612 // qPrint(symName),
@@ -1684,7 +1699,7 @@ static QCString getCanonicalTypeForIdentifier(
16841699 else // fallback
16851700 {
16861701 resolvedType = lang==SrcLangExt::Java ? word : resolveTypeDef (d,word);
1687- // printf("typedef [%s]->[%s]\n",qPrint(word),qPrint( resolvedType) );
1702+ AUTO_TRACE_ADD ( " fallback resolvedType='{}' " , resolvedType);
16881703 if (resolvedType.isEmpty ()) // not known as a typedef either
16891704 {
16901705 result = word;
@@ -1694,12 +1709,13 @@ static QCString getCanonicalTypeForIdentifier(
16941709 result = resolvedType;
16951710 }
16961711 }
1697- // printf("getCanonicalTypeForIdentifier [%s]->[%s]\n",qPrint(word),qPrint( result) );
1712+ AUTO_TRACE_EXIT ( " result='{}' " , result);
16981713 return result;
16991714}
17001715
17011716static QCString extractCanonicalType (const Definition *d,const FileDef *fs,QCString type,SrcLangExt lang)
17021717{
1718+ AUTO_TRACE (" d={} fs={} type='{}'" ,d?d->name ():" " ,fs?fs->name ():" " ,type);
17031719 type = type.stripWhiteSpace ();
17041720
17051721 // strip const and volatile keywords that are not relevant for the type
@@ -1768,7 +1784,7 @@ static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCStr
17681784 pp=p;
17691785 }
17701786 canType += type.right (type.length ()-pp);
1771- // printf("extractCanonicalType = '%s'->'%s'\n",qPrint(type),qPrint( canType) );
1787+ AUTO_TRACE_EXIT ( " canType='{}' " , canType);
17721788
17731789 return removeRedundantWhiteSpace (canType);
17741790}
@@ -1811,6 +1827,7 @@ static bool matchCanonicalTypes(
18111827 const Definition *dstScope,const FileDef *dstFileScope,const QCString &dstType,
18121828 SrcLangExt lang)
18131829{
1830+ AUTO_TRACE (" srcType='{}' dstType='{}'" ,srcType,dstType);
18141831 if (srcType==dstType) return true ;
18151832
18161833 // check if the types are function pointers
@@ -1888,13 +1905,15 @@ static bool matchArgument2(
18881905 lang))
18891906 {
18901907 MATCH
1908+ AUTO_TRACE_EXIT (" true" );
18911909 return TRUE ;
18921910 }
18931911 else
18941912 {
18951913 // printf(" Canonical types do not match [%s]<->[%s]\n",
18961914 // qPrint(srcA->canType),qPrint(dstA->canType));
18971915 NOMATCH
1916+ AUTO_TRACE_EXIT (" false" );
18981917 return FALSE ;
18991918 }
19001919}
0 commit comments