Skip to content

Commit 9a8b3da

Browse files
committed
issue #7580 No autolink for template functions
1 parent 92c4ee8 commit 9a8b3da

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

src/code.l

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,6 +2776,7 @@ static bool getLinkInScope(yyscan_t yyscanner,
27762776
DBG_CTX((stderr,"getLinkInScope: trying '%s'::'%s' varOnly=%d\n",qPrint(c),qPrint(m),varOnly));
27772777
GetDefInput input(c,m,"()");
27782778
input.currentFile = yyextra->sourceFileDef;
2779+
input.insideCode = true;
27792780
GetDefResult result = getDefs(input);
27802781
if (result.found && (!varOnly || result.md->isVariable()))
27812782
{

src/pycode.l

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,7 @@ static bool getLinkInScope(yyscan_t yyscanner,
12091209
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
12101210
GetDefInput input(c,m,"()");
12111211
input.currentFile = yyextra->sourceFileDef;
1212+
input.insideCode = true;
12121213
GetDefResult result = getDefs(input);
12131214
//printf("Trying '%s'::'%s'\n",qPrint(c),qPrint(m));
12141215
if (result.found && result.md->isLinkable())

src/symbolresolver.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ struct SymbolResolver::Private
119119
const QCString &n, // in
120120
const QCString &args, // in
121121
bool checkCV, // in
122+
bool insideCode, // in
122123
const MemberDef **pTypeDef, // out
123124
QCString *pTemplSpec, // out
124125
QCString *pResolvedType); // out
@@ -154,6 +155,7 @@ struct SymbolResolver::Private
154155
const Definition *d, // in
155156
const QCString &args, // in
156157
bool checkCV, // in
158+
bool insideCode, // in
157159
const QCString &explicitScopePart, // in
158160
const std::unique_ptr<ArgumentList> &actTemplParams, // in
159161
int &minDistance, // inout
@@ -365,6 +367,7 @@ const Definition *SymbolResolver::Private::getResolvedSymbolRec(
365367
const QCString &n,
366368
const QCString &args,
367369
bool checkCV,
370+
bool insideCode,
368371
const MemberDef **pTypeDef,
369372
QCString *pTemplSpec,
370373
QCString *pResolvedType)
@@ -402,8 +405,21 @@ const Definition *SymbolResolver::Private::getResolvedSymbolRec(
402405
auto &range = Doxygen::symbolMap->find(name);
403406
if (range.empty())
404407
{
405-
//printf("%d ] not symbols\n",--level);
406-
return 0;
408+
int i;
409+
if (insideCode && (i=name.find('<'))!=-1)
410+
{
411+
range = Doxygen::symbolMap->find(name.left(i));
412+
if (range.empty())
413+
{
414+
//printf("%d ] no symbols even without templates\n",--level);
415+
return 0;
416+
}
417+
}
418+
else
419+
{
420+
//printf("%d ] no symbols\n",--level);
421+
return 0;
422+
}
407423
}
408424
//printf("found symbol %zu times!\n",range.size());
409425

@@ -492,7 +508,7 @@ const Definition *SymbolResolver::Private::getResolvedSymbolRec(
492508

493509
for (Definition *d : range)
494510
{
495-
getResolvedSymbol(visitedKeys,scope,d,args,checkCV,explicitScopePart,actTemplParams,
511+
getResolvedSymbol(visitedKeys,scope,d,args,checkCV,insideCode,explicitScopePart,actTemplParams,
496512
minDistance,bestMatch,bestTypedef,bestTemplSpec,bestResolvedType);
497513
if (minDistance==0) break; // we can stop reaching if we already reached distance 0
498514
}
@@ -503,7 +519,7 @@ const Definition *SymbolResolver::Private::getResolvedSymbolRec(
503519
{
504520
for (Definition *d : range)
505521
{
506-
getResolvedSymbol(visitedKeys,scope,d,QCString(),false,explicitScopePart,actTemplParams,
522+
getResolvedSymbol(visitedKeys,scope,d,QCString(),false,insideCode,explicitScopePart,actTemplParams,
507523
minDistance,bestMatch,bestTypedef,bestTemplSpec,bestResolvedType);
508524
if (minDistance==0) break; // we can stop reaching if we already reached distance 0
509525
}
@@ -708,6 +724,7 @@ void SymbolResolver::Private::getResolvedSymbol(
708724
const Definition *d, // in
709725
const QCString &args, // in
710726
bool checkCV, // in
727+
bool insideCode, // in
711728
const QCString &explicitScopePart, // in
712729
const std::unique_ptr<ArgumentList> &/* actTemplParams */, // in
713730
int &minDistance, // inout
@@ -1564,13 +1581,14 @@ const ClassDef *SymbolResolver::resolveClass(const Definition *scope,
15641581
const Definition *SymbolResolver::resolveSymbol(const Definition *scope,
15651582
const QCString &name,
15661583
const QCString &args,
1567-
bool checkCV)
1584+
bool checkCV,
1585+
bool insideCode)
15681586
{
15691587
p->reset();
15701588
if (scope==0) scope=Doxygen::globalScope;
15711589
StringUnorderedSet visitedKeys;
1572-
const Definition *result = p->getResolvedSymbolRec(visitedKeys,scope,name,args,checkCV,&p->typeDef,&p->templateSpec,&p->resolvedType);
1573-
//printf("resolveSymbol(%s,%s,%s,%d)=%s\n",qPrint(scope?scope->name():QCString()),qPrint(name),qPrint(args),checkCV,qPrint(result?result->qualifiedName():QCString()));
1590+
const Definition *result = p->getResolvedSymbolRec(visitedKeys,scope,name,args,checkCV,insideCode,&p->typeDef,&p->templateSpec,&p->resolvedType);
1591+
//printf("resolveSymbol(%s,%s,%s,%d,%d)=%s\n",qPrint(scope?scope->name():QCString()),qPrint(name),qPrint(args),checkCV,insideCode,qPrint(result?result->qualifiedName():QCString()));
15741592
return result;
15751593
}
15761594

src/symbolresolver.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ class SymbolResolver
6565
* @param name The name of the symbol.
6666
* @param args Argument list associated with the symbol (for functions)
6767
* @param checkCV Check const/volatile qualifiers (for methods)
68+
* @param insideCode Is the symbol found in a code fragment
6869
*/
6970
const Definition *resolveSymbol(const Definition *scope,
7071
const QCString &name,
7172
const QCString &args=QCString(),
72-
bool checkCV=false);
73+
bool checkCV=false,
74+
bool insideCode=false
75+
);
7376

7477
/** Checks if symbol \a item is accessible from within \a scope.
7578
* @returns -1 if \a item is not accessible or a number indicating how

src/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,8 +2178,8 @@ GetDefResult getDefsNew(const GetDefInput &input)
21782178
}
21792179
//printf("@@ -> found scope scope=%s member=%s out=%s\n",qPrint(input.scopeName),qPrint(input.memberName),qPrint(scope?scope->name():""));
21802180
//
2181-
const Definition *symbol = resolver.resolveSymbol(scope,input.memberName,input.args,input.checkCV);
2182-
//printf("@@ -> found symbol in=%s out=%s\n",qPrint(mbName),qPrint(symbol?symbol->qualifiedName():QCString()));
2181+
const Definition *symbol = resolver.resolveSymbol(scope,input.memberName,input.args,input.checkCV,input.insideCode);
2182+
//printf("@@ -> found symbol in=%s out=%s\n",qPrint(input.memberName),qPrint(symbol?symbol->qualifiedName():QCString()));
21832183
if (symbol && symbol->definitionType()==Definition::TypeMember)
21842184
{
21852185
result.md = toMemberDef(symbol);

src/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct GetDefInput
113113
bool forceEmptyScope = false;
114114
const FileDef *currentFile = 0;
115115
bool checkCV = false;
116+
bool insideCode = false;
116117
};
117118

118119
struct GetDefResult

0 commit comments

Comments
 (0)