================ @@ -0,0 +1,174 @@ +// RUN: %check_clang_tidy -std=c++11 %s modernize-use-uniform-initializer %t + +int cinit_0 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int cinit_0 {0}; + +int cinit_1=0; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int cinit_1{0}; + +int callinit_0(0); +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: Use uniform initializer instead of call-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int callinit_0{0}; + +int callinit_1 ( 0 ); +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use uniform initializer instead of call-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int callinit_1 {0}; + +int callinit_2 ( ((3 + 1 + 4) + 1 + 5) ); +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use uniform initializer instead of call-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int callinit_2 {((3 + 1 + 4) + 1 + 5)}; + +int callinit_3((9-2)+(6+5)); +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: Use uniform initializer instead of call-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int callinit_3{(9-2)+(6+5)}; + +int callinit_4 ((3 * 5 + (8 - 9) )); +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use uniform initializer instead of call-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int callinit_4 {(3 * 5 + (8 - 9) )}; + +int callinit_5((7 + (-9))); +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: Use uniform initializer instead of call-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int callinit_5{(7 + (-9))}; + +int mixed_0 = {0}; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int mixed_0 {0}; + +int mixed_1={0}; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] +// CHECK-FIXES: int mixed_1{0}; + +int noinit; + +int correct_0{0}; + +int correct_1 {0}; + +struct CInitList_0 { + CInitList_0() : x(0) {} + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] + // CHECK-FIXES: CInitList_0() : x{0} {} + + int x; +}; + +struct CInitList_1 { + CInitList_1():x(0) {} + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] + // CHECK-FIXES: CInitList_1():x{0} {} + + int x; +}; + +struct CInitList_2 { + CInitList_2() : x ( 0 ) {} + // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] + // CHECK-FIXES: CInitList_2() : x {0} {} + + int x; +}; + +struct Correct_0 { + Correct_0() : x{0} {} + + int x; +}; + +struct Correct_1 { + Correct_1():x{0} {} + + int x; +}; + +struct InClassInitializers { + int cinit_0 = 0; + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] + // CHECK-FIXES: int cinit_0 {0}; + + int cinit_1=0; + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] + // CHECK-FIXES: int cinit_1{0}; + + int mixed_0 = {0}; + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: Use uniform initializer instead of C-style initializer [modernize-use-uniform-initializer] ---------------- PiotrZSL wrote:
diagnostic in lower case https://github.com/llvm/llvm-project/pull/91124 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits