1// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-unary-static-assert %t
2
3#define FOO static_assert(sizeof(a) <= 15, "");
4#define MSG ""
5
6void f_textless(int a) {
7 static_assert(sizeof(a) <= 10, "");
8 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use unary 'static_assert' when the string literal is an empty string [modernize-unary-static-assert]
9 // CHECK-FIXES: {{^}} static_assert(sizeof(a) <= 10 );{{$}}
10 FOO
11 // CHECK-FIXES: {{^}} FOO{{$}}
12 static_assert(sizeof(a) <= 17, MSG);
13 // CHECK-FIXES: {{^}} static_assert(sizeof(a) <= 17, MSG);{{$}}
14}
15
16void f_with_tex(int a) {
17 static_assert(sizeof(a) <= 10, "Size of variable a is out of range!");
18}
19
20void f_unary(int a) { static_assert(sizeof(a) <= 10); }
21
22void f_incorrect_assert() { static_assert(""); }
23

source code of clang-tools-extra/test/clang-tidy/checkers/modernize/unary-static-assert.cpp