@@ -37,8 +37,7 @@ namespace {
3737void CheckInternal::checkTokenMatchPatterns ()
3838{
3939 const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
40- for (std::size_t i = 0 ; i < symbolDatabase->functionScopes .size (); ++i) {
41- const Scope * scope = symbolDatabase->functionScopes [i];
40+ for (const Scope *scope : symbolDatabase->functionScopes ) {
4241 for (const Token* tok = scope->bodyStart ->next (); tok != scope->bodyEnd ; tok = tok->next ()) {
4342 if (!Token::simpleMatch (tok, " Token :: Match (" ) && !Token::simpleMatch (tok, " Token :: findmatch (" ))
4443 continue ;
@@ -130,8 +129,7 @@ void CheckInternal::checkRedundantTokCheckError(const Token* tok)
130129void CheckInternal::checkTokenSimpleMatchPatterns ()
131130{
132131 const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
133- for (std::size_t i = 0 ; i < symbolDatabase->functionScopes .size (); ++i) {
134- const Scope * scope = symbolDatabase->functionScopes [i];
132+ for (const Scope* scope : symbolDatabase->functionScopes ) {
135133 for (const Token* tok = scope->bodyStart ->next (); tok != scope->bodyEnd ; tok = tok->next ()) {
136134 if (!Token::simpleMatch (tok, " Token :: simpleMatch (" ) && !Token::simpleMatch (tok, " Token :: findsimplematch (" ))
137135 continue ;
@@ -151,9 +149,7 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
151149
152150 // Check for [xyz] usage - but exclude standalone square brackets
153151 unsigned int char_count = 0 ;
154- for (std::string::size_type pos = 0 ; pos < pattern.size (); ++pos) {
155- char c = pattern[pos];
156-
152+ for (char c : pattern) {
157153 if (c == ' ' ) {
158154 char_count = 0 ;
159155 } else if (c == ' ]' ) {
@@ -168,9 +164,7 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
168164
169165 // Check | usage: Count characters before the symbol
170166 char_count = 0 ;
171- for (std::string::size_type pos = 0 ; pos < pattern.size (); ++pos) {
172- const char c = pattern[pos];
173-
167+ for (char c : pattern) {
174168 if (c == ' ' ) {
175169 char_count = 0 ;
176170 } else if (c == ' |' ) {
@@ -219,8 +213,7 @@ namespace {
219213void CheckInternal::checkMissingPercentCharacter ()
220214{
221215 const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
222- for (std::size_t i = 0 ; i < symbolDatabase->functionScopes .size (); ++i) {
223- const Scope * scope = symbolDatabase->functionScopes [i];
216+ for (const Scope* scope : symbolDatabase->functionScopes ) {
224217 for (const Token* tok = scope->bodyStart ->next (); tok != scope->bodyEnd ; tok = tok->next ()) {
225218 if (!Token::simpleMatch (tok, " Token :: Match (" ) && !Token::simpleMatch (tok, " Token :: findmatch (" ))
226219 continue ;
@@ -262,8 +255,7 @@ void CheckInternal::checkMissingPercentCharacter()
262255void CheckInternal::checkUnknownPattern ()
263256{
264257 const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
265- for (std::size_t i = 0 ; i < symbolDatabase->functionScopes .size (); ++i) {
266- const Scope * scope = symbolDatabase->functionScopes [i];
258+ for (const Scope* scope : symbolDatabase->functionScopes ) {
267259 for (const Token* tok = scope->bodyStart ->next (); tok != scope->bodyEnd ; tok = tok->next ()) {
268260 if (!Token::simpleMatch (tok, " Token :: Match (" ) && !Token::simpleMatch (tok, " Token :: findmatch (" ))
269261 continue ;
@@ -297,8 +289,7 @@ void CheckInternal::checkUnknownPattern()
297289void CheckInternal::checkRedundantNextPrevious ()
298290{
299291 const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
300- for (std::size_t i = 0 ; i < symbolDatabase->functionScopes .size (); ++i) {
301- const Scope * scope = symbolDatabase->functionScopes [i];
292+ for (const Scope* scope : symbolDatabase->functionScopes ) {
302293 for (const Token* tok = scope->bodyStart ->next (); tok != scope->bodyEnd ; tok = tok->next ()) {
303294 if (tok->str () != " ." )
304295 continue ;
@@ -329,8 +320,7 @@ void CheckInternal::checkRedundantNextPrevious()
329320void CheckInternal::checkExtraWhitespace ()
330321{
331322 const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
332- for (std::size_t i = 0 ; i < symbolDatabase->functionScopes .size (); ++i) {
333- const Scope * scope = symbolDatabase->functionScopes [i];
323+ for (const Scope* scope : symbolDatabase->functionScopes ) {
334324 for (const Token* tok = scope->bodyStart ->next (); tok != scope->bodyEnd ; tok = tok->next ()) {
335325 if (!Token::Match (tok, " Token :: simpleMatch|findsimplematch|Match|findmatch (" ))
336326 continue ;
0 commit comments