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

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