@@ -1319,14 +1319,21 @@ void CheckClass::checkMemset()
13191319
13201320 const Token *typeTok = nullptr ;
13211321 const Scope *type = nullptr ;
1322- if (Token::Match (arg3, " sizeof ( %type% ) )" ))
1323- typeTok = arg3->tokAt (2 );
1324- else if (Token::Match (arg3, " sizeof ( %type% :: %type% ) )" ))
1325- typeTok = arg3->tokAt (4 );
1326- else if (Token::Match (arg3, " sizeof ( struct %type% ) )" ))
1327- typeTok = arg3->tokAt (3 );
1328- else if (Token::simpleMatch (arg3, " sizeof ( * this ) )" ) || Token::simpleMatch (arg1, " this ," )) {
1329- type = findFunctionOf (arg3->scope ());
1322+ const Token* sizeofTok = arg3->previous ()->astOperand2 (); // try to find sizeof() in argument expression
1323+ if (sizeofTok && sizeofTok->astOperand1 () && Token::simpleMatch (sizeofTok->astOperand1 ()->previous (), " sizeof (" ))
1324+ sizeofTok = sizeofTok->astOperand1 ();
1325+ else if (sizeofTok && sizeofTok->astOperand2 () && Token::simpleMatch (sizeofTok->astOperand2 ()->previous (), " sizeof (" ))
1326+ sizeofTok = sizeofTok->astOperand2 ();
1327+ if (Token::simpleMatch (sizeofTok, " (" ))
1328+ sizeofTok = sizeofTok->previous ();
1329+ if (Token::Match (sizeofTok, " sizeof ( %type% )" ))
1330+ typeTok = sizeofTok->tokAt (2 );
1331+ else if (Token::Match (sizeofTok, " sizeof ( %type% :: %type% )" ))
1332+ typeTok = sizeofTok->tokAt (4 );
1333+ else if (Token::Match (sizeofTok, " sizeof ( struct %type% )" ))
1334+ typeTok = sizeofTok->tokAt (3 );
1335+ else if (Token::simpleMatch (sizeofTok, " sizeof ( * this )" ) || Token::simpleMatch (arg1, " this ," )) {
1336+ type = findFunctionOf (sizeofTok->scope ());
13301337 } else if (Token::Match (arg1, " &|*|%var%" )) {
13311338 int numIndirToVariableType = 0 ; // Offset to the actual type in terms of dereference/addressof
13321339 for (;; arg1 = arg1->next ()) {
0 commit comments