@@ -424,7 +424,13 @@ const std::string &Token::strAt(int index) const
424424 return tok ? tok->mStr : emptyString;
425425}
426426
427- static int multiComparePercent (const Token *tok, const char *& haystack, nonneg int varid)
427+ static
428+ #if defined(__GNUC__)
429+ // GCC does not inline this by itself
430+ // need to use the old syntax since the C++11 [[xxx:always_inline]] cannot be used here
431+ inline __attribute__ ((always_inline))
432+ #endif
433+ int multiComparePercent (const Token *tok, const char *& haystack, nonneg int varid)
428434{
429435 ++haystack;
430436 // Compare only the first character of the string for optimization reasons
@@ -556,7 +562,12 @@ static int multiComparePercent(const Token *tok, const char*& haystack, nonneg i
556562 return 0xFFFF ;
557563}
558564
559- int Token::multiCompare (const Token *tok, const char *haystack, nonneg int varid)
565+ static
566+ #if defined(__GNUC__)
567+ // need to use the old syntax since the C++11 [[xxx:always_inline]] cannot be used here
568+ inline __attribute__ ((always_inline))
569+ #endif
570+ int multiCompareImpl (const Token *tok, const char *haystack, nonneg int varid)
560571{
561572 const char *needle = tok->str ().c_str ();
562573 const char *needlePointer = needle;
@@ -609,6 +620,12 @@ int Token::multiCompare(const Token *tok, const char *haystack, nonneg int varid
609620 return -1 ;
610621}
611622
623+ // cppcheck-suppress unusedFunction - used in tests only
624+ int Token::multiCompare (const Token *tok, const char *haystack, nonneg int varid)
625+ {
626+ return multiCompareImpl (tok, haystack, varid);
627+ }
628+
612629bool Token::simpleMatch (const Token *tok, const char pattern[], size_t pattern_len)
613630{
614631 if (!tok)
@@ -730,7 +747,7 @@ bool Token::Match(const Token *tok, const char pattern[], nonneg int varid)
730747
731748 // Parse multi options, such as void|int|char (accept token which is one of these 3)
732749 else {
733- const int res = multiCompare (tok, p, varid);
750+ const int res = multiCompareImpl (tok, p, varid);
734751 if (res == 0 ) {
735752 // Empty alternative matches, use the same token on next round
736753 while (*p && *p != ' ' )
0 commit comments