Refactoring: Use range for loop
This commit is contained in:
parent
3fdb2da0d1
commit
2073bd02d8
|
@ -185,9 +185,7 @@ void CheckAutoVariables::assignFunctionArg()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
for (const Scope * scope : symbolDatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
|
||||||
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
||||||
// TODO: What happens if this is removed?
|
// TODO: What happens if this is removed?
|
||||||
if (tok->astParent())
|
if (tok->astParent())
|
||||||
|
@ -228,9 +226,7 @@ void CheckAutoVariables::autoVariables()
|
||||||
{
|
{
|
||||||
const bool printInconclusive = _settings->inconclusive;
|
const bool printInconclusive = _settings->inconclusive;
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
for (const Scope * scope : symbolDatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
|
||||||
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
||||||
// Critical assignment
|
// Critical assignment
|
||||||
if (Token::Match(tok, "[;{}] %var% = & %var%") && isRefPtrArg(tok->next()) && isAutoVar(tok->tokAt(4))) {
|
if (Token::Match(tok, "[;{}] %var% = & %var%") && isRefPtrArg(tok->next()) && isAutoVar(tok->tokAt(4))) {
|
||||||
|
@ -331,9 +327,7 @@ void CheckAutoVariables::returnPointerToLocalArray()
|
||||||
{
|
{
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
|
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
for (const Scope * scope : symbolDatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
|
||||||
if (!scope->function)
|
if (!scope->function)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -517,9 +511,7 @@ void CheckAutoVariables::returnReference()
|
||||||
|
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
|
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
for (const Scope * scope : symbolDatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
|
||||||
if (!scope->function)
|
if (!scope->function)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue