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
344345std::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,
705706void 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
789800void 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 ;
0 commit comments