@@ -1288,6 +1288,57 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
12881288 (tok->previous ()->isName () || tok->strAt (-1 ) == " >" || tok->strAt (-1 ) == " &" || tok->strAt (-1 ) == " *" || // Either a return type in front of tok
12891289 tok->strAt (-1 ) == " ::" || tok->strAt (-1 ) == " ~" || // or a scope qualifier in front of tok
12901290 outerScope->isClassOrStruct ())) { // or a ctor/dtor
1291+
1292+ const Token* tok1 = tok->previous ();
1293+
1294+ // skip over destructor "~"
1295+ if (tok1->str () == " ~" )
1296+ tok1 = tok1->previous ();
1297+
1298+ // skip over qualification
1299+ while (Token::simpleMatch (tok1, " ::" )) {
1300+ if (Token::Match (tok1->tokAt (-1 ), " %name%" ))
1301+ tok1 = tok1->tokAt (-2 );
1302+ else
1303+ tok1 = tok1->tokAt (-1 );
1304+ }
1305+
1306+ // skip over pointers and references
1307+ while (Token::Match (tok1, " [*&]" ))
1308+ tok1 = tok1->tokAt (-1 );
1309+
1310+ // skip over template
1311+ if (tok1 && tok1->str () == " >" ) {
1312+ if (tok1->link ())
1313+ tok1 = tok1->link ()->previous ();
1314+ else
1315+ return false ;
1316+ }
1317+
1318+ // function can't have number or variable as return type
1319+ if (tok1 && (tok1->isNumber () || tok1->varId ()))
1320+ return false ;
1321+
1322+ // skip over return type
1323+ if (Token::Match (tok1, " %name%" ))
1324+ tok1 = tok1->previous ();
1325+
1326+ // skip over qualification
1327+ while (Token::simpleMatch (tok1, " ::" )) {
1328+ if (Token::Match (tok1->tokAt (-1 ), " %name%" ))
1329+ tok1 = tok1->tokAt (-2 );
1330+ else
1331+ tok1 = tok1->tokAt (-1 );
1332+ }
1333+
1334+ // skip over modifiers and other stuff
1335+ while (Token::Match (tok1, " const|static|extern|template|virtual|struct|class" ))
1336+ tok1 = tok1->previous ();
1337+
1338+ // should be at a sequence point if this is a function
1339+ if (!Token::Match (tok1, " >|{|}|;|public:|protected:|private:" ) && tok1)
1340+ return false ;
1341+
12911342 const Token* tok2 = tok->next ()->link ()->next ();
12921343 if (tok2 &&
12931344 (Token::Match (tok2, " const| ;|{|=" ) ||
0 commit comments