@@ -1382,7 +1382,7 @@ void CheckIO::checkFormatString(const Token * const tok,
13821382// We currently only support string literals, variables, and functions.
13831383// / @todo add non-string literals, and generic expressions
13841384
1385- CheckIO::ArgumentInfo::ArgumentInfo (const Token * tok , const Settings *settings, bool _isCPP)
1385+ CheckIO::ArgumentInfo::ArgumentInfo (const Token * arg , const Settings *settings, bool _isCPP)
13861386 : variableInfo(nullptr )
13871387 , typeToken(nullptr )
13881388 , functionInfo(nullptr )
@@ -1392,14 +1392,14 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings,
13921392 , address(false )
13931393 , isCPP(_isCPP)
13941394{
1395- if (!tok )
1395+ if (!arg )
13961396 return ;
13971397
13981398 // Use AST type info
13991399 // TODO: This is a bailout so that old code is used in simple cases. Remove the old code and always use the AST type.
1400- if (!Token::Match (tok , " %str% ,|)" ) && !(Token::Match (tok ," %var%" ) && tok ->variable () && tok ->variable ()->isArray ())) {
1401- const Token *top = tok ;
1402- while (top->astParent () && top->astParent ()->str () != " ," && top->astParent () != tok ->previous ())
1400+ if (!Token::Match (arg , " %str% ,|)" ) && !(Token::Match (arg ," %var%" ) && arg ->variable () && arg ->variable ()->isArray ())) {
1401+ const Token *top = arg ;
1402+ while (top->astParent () && top->astParent ()->str () != " ," && top->astParent () != arg ->previous ())
14031403 top = top->astParent ();
14041404 const ValueType *valuetype = top->argumentType ();
14051405 if (valuetype && valuetype->type >= ValueType::Type::BOOL) {
@@ -1446,30 +1446,30 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings,
14461446 }
14471447
14481448
1449- if (tok ->tokType () == Token::eString) {
1450- typeToken = tok ;
1449+ if (arg ->tokType () == Token::eString) {
1450+ typeToken = arg ;
14511451 return ;
1452- } else if (tok ->str () == " &" || tok ->tokType () == Token::eVariable ||
1453- tok ->tokType () == Token::eFunction || Token::Match (tok , " %type% ::" ) ||
1454- (Token::Match (tok , " static_cast|reinterpret_cast|const_cast <" ) &&
1455- Token::simpleMatch (tok ->linkAt (1 ), " > (" ) &&
1456- Token::Match (tok ->linkAt (1 )->linkAt (1 ), " ) ,|)" ))) {
1457- if (Token::Match (tok , " static_cast|reinterpret_cast|const_cast" )) {
1458- typeToken = tok ->tokAt (2 );
1452+ } else if (arg ->str () == " &" || arg ->tokType () == Token::eVariable ||
1453+ arg ->tokType () == Token::eFunction || Token::Match (arg , " %type% ::" ) ||
1454+ (Token::Match (arg , " static_cast|reinterpret_cast|const_cast <" ) &&
1455+ Token::simpleMatch (arg ->linkAt (1 ), " > (" ) &&
1456+ Token::Match (arg ->linkAt (1 )->linkAt (1 ), " ) ,|)" ))) {
1457+ if (Token::Match (arg , " static_cast|reinterpret_cast|const_cast" )) {
1458+ typeToken = arg ->tokAt (2 );
14591459 while (typeToken->str () == " const" || typeToken->str () == " extern" )
14601460 typeToken = typeToken->next ();
14611461 return ;
14621462 }
1463- if (tok ->str () == " &" ) {
1463+ if (arg ->str () == " &" ) {
14641464 address = true ;
1465- tok = tok ->next ();
1465+ arg = arg ->next ();
14661466 }
1467- while (Token::Match (tok , " %type% ::" ))
1468- tok = tok ->tokAt (2 );
1469- if (!tok || !(tok ->tokType () == Token::eVariable || tok ->tokType () == Token::eFunction))
1467+ while (Token::Match (arg , " %type% ::" ))
1468+ arg = arg ->tokAt (2 );
1469+ if (!arg || !(arg ->tokType () == Token::eVariable || arg ->tokType () == Token::eFunction))
14701470 return ;
14711471 const Token *varTok = nullptr ;
1472- const Token *tok1 = tok ->next ();
1472+ const Token *tok1 = arg ->next ();
14731473 for (; tok1; tok1 = tok1->next ()) {
14741474 if (tok1->str () == " ," || tok1->str () == " )" ) {
14751475 if (tok1->previous ()->str () == " ]" ) {
0 commit comments