Skip to content

Commit 71459fd

Browse files
committed
issue doxygen#11426 Template specialization in file's output point to the main template's documentation instead of the specialization's documentation.
1 parent 59cf339 commit 71459fd

File tree

2 files changed

+47
-29
lines changed

2 files changed

+47
-29
lines changed

src/clangparser.cpp

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "tooltip.h"
2525
#include "utf8.h"
2626
#include "searchindex.h"
27+
#include "trace.h"
2728
#endif
2829

2930
//--------------------------------------------------------------------------
@@ -343,7 +344,7 @@ void ClangTUParser::switchToFile(const FileDef *fd)
343344

344345
std::string ClangTUParser::lookup(uint32_t line,const char *symbol)
345346
{
346-
//printf("ClangParser::lookup(%d,%s)\n",line,symbol);
347+
AUTO_TRACE("line={},symbol={}",line,symbol);
347348
std::string result;
348349
if (symbol==nullptr) return result;
349350
bool clangAssistedParsing = Config_getBool(CLANG_ASSISTED_PARSING);
@@ -379,10 +380,10 @@ std::string ClangTUParser::lookup(uint32_t line,const char *symbol)
379380
while (l<=line && p->curToken<p->numTokens && !found)
380381
{
381382
CXString tokenString = clang_getTokenSpelling(p->tu, p->tokens[p->curToken]);
382-
//if (l==line)
383-
//{
384-
// printf("try to match symbol %s with token %s\n",symbol,clang_getCString(tokenString));
385-
//}
383+
if (l==line)
384+
{
385+
AUTO_TRACE_ADD("try to match symbol {} with token {}",symbol,clang_getCString(tokenString));
386+
}
386387
const char *ts = clang_getCString(tokenString);
387388
int tl = strlen(ts);
388389
int startIndex = p->curToken;
@@ -413,14 +414,14 @@ std::string ClangTUParser::lookup(uint32_t line,const char *symbol)
413414
//printf("no match '%s'<->'%s'\n",ts,symbol+offset);
414415
break; // no match
415416
}
416-
//printf("partial match '%s'<->'%s'\n",ts,symbol+offset);
417+
AUTO_TRACE_ADD("partial match '{}'<->'{}'",ts,symbol+offset);
417418
offset+=tl;
418419
}
419420
if (offset==sl) // symbol matches the token(s)
420421
{
421422
CXCursor c = p->cursors[p->curToken];
422423
CXString usr = clang_getCursorUSR(c);
423-
//printf("found full match %s usr='%s'\n",symbol,clang_getCString(usr));
424+
AUTO_TRACE_ADD("found full match {} usr='{}'",symbol,clang_getCString(usr));
424425
result = clang_getCString(usr);
425426
clang_disposeString(usr);
426427
found=TRUE;
@@ -437,14 +438,14 @@ std::string ClangTUParser::lookup(uint32_t line,const char *symbol)
437438
l = getCurrentTokenLine();
438439
}
439440
}
440-
//if (!found)
441-
//{
442-
// printf("Did not find symbol %s at line %d :-(\n",symbol,line);
443-
//}
444-
//else
445-
//{
446-
// printf("Found symbol %s usr=%s\n",symbol,result.data());
447-
//}
441+
if (!found)
442+
{
443+
AUTO_TRACE_EXIT("Did not find symbol {} at line {} :-(",symbol,line);
444+
}
445+
else
446+
{
447+
AUTO_TRACE_EXIT("Found symbol {} usr={}",symbol,result);
448+
}
448449
return result;
449450
}
450451

@@ -705,37 +706,47 @@ void ClangTUParser::linkMacro(OutputCodeList &ol,const FileDef *fd,
705706
void ClangTUParser::linkIdentifier(OutputCodeList &ol,const FileDef *fd,
706707
uint32_t &line,uint32_t &column,const char *text,int tokenIndex)
707708
{
709+
AUTO_TRACE("line={} colum={} text={}",line,column,text);
708710
CXCursor c = p->cursors[tokenIndex];
711+
CXCursorKind cKind = clang_getCursorKind(c);
712+
AUTO_TRACE_ADD("cursor kind={}",(int)cKind);
709713
CXCursor r = clang_getCursorReferenced(c);
714+
AUTO_TRACE_ADD("cursor reference kind={}",(int)clang_getCursorKind(r));
710715
if (!clang_equalCursors(r, c))
711716
{
717+
AUTO_TRACE_ADD("link to referenced location");
712718
c=r; // link to referenced location
713719
}
714-
CXCursor t = clang_getSpecializedCursorTemplate(c);
715-
if (!clang_Cursor_isNull(t) && !clang_equalCursors(t,c))
720+
if (!clang_isDeclaration(cKind))
716721
{
717-
c=t; // link to template
722+
CXCursor t = clang_getSpecializedCursorTemplate(c);
723+
AUTO_TRACE_ADD("cursor template kind={}",(int)clang_getCursorKind(t));
724+
if (!clang_Cursor_isNull(t) && !clang_equalCursors(t,c))
725+
{
726+
c=t; // link to template
727+
}
718728
}
719729
CXString usr = clang_getCursorUSR(c);
720730
const char *usrStr = clang_getCString(usr);
731+
AUTO_TRACE_ADD("usr={}",usrStr);
721732

722733
const Definition *d = nullptr;
723734
auto kv = Doxygen::clangUsrMap->find(usrStr);
724735
if (kv!=Doxygen::clangUsrMap->end())
725736
{
726737
d = kv->second;
727738
}
728-
//CXCursorKind kind = clang_getCursorKind(c);
729-
//if (d==0)
730-
//{
731-
// printf("didn't find definition for '%s' usr='%s' kind=%d\n",
732-
// text,usrStr,kind);
733-
//}
734-
//else
735-
//{
736-
// printf("found definition for '%s' usr='%s' name='%s'\n",
737-
// text,usrStr,d->name().data());
738-
//}
739+
CXCursorKind kind = clang_getCursorKind(c);
740+
if (d==0)
741+
{
742+
AUTO_TRACE_ADD("didn't find definition for '{}' usr='{}' kind={}",
743+
text,usrStr,(int)kind);
744+
}
745+
else
746+
{
747+
AUTO_TRACE_ADD("found definition for '{}' usr='{}' name='{}'",
748+
text,usrStr,d->name().data());
749+
}
739750

740751
if (d && d->isLinkable())
741752
{
@@ -788,6 +799,7 @@ void ClangTUParser::detectFunctionBody(const char *s)
788799

789800
void ClangTUParser::writeSources(OutputCodeList &ol,const FileDef *fd)
790801
{
802+
AUTO_TRACE("file={}",fd->name());
791803
// (re)set global parser state
792804
p->currentMemberDef=nullptr;
793805
p->currentLine=0;

src/scanner.l

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,7 @@ NONLopt [^\n]*
20642064
yyextra->current->bodyColumn = yyextra->yyColNr;
20652065
yyextra->lastInitializerContext = UsingAlias;
20662066
yyextra->initBracketCount=0;
2067+
storeClangId(yyscanner,yyextra->current->name.data());
20672068
BEGIN(ReadInitializer);
20682069
}
20692070
<UsingAlias>";" {
@@ -5884,6 +5885,7 @@ NONLopt [^\n]*
58845885
<CompoundName>{SCOPENAME}/{BN}*"<" {
58855886
yyextra->sharpCount = 0;
58865887
yyextra->current->name = yytext ;
5888+
storeClangId(yyscanner,yytext);
58875889
if (yyextra->current->spec.isProtocol())
58885890
{
58895891
yyextra->current->name+="-p";
@@ -5964,6 +5966,7 @@ NONLopt [^\n]*
59645966
// a purpose of its own
59655967
yyextra->current->name = yytext;
59665968
yyextra->current->name=yyextra->current->name.left(yyextra->current->name.length()-1).stripWhiteSpace();
5969+
storeClangId(yyscanner,yyextra->current->name.data());
59675970
//printf("template class declaration for %s!\n",qPrint(yyextra->current->name));
59685971
QCString rn = yyextra->current_root->name;
59695972
//printf("cn='%s' rn='%s' yyextra->isTypedef=%d\n",qPrint(cn),qPrint(rn),yyextra->isTypedef);
@@ -6017,6 +6020,7 @@ NONLopt [^\n]*
60176020
}
60186021
<CompoundName>{SCOPENAME}/{BN}*"(" {
60196022
yyextra->current->name = yytext ;
6023+
storeClangId(yyscanner,yytext);
60206024
lineCount(yyscanner);
60216025
if (yyextra->insideCpp && yyextra->current->name=="alignas") // C++11
60226026
{
@@ -6047,6 +6051,7 @@ NONLopt [^\n]*
60476051
<AlignAsEnd>.
60486052
<ConceptName>{ID} {
60496053
yyextra->current->name = yytext ;
6054+
storeClangId(yyscanner,yytext);
60506055
}
60516056
<ConceptName>"=" {
60526057
yyextra->current->bodyLine = yyextra->yyLineNr;
@@ -6094,6 +6099,7 @@ NONLopt [^\n]*
60946099
yyextra->yyBegLineNr=yyextra->yyLineNr;
60956100
yyextra->current->name = yytext;
60966101
yyextra->current->name = yyextra->current->name.stripWhiteSpace();
6102+
storeClangId(yyscanner,yyextra->current->name.data());
60976103
lineCount(yyscanner);
60986104
BEGIN( FindMembers );
60996105
}

0 commit comments

Comments
 (0)