Skip to content

Commit d8873dd

Browse files
committed
issue #10143 Inheritance
1 parent 060b2d1 commit d8873dd

File tree

3 files changed

+56
-34
lines changed

3 files changed

+56
-34
lines changed

src/code.l

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
13281328
}
13291329
else
13301330
{
1331-
codifyLines(yyscanner,yytext);
1331+
codifyLines(yyscanner,yytext);
13321332
addToSearchIndex(yyscanner,yytext);
13331333
yyextra->name.resize(0);
13341334
}
@@ -2610,6 +2610,8 @@ static void setParameterList(yyscan_t yyscanner,const MemberDef *md)
26102610
static const ClassDef *stripClassName(yyscan_t yyscanner,const QCString &s,const Definition *d)
26112611
{
26122612
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2613+
DBG_CTX((stderr,"stripClassName(scope=%s,type=%s) classScope=%s\n",
2614+
qPrint(d?d->name():""),qPrint(s),qPrint(yyextra->classScope)));
26132615
int pos=0;
26142616
QCString type = s;
26152617
QCString className;
@@ -2803,7 +2805,11 @@ static bool getLinkInScope(yyscan_t yyscanner,
28032805
if (result.md->resolveAlias()->getGroupDef()) d = result.md->resolveAlias()->getGroupDef();
28042806
if (d && d->isLinkable())
28052807
{
2806-
yyextra->theCallContext.setScope(ScopedTypeVariant(stripClassName(yyscanner,result.md->typeString(),result.md->getOuterScope())));
2808+
const ClassDef *ncd = stripClassName(yyscanner,result.md->typeString(),result.md->getOuterScope());
2809+
if (ncd)
2810+
{
2811+
yyextra->theCallContext.setScope(ScopedTypeVariant(ncd));
2812+
}
28072813
DBG_CTX((stderr,"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p yyextra->insideBody=%d\n",
28082814
(void*)yyextra->currentDefinition,(void*)yyextra->currentMemberDef,yyextra->insideBody));
28092815

@@ -2812,7 +2818,7 @@ static bool getLinkInScope(yyscan_t yyscanner,
28122818
{
28132819
addDocCrossReference(yyextra->currentMemberDef,result.md);
28142820
}
2815-
DBG_CTX((stderr,"d->getReference()='%s' d->getOutputBase()='%s' name='%s' member name='%s'\n",qPrint(d->getReference()),qPrint(d->getOutputFileBase()),qPrint(d->name()),qPrint(md->name())));
2821+
DBG_CTX((stderr,"d->getReference()='%s' d->getOutputBase()='%s' name='%s' member name='%s'\n",qPrint(d->getReference()),qPrint(d->getOutputFileBase()),qPrint(d->name()),qPrint(result.md->name())));
28162822

28172823
writeMultiLineCodeLink(yyscanner,ol,result.md, !text.isEmpty() ? text : memberText);
28182824
addToSearchIndex(yyscanner,!text.isEmpty() ? text : memberText);

src/scopedtypevariant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class CallContext
154154
void setScope(const ScopedTypeVariant &stv)
155155
{
156156
Ctx &ctx = m_stvList.back();
157-
ctx.stv=std::move(stv);
157+
ctx.stv=stv;
158158
}
159159
void pushScope(const QCString &name_,const QCString &type_)
160160
{

src/symbolresolver.cpp

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ const ClassDef *SymbolResolver::Private::getResolvedTypeRec(
307307
if (pval)
308308
{
309309
//printf("LookupInfo %p %p '%s' %p\n",
310-
// pval->classDef, pval->typeDef, qPrint(pval->templSpec),
310+
// pval->definition, pval->typeDef, qPrint(pval->templSpec),
311311
// qPrint(pval->resolvedType));
312312
if (pTemplSpec) *pTemplSpec=pval->templSpec;
313313
if (pTypeDef) *pTypeDef=pval->typeDef;
@@ -353,11 +353,12 @@ const ClassDef *SymbolResolver::Private::getResolvedTypeRec(
353353
LookupInfo(bestMatch,bestTypedef,bestTemplSpec,bestResolvedType));
354354
}
355355
visitedKeys.erase(key.str());
356+
357+
//printf("%d ] bestMatch=%s distance=%d\n",--level,
358+
// bestMatch?qPrint(bestMatch->name()):"<none>",minDistance);
359+
//if (pTemplSpec)
360+
// printf("templSpec=%s\n",pTemplSpec->data());
356361
}
357-
//printf("%d ] bestMatch=%s distance=%d\n",--level,
358-
// bestMatch?qPrint(bestMatch->name()):"<none>",minDistance);
359-
//if (pTemplSpec)
360-
// printf("templSpec=%s\n",pTemplSpec->data());
361362
return bestMatch;
362363
}
363364

@@ -569,7 +570,7 @@ void SymbolResolver::Private::getResolvedType(
569570
QCString &bestResolvedType // out
570571
)
571572
{
572-
//fprintf(stderr,"getResolvedType(%s,%s)\n",qPrint(scope->name()),qPrint(d->qualifiedName()));
573+
//fprintf(stderr,"getResolvedType(scope=%s,symbol=%s,explicitScope=%s)\n",qPrint(scope->name()),qPrint(d->qualifiedName()),qPrint(explicitScopePart));
573574
// only look at classes and members that are enums or typedefs
574575
if (d->definitionType()==Definition::TypeClass ||
575576
(d->definitionType()==Definition::TypeMember &&
@@ -714,7 +715,7 @@ void SymbolResolver::Private::getResolvedType(
714715
//printf(" Not accessible!\n");
715716
}
716717
} // if definition is a class or member
717-
//printf(" bestMatch=%p bestResolvedType=%s\n",bestMatch,qPrint(bestResolvedType));
718+
//fprintf(stderr," bestMatch=%p bestResolvedType=%s\n",bestMatch,qPrint(bestResolvedType));
718719
}
719720

720721

@@ -1006,7 +1007,7 @@ int SymbolResolver::Private::isAccessibleFromWithExpScope(
10061007
accessStack.push(scope,m_fileScope,item,explicitScopePart);
10071008

10081009

1009-
//printf(" <isAccessibleFromWithExpScope(%s,%s,%s)\n",scope?qPrint(scope->name()):"<global>",
1010+
//fprintf(stderr," <isAccessibleFromWithExpScope(%s,%s,%s)\n",scope?qPrint(scope->name()):"<global>",
10101011
// item?qPrint(item->qualifiedName()):"<none>",
10111012
// qPrint(explicitScopePart));
10121013
int result=0; // assume we found it
@@ -1015,7 +1016,7 @@ int SymbolResolver::Private::isAccessibleFromWithExpScope(
10151016
{
10161017
Definition *itemScope = item->getOuterScope();
10171018

1018-
//printf(" scope traversal successful %s<->%s!\n",qPrint(itemScope->name()),qPrint(newScope->name()));
1019+
//fprintf(stderr," scope traversal successful %s<->%s!\n",qPrint(itemScope->name()),qPrint(newScope->name()));
10191020

10201021
bool nestedClassInsideBaseClass =
10211022
itemScope &&
@@ -1109,14 +1110,14 @@ int SymbolResolver::Private::isAccessibleFromWithExpScope(
11091110
}
11101111
else // failed to resolve explicitScope
11111112
{
1112-
//printf(" failed to resolve explicitScope=%s: scope=%s\n",qPrint(explicitScopePart), qPrint(scope->name()));
1113+
//fprintf(stderr," failed to resolve explicitScope=%s: scope=%s\n",qPrint(explicitScopePart), qPrint(scope->name()));
11131114
if (scope->definitionType()==Definition::TypeNamespace)
11141115
{
11151116
const NamespaceDef *nscope = toNamespaceDef(scope);
11161117
StringUnorderedSet locVisitedNamespaces;
11171118
if (accessibleViaUsingNamespace(visitedKeys,locVisitedNamespaces,nscope->getUsedNamespaces(),item,explicitScopePart))
11181119
{
1119-
//printf(" > found in used namespace\n");
1120+
//fprintf(stderr," > found in used namespace\n");
11201121
goto done;
11211122
}
11221123
}
@@ -1127,23 +1128,22 @@ int SymbolResolver::Private::isAccessibleFromWithExpScope(
11271128
StringUnorderedSet locVisitedNamespaces;
11281129
if (accessibleViaUsingNamespace(visitedKeys,locVisitedNamespaces,m_fileScope->getUsedNamespaces(),item,explicitScopePart))
11291130
{
1130-
//printf(" > found in used namespace\n");
1131+
//fprintf(stderr," > found in used namespace\n");
11311132
goto done;
11321133
}
11331134
}
1134-
//printf(" > not found\n");
1135+
//fprintf(stderr," > not found\n");
11351136
result=-1;
11361137
}
11371138
else // continue by looking into the parent scope
11381139
{
11391140
int i=isAccessibleFromWithExpScope(visitedKeys,visitedNamespaces,accessStack,scope->getOuterScope(),item,explicitScopePart);
1140-
//printf(" > result=%d\n",i);
11411141
result= (i==-1) ? -1 : i+2;
11421142
}
11431143
}
11441144

11451145
done:
1146-
//printf(" > result=%d\n",result);
1146+
//fprintf(stderr," > result=%d\n",result);
11471147
accessStack.pop();
11481148
return result;
11491149
}
@@ -1272,12 +1272,12 @@ bool SymbolResolver::Private::accessibleViaUsingNamespace(
12721272
//size_t count=0;
12731273
for (const auto &und : nl) // check used namespaces for the class
12741274
{
1275-
//printf("%d [Trying via used namespace %s: count=%zu/%zu\n",level,qPrint(und->name()),
1275+
//fprintf(stderr,"%d [Trying via used namespace %s: count=%zu/%zu\n",level,qPrint(und->name()),
12761276
// count++,nl.size());
12771277
const Definition *sc = explicitScopePart.isEmpty() ? und : followPath(visitedKeys,und,explicitScopePart);
12781278
if (sc && item->getOuterScope()==sc)
12791279
{
1280-
//printf("%d ] found it\n",level);
1280+
//fprintf(stderr,"%d ] found it\n",level);
12811281
return true;
12821282
}
12831283
if (item->getLanguage()==SrcLangExt_Cpp)
@@ -1287,13 +1287,13 @@ bool SymbolResolver::Private::accessibleViaUsingNamespace(
12871287
{
12881288
if (accessibleViaUsingNamespace(visitedKeys,visitedNamespaces,und->getUsedNamespaces(),item,explicitScopePart,level+1))
12891289
{
1290-
//printf("%d ] found it via recursion\n",level);
1290+
//fprintf(stderr,"%d ] found it via recursion\n",level);
12911291
return true;
12921292
}
12931293

12941294
}
12951295
}
1296-
//printf("%d ] Try via used namespace done\n",level);
1296+
//fprintf(stderr,"%d ] Try via used namespace done\n",level);
12971297
}
12981298
return false;
12991299
}
@@ -1319,17 +1319,18 @@ int SymbolResolver::Private::isAccessibleFrom(StringUnorderedSet &visitedKeys,
13191319
const Definition *scope,
13201320
const Definition *item)
13211321
{
1322-
//printf("<isAccessibleFrom(scope=%s,item=%s itemScope=%s)\n",
1322+
//fprintf(stderr,"<isAccessibleFrom(scope=%s,item=%s itemScope=%s)\n",
13231323
// qPrint(scope->name()),qPrint(item->name()),qPrint(item->getOuterScope()->name()));
13241324

13251325
if (accessStack.find(scope,m_fileScope,item))
13261326
{
1327+
//fprintf(stderr,">already processed!\n");
13271328
return -1;
13281329
}
13291330
accessStack.push(scope,m_fileScope,item);
13301331

13311332
int result=0; // assume we found it
1332-
int i;
1333+
int i=0;
13331334

13341335
const Definition *itemScope=item->getOuterScope();
13351336
bool itemIsMember = item->definitionType()==Definition::TypeMember;
@@ -1377,7 +1378,7 @@ int SymbolResolver::Private::isAccessibleFrom(StringUnorderedSet &visitedKeys,
13771378

13781379
if (itemScope==scope || memberAccessibleFromScope || nestedClassInsideBaseClass || enumValueOfStrongEnum)
13791380
{
1380-
//printf("> found it memberAccessibleFromScope=%d nestedClassInsideBaseClass=%d enumValueOfStrongEnum=%d\n",memberAccessibleFromScope,nestedClassInsideBaseClass,enumValueOfStrongEnum);
1381+
//fprintf(stderr,"> found it memberAccessibleFromScope=%d nestedClassInsideBaseClass=%d enumValueOfStrongEnum=%d\n",memberAccessibleFromScope,nestedClassInsideBaseClass,enumValueOfStrongEnum);
13811382
int distanceToBase=0;
13821383
if (nestedClassInsideBaseClass)
13831384
{
@@ -1403,25 +1404,25 @@ int SymbolResolver::Private::isAccessibleFrom(StringUnorderedSet &visitedKeys,
14031404
itemScope->getOuterScope()==Doxygen::globalScope)
14041405
{ // item is in an anonymous namespace in the global scope and we are
14051406
// looking in the global scope
1406-
//printf("> found in anonymous namespace\n");
1407+
//fprintf(stderr,"> found in anonymous namespace\n");
14071408
result++;
14081409
goto done;
14091410
}
14101411
if (m_fileScope)
14111412
{
14121413
if (accessibleViaUsingClass(visitedKeys,m_fileScope->getUsedClasses(),item))
14131414
{
1414-
//printf("> found via used class\n");
1415+
//fprintf(stderr,"> found via used class\n");
14151416
goto done;
14161417
}
14171418
StringUnorderedSet visitedNamespaces;
14181419
if (accessibleViaUsingNamespace(visitedKeys,visitedNamespaces,m_fileScope->getUsedNamespaces(),item))
14191420
{
1420-
//printf("> found via used namespace\n");
1421+
//fprintf(stderr,"> found via used namespace\n");
14211422
goto done;
14221423
}
14231424
}
1424-
//printf("> reached global scope\n");
1425+
//fprintf(stderr,"> reached global scope\n");
14251426
result=-1; // not found in path to globalScope
14261427
}
14271428
else // keep searching
@@ -1430,16 +1431,31 @@ int SymbolResolver::Private::isAccessibleFrom(StringUnorderedSet &visitedKeys,
14301431
if (scope->definitionType()==Definition::TypeNamespace)
14311432
{
14321433
const NamespaceDef *nscope = toNamespaceDef(scope);
1433-
//printf(" %s is namespace with %d used classes\n",qPrint(nscope->name()),nscope->getUsedClasses());
1434+
//fprintf(stderr," %s is namespace with %zu used classes\n",qPrint(nscope->name()),nscope->getUsedClasses().size());
14341435
if (accessibleViaUsingClass(visitedKeys,nscope->getUsedClasses(),item))
14351436
{
1436-
//printf("> found via used class\n");
1437+
//fprintf(stderr,"> found via used class\n");
14371438
goto done;
14381439
}
14391440
StringUnorderedSet visitedNamespaces;
14401441
if (accessibleViaUsingNamespace(visitedKeys,visitedNamespaces,nscope->getUsedNamespaces(),item,0))
14411442
{
1442-
//printf("> found via used namespace\n");
1443+
//fprintf(stderr,"> found via used namespace\n");
1444+
goto done;
1445+
}
1446+
}
1447+
else if (scope->definitionType()==Definition::TypeFile)
1448+
{
1449+
const FileDef *nfile = toFileDef(scope);
1450+
if (accessibleViaUsingClass(visitedKeys,nfile->getUsedClasses(),item))
1451+
{
1452+
//fprintf(stderr,"> found via used class\n");
1453+
goto done;
1454+
}
1455+
StringUnorderedSet visitedNamespaces;
1456+
if (accessibleViaUsingNamespace(visitedKeys,visitedNamespaces,nfile->getUsedNamespaces(),item,0))
1457+
{
1458+
//fprintf(stderr,"> found via used namespace\n");
14431459
goto done;
14441460
}
14451461
}
@@ -1457,10 +1473,10 @@ int SymbolResolver::Private::isAccessibleFrom(StringUnorderedSet &visitedKeys,
14571473
}
14581474
}
14591475
i=isAccessibleFrom(visitedKeys,accessStack,parentScope,item);
1460-
//printf("> result=%d\n",i);
14611476
result= (i==-1) ? -1 : i+2;
14621477
}
14631478
done:
1479+
//fprintf(stderr,"> result=%d\n",result);
14641480
accessStack.pop();
14651481
return result;
14661482
}

0 commit comments

Comments
 (0)