@@ -937,10 +937,10 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al
937937 }
938938
939939 if (Token::Match (vartok->previous (), " ++|--|%cop%" )) {
940- if ((! _tokenizer || _tokenizer ->isCPP () ) && alloc == ARRAY && Token::Match (vartok->tokAt (-4 ), " & %var% =|( *" ))
940+ if (_tokenizer->isCPP () && alloc == ARRAY && Token::Match (vartok->tokAt (-4 ), " & %var% =|( *" ))
941941 return false ;
942942
943- if (_tokenizer && _tokenizer ->isCPP () && Token::Match (vartok->previous (), " >>|<<" )) {
943+ if (_tokenizer->isCPP () && Token::Match (vartok->previous (), " >>|<<" )) {
944944 const Token* tok2 = vartok->previous ();
945945 if (Token::simpleMatch (tok2->astOperand1 (), " >>" ))
946946 return false ; // Looks like stream operator, initializes the variable
@@ -1012,7 +1012,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al
10121012 return true ;
10131013 }
10141014
1015- if (_tokenizer && _tokenizer ->isCPP () && Token::Match (vartok->next (), " <<|>>" )) {
1015+ if (_tokenizer->isCPP () && Token::Match (vartok->next (), " <<|>>" )) {
10161016 // Is this calculation done in rhs?
10171017 const Token *tok = vartok;
10181018 while (Token::Match (tok, " %name%|.|::" ))
@@ -1320,15 +1320,19 @@ CheckUninitVar::MyFileInfo::FunctionArg::FunctionArg(const Tokenizer *tokenizer,
13201320 location.linenr = tok->linenr ();
13211321}
13221322
1323- bool CheckUninitVar:: isUnsafeFunction (const Scope *scope, int argnr, const Token **tok) const
1323+ static bool isUnsafeFunction (const Scope *scope, int argnr, const Token **tok)
13241324{
13251325 const Variable * const argvar = scope->function ->getArgumentVar (argnr);
13261326 if (!argvar->isPointer ())
13271327 return false ;
13281328 for (const Token *tok2 = scope->classStart ; tok2 != scope->classEnd ; tok2 = tok2->next ()) {
13291329 if (tok2->variable () != argvar)
13301330 continue ;
1331- if (!isVariableUsage (tok2, true , Alloc::ARRAY))
1331+ if (!Token::Match (tok2->astParent (), " *|[" ))
1332+ return false ;
1333+ while (Token::Match (tok2->astParent (), " *|[" ))
1334+ tok2 = tok2->astParent ();
1335+ if (!Token::Match (tok2->astParent ()," %cop%" ))
13321336 return false ;
13331337 *tok = tok2;
13341338 return true ;
0 commit comments