1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <tuple>
struct A{
int a;
int b;
};
A aggregate_with_very_very_very_long_name = {1, 2};
int UnsafeIndex();
void Test() {
// Expected rewrite:
// std::array<A, 1> a_1 = {{{1, 2}}};
A a_1[1] = {{1, 2}};
std::ignore = a_1[UnsafeIndex()];
// Expected rewrite:
// std::array<A, 2> a_2 = {{{1, 2}, {3, 4}}};
A a_2[2] = {{1, 2}, {3, 4}};
std::ignore = a_2[UnsafeIndex()];
// Expected rewrite:
// std::array<A, 2> a_2_long = {aggregate_with_very_very_very_long_name,
// aggregate_with_very_very_very_long_name};
A a_2_long[2] = {aggregate_with_very_very_very_long_name,
aggregate_with_very_very_very_long_name};
std::ignore = a_2_long[UnsafeIndex()];
// Expected rewrite:
// std::array<A, 5> a_5 = {{
// {1, 2},
// {3, 4},
// {5, 6},
// {7, 8},
// {9, 10},
// }};
A a_5[5] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}};
std::ignore = a_5[UnsafeIndex()];
// Expected rewrite:
// std::array<A, 5> a_5_long = {{
// {1, 2},
// {3, 4},
// aggregate_with_very_very_very_long_name,
// {7, 8},
// {9, 10},
// }};
A a_5_long[5] = {
{1, 2}, {3, 4}, aggregate_with_very_very_very_long_name, {7, 8}, {9, 10}};
std::ignore = a_5_long[UnsafeIndex()];
// Expected rewrite:
// std::array<A, 6> a_6 = {{
// {1, 2},
// {3, 4},
// {5, 6},
// {7, 8},
// {9, 10},
// {11, 12},
// }};
A a_6[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}};
std::ignore = a_6[UnsafeIndex()];
// Expected rewrite:
// std::array<A, 6> a_6_with_new_line = {{
// {1, 2},
// {3, 4},
// {5, 6},
// {7, 8},
// {9, 10},
// {11, 12},
// }};
A a_6_with_new_line[6] = {
{1, 2}, {3, 4}, {5, 6},
{7, 8}, {9, 10}, {11, 12}
};
std::ignore = a_6_with_new_line[UnsafeIndex()];
// Expected rewrite:
// std::array<A, 5> a_5_with_trailing_comma = {{
// {1, 2},
// {3, 4},
// {5, 6},
// {7, 8},
// {9, 10},
// }};
A a_5_with_trailing_comma[5] = {
{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10},
};
std::ignore = a_5_with_trailing_comma[UnsafeIndex()];
// Expected rewrite:
// std::array<A, 5> a_5_with_trailing_comma_2 = {{
// {1, 2},
// {3, 4},
// {5, 6},
// {7, 8},
// {9, 10},
// }};
A a_5_with_trailing_comma_2[5] = {
{1, 2},
{3, 4},
{5, 6},
{7, 8},
{9, 10},
};
std::ignore = a_5_with_trailing_comma_2[UnsafeIndex()];
}
|