1// RUN: %check_clang_tidy %s modernize-loop-convert %t -- \
2// RUN: -config="{CheckOptions: {modernize-loop-convert.NamingStyle: 'UPPER_CASE'}}" \
3// RUN: -- -I %S/Inputs/loop-convert
4
5#include "structures.h"
6
7const int N = 10;
8int ARR[N];
9int NUMS[N];
10int NUMS_[N];
11
12void naming() {
13 for (int I = 0; I < N; ++I) {
14 printf("%d\n", ARR[I]);
15 }
16 // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
17 // CHECK-FIXES: for (int I : ARR)
18 // CHECK-FIXES-NEXT: printf("%d\n", I);
19
20 for (int I = 0; I < N; ++I) {
21 printf("%d\n", NUMS[I]);
22 }
23 // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
24 // CHECK-FIXES: for (int NUM : NUMS)
25 // CHECK-FIXES-NEXT: printf("%d\n", NUM);
26
27 for (int I = 0; I < N; ++I) {
28 printf("%d\n", NUMS_[I]);
29 }
30 // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
31 // CHECK-FIXES: for (int NUM : NUMS_)
32 // CHECK-FIXES-NEXT: printf("%d\n", NUM);
33
34 int NUM = 0;
35 for (int I = 0; I < N; ++I) {
36 printf("%d\n", NUMS[I] + NUM);
37 }
38 // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
39 // CHECK-FIXES: for (int I : NUMS)
40 // CHECK-FIXES-NEXT: printf("%d\n", I + NUM);
41}
42

source code of clang-tools-extra/test/clang-tidy/checkers/modernize/loop-convert-uppercase.cpp