| 1 | // RUN: %check_clang_tidy -check-suffixes=UDL-ALLOWED -std=c++14-or-later %s readability-magic-numbers %t \ |
| 2 | // RUN: -config='{CheckOptions: \ |
| 3 | // RUN: {readability-magic-numbers.IgnoreUserDefinedLiterals: false}}' \ |
| 4 | // RUN: -- |
| 5 | // RUN: %check_clang_tidy -check-suffixes=UDL-IGNORED -std=c++14-or-later %s readability-magic-numbers %t \ |
| 6 | // RUN: -config='{CheckOptions: \ |
| 7 | // RUN: {readability-magic-numbers.IgnoreUserDefinedLiterals: true}}' \ |
| 8 | // RUN: -- |
| 9 | |
| 10 | namespace std { |
| 11 | class string {}; |
| 12 | using size_t = decltype(sizeof(int)); |
| 13 | string operator ""s (const char *, std::size_t); |
| 14 | int operator "" s(unsigned long long); |
| 15 | float operator "" s(long double); |
| 16 | } |
| 17 | |
| 18 | void UserDefinedLiteral() { |
| 19 | using std::operator ""s ; |
| 20 | "Hello World"s ; |
| 21 | const int i = 3600s; |
| 22 | int j = 3600s; |
| 23 | // CHECK-MESSAGES-UDL-ALLOWED: :[[@LINE-1]]:11: warning: 3600s is a magic number; consider replacing it with a named constant [readability-magic-numbers] |
| 24 | // CHECK-MESSAGES-UDL-IGNORED-NOT: :[[@LINE-2]]:11: warning: 3600s is a magic number; consider replacing it with a named constant [readability-magic-numbers] |
| 25 | float k = 3600.0s; |
| 26 | // CHECK-MESSAGES-UDL-ALLOWED: :[[@LINE-1]]:13: warning: 3600.0s is a magic number; consider replacing it with a named constant [readability-magic-numbers] |
| 27 | // CHECK-MESSAGES-UDL-IGNORED-NOT: :[[@LINE-1]]:13: warning: 3600.0s is a magic number; consider replacing it with a named constant [readability-magic-numbers] |
| 28 | } |
| 29 | |