From b19ad9cda58288d727861bdd0a9d2a7cedc7c1a6 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Fri, 11 Jul 2025 11:35:50 -0700 Subject: [PATCH 1/7] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes --- .../UppercaseLiteralSuffixCheck.cpp | 13 +- clang-tools-extra/docs/ReleaseNotes.rst | 4 + .../uppercase-literal-suffix-c23.c | 162 ++++++++++++ ...literal-suffix-extended-floating-point.cpp | 248 ++++++++++++++++++ .../uppercase-literal-suffix-float16.cpp | 51 ---- .../uppercase-literal-suffix-integer.cpp | 86 +++++- 6 files changed, 506 insertions(+), 58 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c create mode 100644 clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp diff --git a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp index 678aa8dad48a7..dd43ee200f4c0 100644 --- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp @@ -25,10 +25,11 @@ struct IntegerLiteralCheck { static constexpr llvm::StringLiteral Name = llvm::StringLiteral("integer"); // What should be skipped before looking for the Suffixes? (Nothing here.) static constexpr llvm::StringLiteral SkipFirst = llvm::StringLiteral(""); - // Suffix can only consist of 'u' and 'l' chars, and can be a complex number - // ('i', 'j'). In MS compatibility mode, suffixes like i32 are supported. + // Suffix can only consist of 'u', 'l', and 'z' chars, can be a bit-precise + // integer (wb), and can be a complex number ('i', 'j'). In MS compatibility + // mode, suffixes like i32 are supported. static constexpr llvm::StringLiteral Suffixes = - llvm::StringLiteral("uUlLiIjJ"); + llvm::StringLiteral("uUlLzZwWbBiIjJ"); }; constexpr llvm::StringLiteral IntegerLiteralCheck::Name; constexpr llvm::StringLiteral IntegerLiteralCheck::SkipFirst; @@ -45,10 +46,10 @@ struct FloatingLiteralCheck { // Since the exponent ('p'/'P') is mandatory for hexadecimal floating-point // literals, we first skip everything before the exponent. static constexpr llvm::StringLiteral SkipFirst = llvm::StringLiteral("pP"); - // Suffix can only consist of 'f', 'l', "f16", 'h', 'q' chars, - // and can be a complex number ('i', 'j'). + // Suffix can only consist of 'f', 'l', "f16", "bf16", "df", "dd", "dl", + // 'h', 'q' chars, and can be a complex number ('i', 'j'). static constexpr llvm::StringLiteral Suffixes = - llvm::StringLiteral("fFlLhHqQiIjJ"); + llvm::StringLiteral("fFlLbBdDhHqQiIjJ"); }; constexpr llvm::StringLiteral FloatingLiteralCheck::Name; constexpr llvm::StringLiteral FloatingLiteralCheck::SkipFirst; diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index ad869265a2db5..119c030b43852 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -354,6 +354,10 @@ Changes in existing checks ` check by fixing some false positives involving smart pointers to arrays. +- Improved :doc:`readability-uppercase-literal-suffix + ` check to recognize + literal suffixes added in C++23 and C23. + Removed checks ^^^^^^^^^^^^^^ diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c new file mode 100644 index 0000000000000..75727fc69e68c --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c @@ -0,0 +1,162 @@ +// TODO: When Clang adds support for decimal floating point types, enable these tests by: +// 1. Removing all the #if 0 + #endif guards. +// 2. Removing all occurrences of the string "DISABLED-" in this file. +// 3. Deleting this message. + +// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -std=c23 +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.c +// RUN: clang-tidy %t.c -checks='-*,readability-uppercase-literal-suffix' -fix -- -std=c23 +// RUN: clang-tidy %t.c -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -std=c23 + +void bit_precise_literal_suffix() { + // _BitInt() + + static constexpr auto v1 = 1wb; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wb', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1wb; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: WB{{$}} + // CHECK-FIXES: static constexpr auto v1 = 1WB; + static_assert(v1 == 1WB); + + static constexpr auto v2 = 1WB; // OK. + static_assert(v2 == 1WB); + + // _BitInt() Unsigned + + static constexpr auto v3 = 1wbu; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wbu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1wbu; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: WBU{{$}} + // CHECK-FIXES: static constexpr auto v3 = 1WBU; + static_assert(v3 == 1WBU); + + static constexpr auto v4 = 1WBu; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'WBu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v4 = 1WBu; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: WBU{{$}} + // CHECK-FIXES: static constexpr auto v4 = 1WBU; + static_assert(v4 == 1WBU); + + static constexpr auto v5 = 1wbU; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wbU', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1wbU; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: WBU{{$}} + // CHECK-FIXES: static constexpr auto v5 = 1WBU; + static_assert(v5 == 1WBU); + + static constexpr auto v6 = 1WBU; // OK. + static_assert(v6 == 1WBU); + + // Unsigned _BitInt() + + static constexpr auto v7 = 1uwb; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'uwb', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1uwb; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: UWB{{$}} + // CHECK-FIXES: static constexpr auto v7 = 1UWB; + static_assert(v7 == 1UWB); + + static constexpr auto v8 = 1uWB; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'uWB', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v8 = 1uWB; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: UWB{{$}} + // CHECK-FIXES: static constexpr auto v8 = 1UWB; + static_assert(v8 == 1UWB); + + static constexpr auto v9 = 1Uwb; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'Uwb', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1Uwb; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: UWB{{$}} + // CHECK-FIXES: static constexpr auto v9 = 1UWB; + static_assert(v9 == 1UWB); + + static constexpr auto v10 = 1UWB; // OK. + static_assert(v10 == 1UWB); +} + +void decimal_floating_point_suffix() { + // _Decimal32 + +#if 0 + static constexpr auto v1 = 1.df; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'df', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1.df; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DF{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v1 = 1.DF; + static_assert(v1 == 1.DF); + + static constexpr auto v2 = 1.e0df; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'df', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v2 = 1.e0df; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DF{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v2 = 1.e0DF; + static_assert(v2 == 1.DF); + + static constexpr auto v3 = 1.DF; // OK. + static_assert(v3 == 1.DF); + + static constexpr auto v4 = 1.e0DF; // OK. + static_assert(v4 == 1.DF); +#endif + + // _Decimal64 + +#if 0 + static constexpr auto v5 = 1.dd; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dd', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1.dd; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DD{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v5 = 1.DD; + static_assert(v5 == 1.DD); + + static constexpr auto v6 = 1.e0dd; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dd', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v6 = 1.e0dd; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DD{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v6 = 1.e0DD; + static_assert(v6 == 1.DD); + + static constexpr auto v7 = 1.DD; // OK. + static_assert(v7 == 1.DD); + + static constexpr auto v8 = 1.e0DD; // OK. + static_assert(v8 == 1.DD); +#endif + + // _Decimal128 + +#if 0 + static constexpr auto v9 = 1.dl; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dl', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1.dl; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DL{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v9 = 1.DL; + static_assert(v9 == 1.DL); + + static constexpr auto v10 = 1.e0dl; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'dl', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1.e0dl; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DL{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v10 = 1.e0DL; + static_assert(v10 == 1.DL); + + static constexpr auto v11 = 1.DL; // OK. + static_assert(v11 == 1.DL); + + static constexpr auto v12 = 1.e0DL; // OK. + static_assert(v12 == 1.DL); +#endif +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp new file mode 100644 index 0000000000000..abe23e3363766 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp @@ -0,0 +1,248 @@ +// TODO: When Clang adds support for C++23 floating-point types, enable these tests by: +// 1. Removing all the #if 0 + #endif guards. +// 2. Removing all occurrences of the string "DISABLED-" in this file. +// 3. Deleting this message. +// These suffixes may be relevant to C too: https://github.com/llvm/llvm-project/issues/97335 + +// RUN: %check_clang_tidy -std=c++23 %s readability-uppercase-literal-suffix %t -- -- -target aarch64-linux-gnu -I %clang_tidy_headers + +#include "integral_constant.h" +#if 0 +#include +#endif + +void normal_literals() { + // std::bfloat16_t + +#if 0 + static constexpr auto v1 = 1.bf16; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1.bf16; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v1 = 1.BF16; + static_assert(is_same::value, ""); + static_assert(v1 == 1.BF16, ""); + + static constexpr auto v2 = 1.e0bf16; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v2 = 1.e0bf16; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v2 = 1.e0BF16; + static_assert(is_same::value, ""); + static_assert(v2 == 1.BF16, ""); + + static constexpr auto v3 = 1.BF16; // OK. + static_assert(is_same::value, ""); + static_assert(v3 == 1.BF16, ""); + + static constexpr auto v4 = 1.e0BF16; // OK. + static_assert(is_same::value, ""); + static_assert(v4 == 1.BF16, ""); +#endif + + // _Float16/std::float16_t + + static constexpr auto v5 = 1.f16; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1.f16; + // CHECK-MESSAGES-NEXT: ^ ~ + // CHECK-MESSAGES-NEXT: F16{{$}} + // CHECK-FIXES: static constexpr auto v5 = 1.F16; + static_assert(is_same::value, ""); + static_assert(v5 == 1.F16, ""); + + static constexpr auto v6 = 1.e0f16; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v6 = 1.e0f16; + // CHECK-MESSAGES-NEXT: ^ ~ + // CHECK-MESSAGES-NEXT: F16{{$}} + // CHECK-FIXES: static constexpr auto v6 = 1.e0F16; + static_assert(is_same::value, ""); + static_assert(v6 == 1.F16, ""); + + static constexpr auto v7 = 1.F16; // OK. + static_assert(is_same::value, ""); + static_assert(v7 == 1.F16, ""); + + static constexpr auto v8 = 1.e0F16; // OK. + static_assert(is_same::value, ""); + static_assert(v8 == 1.F16, ""); + + // std::float32_t + +#if 0 + static constexpr auto v9 = 1.f32; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f32', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1.f32; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v9 = 1.F32; + static_assert(is_same::value, ""); + static_assert(v9 == 1.F32, ""); + + static constexpr auto v10 = 1.e0f32; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f32', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1.e0f32; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v10 = 1.e0F32; + static_assert(is_same::value, ""); + static_assert(v10 == 1.F32, ""); + + static constexpr auto v11 = 1.F32; // OK. + static_assert(is_same::value, ""); + static_assert(v11 == 1.F32, ""); + + static constexpr auto v12 = 1.e0F32; // OK. + static_assert(is_same::value, ""); + static_assert(v12 == 1.F32, ""); +#endif + + // std::float64_t + +#if 0 + static constexpr auto v13 = 1.f64; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f64', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v13 = 1.f64; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v13 = 1.F64; + static_assert(is_same::value, ""); + static_assert(v13 == 1.F64, ""); + + static constexpr auto v14 = 1.e0f64; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f64', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.e0f64; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v14 = 1.e0F64; + static_assert(is_same::value, ""); + static_assert(v14 == 1.F64, ""); + + static constexpr auto v15 = 1.F64; // OK. + static_assert(is_same::value, ""); + static_assert(v15 == 1.F64, ""); + + static constexpr auto v16 = 1.e0F64; // OK. + static_assert(is_same::value, ""); + static_assert(v16 == 1.F64, ""); +#endif + + // std::float128_t + +#if 0 + static constexpr auto v17 = 1.f128; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f128', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v17 = 1.f128; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v17 = 1.F128; + static_assert(is_same::value, ""); + static_assert(v17 == 1.F128, ""); + + static constexpr auto v18 = 1.e0f128; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f128', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v18 = 1.e0f128; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v18 = 1.e0F128; + static_assert(is_same::value, ""); + static_assert(v18 == 1.F128, ""); + + static constexpr auto v19 = 1.F128; // OK. + static_assert(is_same::value, ""); + static_assert(v19 == 1.F128, ""); + + static constexpr auto v20 = 1.e0F128; // OK. + static_assert(is_same::value, ""); + static_assert(v20 == 1.F128, ""); +#endif +} + +void hexadecimal_literals() { + // std::bfloat16_t + +#if 0 + static constexpr auto v1 = 0xfp0bf16; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 0xfp0bf16; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v1 = 0xfp0BF16; + static_assert(is_same::value, ""); + static_assert(v1 == 0xfp0BF16, ""); + + static constexpr auto v2 = 0xfp0BF16; // OK. + static_assert(is_same::value, ""); + static_assert(v2 == 0xfp0BF16, ""); +#endif + + // _Float16/std::float16_t + + static constexpr auto v3 = 0xfp0f16; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 0xfp0f16; + // CHECK-MESSAGES-NEXT: ^ ~ + // CHECK-MESSAGES-NEXT: F16{{$}} + // CHECK-FIXES: static constexpr auto v3 = 0xfp0F16; + static_assert(is_same::value, ""); + static_assert(v3 == 0xfp0F16, ""); + + static constexpr auto v4 = 0xfp0F16; // OK. + static_assert(is_same::value, ""); + static_assert(v4 == 0xfp0F16, ""); + + // std::float32_t + +#if 0 + static constexpr auto v5 = 0xfp0f32; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f32', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v5 = 0xfp0f32; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v5 = 0xfp0F32; + static_assert(is_same::value, ""); + static_assert(v5 == 0xfp0F32, ""); + + static constexpr auto v6 = 0xfp0F32; // OK. + static_assert(is_same::value, ""); + static_assert(v6 == 0xfp0F32, ""); +#endif + + // std::float64_t + +#if 0 + static constexpr auto v7 = 0xfp0f64; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f64', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v7 = 0xfp0f64; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v7 = 0xfp0F64; + static_assert(is_same::value, ""); + static_assert(v7 == 0xfp0F64, ""); + + static constexpr auto v8 = 0xfp0F64; // OK. + static_assert(is_same::value, ""); + static_assert(v8 == 0xfp0F64, ""); +#endif + + // std::float128_t + +#if 0 + static constexpr auto v9 = 0xfp0f128; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f128', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 0xfp0f128; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v9 = 0xfp0F128; + static_assert(is_same::value, ""); + static_assert(v9 == 0xfp0F128, ""); + + static constexpr auto v10 = 0xfp0F128; // OK. + static_assert(is_same::value, ""); + static_assert(v10 == 0xfp0F128, ""); +#endif + +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp deleted file mode 100644 index 46d7bc1347d0d..0000000000000 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -target aarch64-linux-gnu -I %clang_tidy_headers - -#include "integral_constant.h" - -void float16_normal_literals() { - // _Float16 - - static constexpr auto v14 = 1.f16; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} - // CHECK-FIXES: static constexpr auto v14 = 1.F16; - static_assert(is_same::value, ""); - static_assert(v14 == 1.F16, ""); - - static constexpr auto v15 = 1.e0f16; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1.e0f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} - // CHECK-FIXES: static constexpr auto v15 = 1.e0F16; - static_assert(is_same::value, ""); - static_assert(v15 == 1.F16, ""); - - static constexpr auto v16 = 1.F16; // OK. - static_assert(is_same::value, ""); - static_assert(v16 == 1.F16, ""); - - static constexpr auto v17 = 1.e0F16; // OK. - static_assert(is_same::value, ""); - static_assert(v17 == 1.F16, ""); -} - -void float16_hexadecimal_literals() { -// _Float16 - - static constexpr auto v13 = 0xfp0f16; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 0xfp0f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} - // CHECK-FIXES: static constexpr auto v13 = 0xfp0F16; - static_assert(is_same::value, ""); - static_assert(v13 == 0xfp0F16, ""); - - static constexpr auto v14 = 0xfp0F16; // OK. - static_assert(is_same::value, ""); - static_assert(v14 == 0xfp0F16, ""); - -} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp index 084d9f68e0b5e..29f85749e9d55 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp @@ -4,10 +4,11 @@ // RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %clang_tidy_headers #include "integral_constant.h" +#include void integer_suffix() { static constexpr auto v0 = __LINE__; // synthetic - static_assert(v0 == 9 || v0 == 5, ""); + static_assert(v0 == 10 || v0 == 6, ""); static constexpr auto v1 = __cplusplus; // synthetic, long @@ -225,6 +226,89 @@ void integer_complex_suffix() { static_assert(v28 == 1J, ""); } +// This is a C++23 feature, but Clang supports it in earlier language modes +// as an extension, so we test it unconditionally. +void size_t_suffix() { + // Signed + + static constexpr auto v29 = 1z; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'z', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v29 = 1z; + // CHECK-MESSAGES-NEXT: ^~ + // CHECK-MESSAGES-NEXT: Z{{$}} + // CHECK-FIXES: static constexpr auto v29 = 1Z; + static_assert(v29 == 1Z, ""); + + static constexpr auto v30 = 1Z; // OK. + static_assert(v30 == 1Z, ""); + + // size_t Unsigned + + static constexpr auto v31 = 1zu; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v31 = 1zu; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v31 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v31 == 1ZU, ""); + + static constexpr auto v32 = 1Zu; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Zu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v32 = 1Zu; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v32 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v32 == 1ZU, ""); + + static constexpr auto v33 = 1zU; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zU', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v33 = 1zU; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v33 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v33 == 1ZU, ""); + + static constexpr auto v34 = 1ZU; // OK. + static_assert(is_same::value, ""); + static_assert(v34 == 1ZU, ""); + + // Unsigned size_t + + static constexpr auto v35 = 1uz; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uz', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v35 = 1uz; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v35 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v35 == 1UZ); + + static constexpr auto v36 = 1uZ; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uZ', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v36 = 1uZ; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v36 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v36 == 1UZ); + + static constexpr auto v37 = 1Uz; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Uz', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v37 = 1Uz; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v37 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v37 == 1UZ); + + static constexpr auto v38 = 1UZ; // OK. + static_assert(is_same::value, ""); + static_assert(v38 == 1UZ); +} + void macros() { #define PASSTHROUGH(X) X static constexpr auto m0 = PASSTHROUGH(1u); From 4b627b99ce73f37ec4a2e2966c021e3f10fdbe88 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Fri, 11 Jul 2025 11:35:50 -0700 Subject: [PATCH 2/7] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes --- .../UppercaseLiteralSuffixCheck.cpp | 13 +- clang-tools-extra/docs/ReleaseNotes.rst | 4 + .../uppercase-literal-suffix-c23.c | 162 ++++++++++++ ...literal-suffix-extended-floating-point.cpp | 248 ++++++++++++++++++ .../uppercase-literal-suffix-float16.cpp | 51 ---- .../uppercase-literal-suffix-integer.cpp | 86 +++++- 6 files changed, 506 insertions(+), 58 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c create mode 100644 clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp diff --git a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp index 678aa8dad48a7..dd43ee200f4c0 100644 --- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp @@ -25,10 +25,11 @@ struct IntegerLiteralCheck { static constexpr llvm::StringLiteral Name = llvm::StringLiteral("integer"); // What should be skipped before looking for the Suffixes? (Nothing here.) static constexpr llvm::StringLiteral SkipFirst = llvm::StringLiteral(""); - // Suffix can only consist of 'u' and 'l' chars, and can be a complex number - // ('i', 'j'). In MS compatibility mode, suffixes like i32 are supported. + // Suffix can only consist of 'u', 'l', and 'z' chars, can be a bit-precise + // integer (wb), and can be a complex number ('i', 'j'). In MS compatibility + // mode, suffixes like i32 are supported. static constexpr llvm::StringLiteral Suffixes = - llvm::StringLiteral("uUlLiIjJ"); + llvm::StringLiteral("uUlLzZwWbBiIjJ"); }; constexpr llvm::StringLiteral IntegerLiteralCheck::Name; constexpr llvm::StringLiteral IntegerLiteralCheck::SkipFirst; @@ -45,10 +46,10 @@ struct FloatingLiteralCheck { // Since the exponent ('p'/'P') is mandatory for hexadecimal floating-point // literals, we first skip everything before the exponent. static constexpr llvm::StringLiteral SkipFirst = llvm::StringLiteral("pP"); - // Suffix can only consist of 'f', 'l', "f16", 'h', 'q' chars, - // and can be a complex number ('i', 'j'). + // Suffix can only consist of 'f', 'l', "f16", "bf16", "df", "dd", "dl", + // 'h', 'q' chars, and can be a complex number ('i', 'j'). static constexpr llvm::StringLiteral Suffixes = - llvm::StringLiteral("fFlLhHqQiIjJ"); + llvm::StringLiteral("fFlLbBdDhHqQiIjJ"); }; constexpr llvm::StringLiteral FloatingLiteralCheck::Name; constexpr llvm::StringLiteral FloatingLiteralCheck::SkipFirst; diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 4fee4f93908da..59425872c9b00 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -243,6 +243,10 @@ Changes in existing checks ` check by adding the option `IgnoreAliasing`, that allows not looking at underlying types of type aliases. +- Improved :doc:`readability-uppercase-literal-suffix + ` check to recognize + literal suffixes added in C++23 and C23. + Removed checks ^^^^^^^^^^^^^^ diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c new file mode 100644 index 0000000000000..75727fc69e68c --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c @@ -0,0 +1,162 @@ +// TODO: When Clang adds support for decimal floating point types, enable these tests by: +// 1. Removing all the #if 0 + #endif guards. +// 2. Removing all occurrences of the string "DISABLED-" in this file. +// 3. Deleting this message. + +// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -std=c23 +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.c +// RUN: clang-tidy %t.c -checks='-*,readability-uppercase-literal-suffix' -fix -- -std=c23 +// RUN: clang-tidy %t.c -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -std=c23 + +void bit_precise_literal_suffix() { + // _BitInt() + + static constexpr auto v1 = 1wb; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wb', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1wb; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: WB{{$}} + // CHECK-FIXES: static constexpr auto v1 = 1WB; + static_assert(v1 == 1WB); + + static constexpr auto v2 = 1WB; // OK. + static_assert(v2 == 1WB); + + // _BitInt() Unsigned + + static constexpr auto v3 = 1wbu; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wbu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1wbu; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: WBU{{$}} + // CHECK-FIXES: static constexpr auto v3 = 1WBU; + static_assert(v3 == 1WBU); + + static constexpr auto v4 = 1WBu; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'WBu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v4 = 1WBu; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: WBU{{$}} + // CHECK-FIXES: static constexpr auto v4 = 1WBU; + static_assert(v4 == 1WBU); + + static constexpr auto v5 = 1wbU; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wbU', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1wbU; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: WBU{{$}} + // CHECK-FIXES: static constexpr auto v5 = 1WBU; + static_assert(v5 == 1WBU); + + static constexpr auto v6 = 1WBU; // OK. + static_assert(v6 == 1WBU); + + // Unsigned _BitInt() + + static constexpr auto v7 = 1uwb; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'uwb', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1uwb; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: UWB{{$}} + // CHECK-FIXES: static constexpr auto v7 = 1UWB; + static_assert(v7 == 1UWB); + + static constexpr auto v8 = 1uWB; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'uWB', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v8 = 1uWB; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: UWB{{$}} + // CHECK-FIXES: static constexpr auto v8 = 1UWB; + static_assert(v8 == 1UWB); + + static constexpr auto v9 = 1Uwb; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'Uwb', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1Uwb; + // CHECK-MESSAGES-NEXT: ^~~~ + // CHECK-MESSAGES-NEXT: UWB{{$}} + // CHECK-FIXES: static constexpr auto v9 = 1UWB; + static_assert(v9 == 1UWB); + + static constexpr auto v10 = 1UWB; // OK. + static_assert(v10 == 1UWB); +} + +void decimal_floating_point_suffix() { + // _Decimal32 + +#if 0 + static constexpr auto v1 = 1.df; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'df', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1.df; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DF{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v1 = 1.DF; + static_assert(v1 == 1.DF); + + static constexpr auto v2 = 1.e0df; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'df', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v2 = 1.e0df; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DF{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v2 = 1.e0DF; + static_assert(v2 == 1.DF); + + static constexpr auto v3 = 1.DF; // OK. + static_assert(v3 == 1.DF); + + static constexpr auto v4 = 1.e0DF; // OK. + static_assert(v4 == 1.DF); +#endif + + // _Decimal64 + +#if 0 + static constexpr auto v5 = 1.dd; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dd', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1.dd; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DD{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v5 = 1.DD; + static_assert(v5 == 1.DD); + + static constexpr auto v6 = 1.e0dd; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dd', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v6 = 1.e0dd; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DD{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v6 = 1.e0DD; + static_assert(v6 == 1.DD); + + static constexpr auto v7 = 1.DD; // OK. + static_assert(v7 == 1.DD); + + static constexpr auto v8 = 1.e0DD; // OK. + static_assert(v8 == 1.DD); +#endif + + // _Decimal128 + +#if 0 + static constexpr auto v9 = 1.dl; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dl', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1.dl; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DL{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v9 = 1.DL; + static_assert(v9 == 1.DL); + + static constexpr auto v10 = 1.e0dl; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'dl', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1.e0dl; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: DL{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v10 = 1.e0DL; + static_assert(v10 == 1.DL); + + static constexpr auto v11 = 1.DL; // OK. + static_assert(v11 == 1.DL); + + static constexpr auto v12 = 1.e0DL; // OK. + static_assert(v12 == 1.DL); +#endif +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp new file mode 100644 index 0000000000000..abe23e3363766 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp @@ -0,0 +1,248 @@ +// TODO: When Clang adds support for C++23 floating-point types, enable these tests by: +// 1. Removing all the #if 0 + #endif guards. +// 2. Removing all occurrences of the string "DISABLED-" in this file. +// 3. Deleting this message. +// These suffixes may be relevant to C too: https://github.com/llvm/llvm-project/issues/97335 + +// RUN: %check_clang_tidy -std=c++23 %s readability-uppercase-literal-suffix %t -- -- -target aarch64-linux-gnu -I %clang_tidy_headers + +#include "integral_constant.h" +#if 0 +#include +#endif + +void normal_literals() { + // std::bfloat16_t + +#if 0 + static constexpr auto v1 = 1.bf16; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1.bf16; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v1 = 1.BF16; + static_assert(is_same::value, ""); + static_assert(v1 == 1.BF16, ""); + + static constexpr auto v2 = 1.e0bf16; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v2 = 1.e0bf16; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v2 = 1.e0BF16; + static_assert(is_same::value, ""); + static_assert(v2 == 1.BF16, ""); + + static constexpr auto v3 = 1.BF16; // OK. + static_assert(is_same::value, ""); + static_assert(v3 == 1.BF16, ""); + + static constexpr auto v4 = 1.e0BF16; // OK. + static_assert(is_same::value, ""); + static_assert(v4 == 1.BF16, ""); +#endif + + // _Float16/std::float16_t + + static constexpr auto v5 = 1.f16; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1.f16; + // CHECK-MESSAGES-NEXT: ^ ~ + // CHECK-MESSAGES-NEXT: F16{{$}} + // CHECK-FIXES: static constexpr auto v5 = 1.F16; + static_assert(is_same::value, ""); + static_assert(v5 == 1.F16, ""); + + static constexpr auto v6 = 1.e0f16; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v6 = 1.e0f16; + // CHECK-MESSAGES-NEXT: ^ ~ + // CHECK-MESSAGES-NEXT: F16{{$}} + // CHECK-FIXES: static constexpr auto v6 = 1.e0F16; + static_assert(is_same::value, ""); + static_assert(v6 == 1.F16, ""); + + static constexpr auto v7 = 1.F16; // OK. + static_assert(is_same::value, ""); + static_assert(v7 == 1.F16, ""); + + static constexpr auto v8 = 1.e0F16; // OK. + static_assert(is_same::value, ""); + static_assert(v8 == 1.F16, ""); + + // std::float32_t + +#if 0 + static constexpr auto v9 = 1.f32; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f32', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1.f32; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v9 = 1.F32; + static_assert(is_same::value, ""); + static_assert(v9 == 1.F32, ""); + + static constexpr auto v10 = 1.e0f32; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f32', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1.e0f32; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v10 = 1.e0F32; + static_assert(is_same::value, ""); + static_assert(v10 == 1.F32, ""); + + static constexpr auto v11 = 1.F32; // OK. + static_assert(is_same::value, ""); + static_assert(v11 == 1.F32, ""); + + static constexpr auto v12 = 1.e0F32; // OK. + static_assert(is_same::value, ""); + static_assert(v12 == 1.F32, ""); +#endif + + // std::float64_t + +#if 0 + static constexpr auto v13 = 1.f64; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f64', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v13 = 1.f64; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v13 = 1.F64; + static_assert(is_same::value, ""); + static_assert(v13 == 1.F64, ""); + + static constexpr auto v14 = 1.e0f64; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f64', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.e0f64; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v14 = 1.e0F64; + static_assert(is_same::value, ""); + static_assert(v14 == 1.F64, ""); + + static constexpr auto v15 = 1.F64; // OK. + static_assert(is_same::value, ""); + static_assert(v15 == 1.F64, ""); + + static constexpr auto v16 = 1.e0F64; // OK. + static_assert(is_same::value, ""); + static_assert(v16 == 1.F64, ""); +#endif + + // std::float128_t + +#if 0 + static constexpr auto v17 = 1.f128; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f128', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v17 = 1.f128; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v17 = 1.F128; + static_assert(is_same::value, ""); + static_assert(v17 == 1.F128, ""); + + static constexpr auto v18 = 1.e0f128; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f128', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v18 = 1.e0f128; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v18 = 1.e0F128; + static_assert(is_same::value, ""); + static_assert(v18 == 1.F128, ""); + + static constexpr auto v19 = 1.F128; // OK. + static_assert(is_same::value, ""); + static_assert(v19 == 1.F128, ""); + + static constexpr auto v20 = 1.e0F128; // OK. + static_assert(is_same::value, ""); + static_assert(v20 == 1.F128, ""); +#endif +} + +void hexadecimal_literals() { + // std::bfloat16_t + +#if 0 + static constexpr auto v1 = 0xfp0bf16; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 0xfp0bf16; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v1 = 0xfp0BF16; + static_assert(is_same::value, ""); + static_assert(v1 == 0xfp0BF16, ""); + + static constexpr auto v2 = 0xfp0BF16; // OK. + static_assert(is_same::value, ""); + static_assert(v2 == 0xfp0BF16, ""); +#endif + + // _Float16/std::float16_t + + static constexpr auto v3 = 0xfp0f16; + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 0xfp0f16; + // CHECK-MESSAGES-NEXT: ^ ~ + // CHECK-MESSAGES-NEXT: F16{{$}} + // CHECK-FIXES: static constexpr auto v3 = 0xfp0F16; + static_assert(is_same::value, ""); + static_assert(v3 == 0xfp0F16, ""); + + static constexpr auto v4 = 0xfp0F16; // OK. + static_assert(is_same::value, ""); + static_assert(v4 == 0xfp0F16, ""); + + // std::float32_t + +#if 0 + static constexpr auto v5 = 0xfp0f32; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f32', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v5 = 0xfp0f32; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v5 = 0xfp0F32; + static_assert(is_same::value, ""); + static_assert(v5 == 0xfp0F32, ""); + + static constexpr auto v6 = 0xfp0F32; // OK. + static_assert(is_same::value, ""); + static_assert(v6 == 0xfp0F32, ""); +#endif + + // std::float64_t + +#if 0 + static constexpr auto v7 = 0xfp0f64; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f64', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v7 = 0xfp0f64; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v7 = 0xfp0F64; + static_assert(is_same::value, ""); + static_assert(v7 == 0xfp0F64, ""); + + static constexpr auto v8 = 0xfp0F64; // OK. + static_assert(is_same::value, ""); + static_assert(v8 == 0xfp0F64, ""); +#endif + + // std::float128_t + +#if 0 + static constexpr auto v9 = 0xfp0f128; + // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f128', which is not uppercase + // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 0xfp0f128; + // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ + // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} + // DISABLED-CHECK-FIXES: static constexpr auto v9 = 0xfp0F128; + static_assert(is_same::value, ""); + static_assert(v9 == 0xfp0F128, ""); + + static constexpr auto v10 = 0xfp0F128; // OK. + static_assert(is_same::value, ""); + static_assert(v10 == 0xfp0F128, ""); +#endif + +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp deleted file mode 100644 index 46d7bc1347d0d..0000000000000 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -target aarch64-linux-gnu -I %clang_tidy_headers - -#include "integral_constant.h" - -void float16_normal_literals() { - // _Float16 - - static constexpr auto v14 = 1.f16; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} - // CHECK-FIXES: static constexpr auto v14 = 1.F16; - static_assert(is_same::value, ""); - static_assert(v14 == 1.F16, ""); - - static constexpr auto v15 = 1.e0f16; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1.e0f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} - // CHECK-FIXES: static constexpr auto v15 = 1.e0F16; - static_assert(is_same::value, ""); - static_assert(v15 == 1.F16, ""); - - static constexpr auto v16 = 1.F16; // OK. - static_assert(is_same::value, ""); - static_assert(v16 == 1.F16, ""); - - static constexpr auto v17 = 1.e0F16; // OK. - static_assert(is_same::value, ""); - static_assert(v17 == 1.F16, ""); -} - -void float16_hexadecimal_literals() { -// _Float16 - - static constexpr auto v13 = 0xfp0f16; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 0xfp0f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} - // CHECK-FIXES: static constexpr auto v13 = 0xfp0F16; - static_assert(is_same::value, ""); - static_assert(v13 == 0xfp0F16, ""); - - static constexpr auto v14 = 0xfp0F16; // OK. - static_assert(is_same::value, ""); - static_assert(v14 == 0xfp0F16, ""); - -} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp index 084d9f68e0b5e..29f85749e9d55 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp @@ -4,10 +4,11 @@ // RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %clang_tidy_headers #include "integral_constant.h" +#include void integer_suffix() { static constexpr auto v0 = __LINE__; // synthetic - static_assert(v0 == 9 || v0 == 5, ""); + static_assert(v0 == 10 || v0 == 6, ""); static constexpr auto v1 = __cplusplus; // synthetic, long @@ -225,6 +226,89 @@ void integer_complex_suffix() { static_assert(v28 == 1J, ""); } +// This is a C++23 feature, but Clang supports it in earlier language modes +// as an extension, so we test it unconditionally. +void size_t_suffix() { + // Signed + + static constexpr auto v29 = 1z; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'z', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v29 = 1z; + // CHECK-MESSAGES-NEXT: ^~ + // CHECK-MESSAGES-NEXT: Z{{$}} + // CHECK-FIXES: static constexpr auto v29 = 1Z; + static_assert(v29 == 1Z, ""); + + static constexpr auto v30 = 1Z; // OK. + static_assert(v30 == 1Z, ""); + + // size_t Unsigned + + static constexpr auto v31 = 1zu; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v31 = 1zu; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v31 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v31 == 1ZU, ""); + + static constexpr auto v32 = 1Zu; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Zu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v32 = 1Zu; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v32 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v32 == 1ZU, ""); + + static constexpr auto v33 = 1zU; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zU', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v33 = 1zU; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v33 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v33 == 1ZU, ""); + + static constexpr auto v34 = 1ZU; // OK. + static_assert(is_same::value, ""); + static_assert(v34 == 1ZU, ""); + + // Unsigned size_t + + static constexpr auto v35 = 1uz; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uz', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v35 = 1uz; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v35 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v35 == 1UZ); + + static constexpr auto v36 = 1uZ; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uZ', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v36 = 1uZ; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v36 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v36 == 1UZ); + + static constexpr auto v37 = 1Uz; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Uz', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v37 = 1Uz; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v37 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v37 == 1UZ); + + static constexpr auto v38 = 1UZ; // OK. + static_assert(is_same::value, ""); + static_assert(v38 == 1UZ); +} + void macros() { #define PASSTHROUGH(X) X static constexpr auto m0 = PASSTHROUGH(1u); From 0b7a032b61b50163f7b879e0f1c5d830d924686a Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Mon, 25 Aug 2025 15:37:05 +0000 Subject: [PATCH 3/7] Adjust release notes --- clang-tools-extra/docs/ReleaseNotes.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 61a43dd983c4c..59425872c9b00 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -247,10 +247,6 @@ Changes in existing checks ` check to recognize literal suffixes added in C++23 and C23. -- Improved :doc:`readability-uppercase-literal-suffix - ` check to recognize - literal suffixes added in C++23 and C23. - Removed checks ^^^^^^^^^^^^^^ From 13dde5482bd3237b24d8ba188ff18eeec6f7216a Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Mon, 25 Aug 2025 15:47:44 +0000 Subject: [PATCH 4/7] use `-or-later`, make `size_t` tests C++23-only --- .../uppercase-literal-suffix-c23.c | 2 +- ...cpp => uppercase-literal-suffix-cxx23.cpp} | 83 ++++++++++++++++++- .../uppercase-literal-suffix-integer.cpp | 83 ------------------- 3 files changed, 83 insertions(+), 85 deletions(-) rename clang-tools-extra/test/clang-tidy/checkers/readability/{uppercase-literal-suffix-extended-floating-point.cpp => uppercase-literal-suffix-cxx23.cpp} (75%) diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c index 75727fc69e68c..fe8bcc420d3cc 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c @@ -3,7 +3,7 @@ // 2. Removing all occurrences of the string "DISABLED-" in this file. // 3. Deleting this message. -// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -std=c23 +// RUN: %check_clang_tidy -std=c23-or-later %s readability-uppercase-literal-suffix %t // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.c // RUN: clang-tidy %t.c -checks='-*,readability-uppercase-literal-suffix' -fix -- -std=c23 // RUN: clang-tidy %t.c -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -std=c23 diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp similarity index 75% rename from clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp rename to clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp index abe23e3363766..9052c11f8ce6e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-extended-floating-point.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp @@ -4,7 +4,7 @@ // 3. Deleting this message. // These suffixes may be relevant to C too: https://github.com/llvm/llvm-project/issues/97335 -// RUN: %check_clang_tidy -std=c++23 %s readability-uppercase-literal-suffix %t -- -- -target aarch64-linux-gnu -I %clang_tidy_headers +// RUN: %check_clang_tidy -std=c++23-or-later %s readability-uppercase-literal-suffix %t -- -- -target aarch64-linux-gnu -I %clang_tidy_headers #include "integral_constant.h" #if 0 @@ -246,3 +246,84 @@ void hexadecimal_literals() { #endif } + +void size_t_suffix() { + // Signed + + static constexpr auto v29 = 1z; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'z', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v29 = 1z; + // CHECK-MESSAGES-NEXT: ^~ + // CHECK-MESSAGES-NEXT: Z{{$}} + // CHECK-FIXES: static constexpr auto v29 = 1Z; + static_assert(v29 == 1Z, ""); + + static constexpr auto v30 = 1Z; // OK. + static_assert(v30 == 1Z, ""); + + // size_t Unsigned + + static constexpr auto v31 = 1zu; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v31 = 1zu; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v31 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v31 == 1ZU, ""); + + static constexpr auto v32 = 1Zu; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Zu', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v32 = 1Zu; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v32 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v32 == 1ZU, ""); + + static constexpr auto v33 = 1zU; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zU', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v33 = 1zU; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: ZU{{$}} + // CHECK-FIXES: static constexpr auto v33 = 1ZU; + static_assert(is_same::value, ""); + static_assert(v33 == 1ZU, ""); + + static constexpr auto v34 = 1ZU; // OK. + static_assert(is_same::value, ""); + static_assert(v34 == 1ZU, ""); + + // Unsigned size_t + + static constexpr auto v35 = 1uz; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uz', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v35 = 1uz; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v35 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v35 == 1UZ); + + static constexpr auto v36 = 1uZ; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uZ', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v36 = 1uZ; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v36 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v36 == 1UZ); + + static constexpr auto v37 = 1Uz; + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Uz', which is not uppercase + // CHECK-MESSAGES-NEXT: static constexpr auto v37 = 1Uz; + // CHECK-MESSAGES-NEXT: ^~~ + // CHECK-MESSAGES-NEXT: UZ{{$}} + // CHECK-FIXES: static constexpr auto v37 = 1UZ; + static_assert(is_same::value, ""); + static_assert(v37 == 1UZ); + + static constexpr auto v38 = 1UZ; // OK. + static_assert(is_same::value, ""); + static_assert(v38 == 1UZ); +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp index 29f85749e9d55..f4b7d5db77d79 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp @@ -226,89 +226,6 @@ void integer_complex_suffix() { static_assert(v28 == 1J, ""); } -// This is a C++23 feature, but Clang supports it in earlier language modes -// as an extension, so we test it unconditionally. -void size_t_suffix() { - // Signed - - static constexpr auto v29 = 1z; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'z', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v29 = 1z; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: Z{{$}} - // CHECK-FIXES: static constexpr auto v29 = 1Z; - static_assert(v29 == 1Z, ""); - - static constexpr auto v30 = 1Z; // OK. - static_assert(v30 == 1Z, ""); - - // size_t Unsigned - - static constexpr auto v31 = 1zu; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v31 = 1zu; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: ZU{{$}} - // CHECK-FIXES: static constexpr auto v31 = 1ZU; - static_assert(is_same::value, ""); - static_assert(v31 == 1ZU, ""); - - static constexpr auto v32 = 1Zu; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Zu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v32 = 1Zu; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: ZU{{$}} - // CHECK-FIXES: static constexpr auto v32 = 1ZU; - static_assert(is_same::value, ""); - static_assert(v32 == 1ZU, ""); - - static constexpr auto v33 = 1zU; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zU', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v33 = 1zU; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: ZU{{$}} - // CHECK-FIXES: static constexpr auto v33 = 1ZU; - static_assert(is_same::value, ""); - static_assert(v33 == 1ZU, ""); - - static constexpr auto v34 = 1ZU; // OK. - static_assert(is_same::value, ""); - static_assert(v34 == 1ZU, ""); - - // Unsigned size_t - - static constexpr auto v35 = 1uz; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uz', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v35 = 1uz; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UZ{{$}} - // CHECK-FIXES: static constexpr auto v35 = 1UZ; - static_assert(is_same::value, ""); - static_assert(v35 == 1UZ); - - static constexpr auto v36 = 1uZ; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uZ', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v36 = 1uZ; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UZ{{$}} - // CHECK-FIXES: static constexpr auto v36 = 1UZ; - static_assert(is_same::value, ""); - static_assert(v36 == 1UZ); - - static constexpr auto v37 = 1Uz; - // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Uz', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v37 = 1Uz; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UZ{{$}} - // CHECK-FIXES: static constexpr auto v37 = 1UZ; - static_assert(is_same::value, ""); - static_assert(v37 == 1UZ); - - static constexpr auto v38 = 1UZ; // OK. - static_assert(is_same::value, ""); - static_assert(v38 == 1UZ); -} - void macros() { #define PASSTHROUGH(X) X static constexpr auto m0 = PASSTHROUGH(1u); From a66068bf771c970c3be120b873d881f19f8ebd30 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Mon, 25 Aug 2025 16:00:33 +0000 Subject: [PATCH 5/7] Add `stdfloat` stub header --- .../checkers/Inputs/Headers/stdfloat | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdfloat diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdfloat b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdfloat new file mode 100644 index 0000000000000..c178e618bddf0 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdfloat @@ -0,0 +1,18 @@ +//===--- stdfloat - Stub header for tests -----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _STDFLOAT_ +#define _STDFLOAT_ + +namespace std { + +// TODO: define std::float16_t and friends + +} + +#endif // _STDFLOAT_ From ae7e793aef3dc0d3f7b307c6cbac089cf6d84dbc Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Mon, 25 Aug 2025 16:28:54 +0000 Subject: [PATCH 6/7] Add missing include --- .../checkers/readability/uppercase-literal-suffix-cxx23.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp index 9052c11f8ce6e..f9432fc5e5c2e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp @@ -7,6 +7,7 @@ // RUN: %check_clang_tidy -std=c++23-or-later %s readability-uppercase-literal-suffix %t -- -- -target aarch64-linux-gnu -I %clang_tidy_headers #include "integral_constant.h" +#include #if 0 #include #endif From 7c41b0ae8d2e723ee420e8153149747274a4f09e Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Tue, 26 Aug 2025 17:06:12 -0700 Subject: [PATCH 7/7] remove `CHECK-MESSAGES-NEXT` and idempotency tests --- .../cert/uppercase-literal-suffix-integer.cpp | 29 -------- .../uppercase-literal-suffix-c23.c | 42 ------------ .../uppercase-literal-suffix-cxx23.cpp | 66 ------------------- ...eral-suffix-floating-point-opencl-half.cpp | 9 --- ...ppercase-literal-suffix-floating-point.cpp | 36 ---------- ...eral-suffix-hexadecimal-floating-point.cpp | 30 --------- ...ase-literal-suffix-integer-custom-list.cpp | 15 ----- .../uppercase-literal-suffix-integer-ms.cpp | 17 ----- .../uppercase-literal-suffix-integer.cpp | 59 ----------------- 9 files changed, 303 deletions(-) diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp b/clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp index 6fa700bf06d4f..e7c0dd679871b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp @@ -1,14 +1,9 @@ // RUN: %check_clang_tidy %s cert-dcl16-c %t -- -- -I %clang_tidy_headers -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-tidy %t.cpp -checks='-*,cert-dcl16-c' -fix -- -I %clang_tidy_headers -// RUN: clang-tidy %t.cpp -checks='-*,cert-dcl16-c' -warnings-as-errors='-*,cert-dcl16-c' -- -I %clang_tidy_headers #include "integral_constant.h" void integer_suffix() { static constexpr auto v0 = __LINE__; // synthetic - static_assert(v0 == 9 || v0 == 5, ""); - static constexpr auto v1 = __cplusplus; // synthetic, long static constexpr auto v2 = 1; // no literal @@ -29,9 +24,6 @@ void integer_suffix() { static constexpr auto v5 = 1l; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1l; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *| *}}L{{$}} // CHECK-FIXES: static constexpr auto v5 = 1L; static_assert(is_same::value, ""); static_assert(v5 == 1, ""); @@ -44,9 +36,6 @@ void integer_suffix() { static constexpr auto v7 = 1ll; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'll', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1ll; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *| *}}LL{{$}} // CHECK-FIXES: static constexpr auto v7 = 1LL; static_assert(is_same::value, ""); static_assert(v7 == 1, ""); @@ -77,27 +66,18 @@ void integer_suffix() { static constexpr auto v13 = 1lu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 1lu; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *| *}}LU{{$}} // CHECK-FIXES: static constexpr auto v13 = 1LU; static_assert(is_same::value, ""); static_assert(v13 == 1, ""); static constexpr auto v14 = 1Lu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Lu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1Lu; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *| *}}LU{{$}} // CHECK-FIXES: static constexpr auto v14 = 1LU; static_assert(is_same::value, ""); static_assert(v14 == 1, ""); static constexpr auto v15 = 1lU; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lU', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1lU; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *| *}}LU{{$}} // CHECK-FIXES: static constexpr auto v15 = 1LU; static_assert(is_same::value, ""); static_assert(v15 == 1, ""); @@ -128,27 +108,18 @@ void integer_suffix() { static constexpr auto v21 = 1llu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v21 = 1llu; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *| *}}LLU{{$}} // CHECK-FIXES: static constexpr auto v21 = 1LLU; static_assert(is_same::value, ""); static_assert(v21 == 1, ""); static constexpr auto v22 = 1LLu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'LLu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v22 = 1LLu; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *| *}}LLU{{$}} // CHECK-FIXES: static constexpr auto v22 = 1LLU; static_assert(is_same::value, ""); static_assert(v22 == 1, ""); static constexpr auto v23 = 1llU; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llU', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v23 = 1llU; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *| *}}LLU{{$}} // CHECK-FIXES: static constexpr auto v23 = 1LLU; static_assert(is_same::value, ""); static_assert(v23 == 1, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c index fe8bcc420d3cc..d8b104fa7e838 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-c23.c @@ -4,18 +4,12 @@ // 3. Deleting this message. // RUN: %check_clang_tidy -std=c23-or-later %s readability-uppercase-literal-suffix %t -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.c -// RUN: clang-tidy %t.c -checks='-*,readability-uppercase-literal-suffix' -fix -- -std=c23 -// RUN: clang-tidy %t.c -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -std=c23 void bit_precise_literal_suffix() { // _BitInt() static constexpr auto v1 = 1wb; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wb', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1wb; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: WB{{$}} // CHECK-FIXES: static constexpr auto v1 = 1WB; static_assert(v1 == 1WB); @@ -26,25 +20,16 @@ void bit_precise_literal_suffix() { static constexpr auto v3 = 1wbu; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wbu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1wbu; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: WBU{{$}} // CHECK-FIXES: static constexpr auto v3 = 1WBU; static_assert(v3 == 1WBU); static constexpr auto v4 = 1WBu; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'WBu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v4 = 1WBu; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: WBU{{$}} // CHECK-FIXES: static constexpr auto v4 = 1WBU; static_assert(v4 == 1WBU); static constexpr auto v5 = 1wbU; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wbU', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1wbU; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: WBU{{$}} // CHECK-FIXES: static constexpr auto v5 = 1WBU; static_assert(v5 == 1WBU); @@ -55,25 +40,16 @@ void bit_precise_literal_suffix() { static constexpr auto v7 = 1uwb; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'uwb', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1uwb; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: UWB{{$}} // CHECK-FIXES: static constexpr auto v7 = 1UWB; static_assert(v7 == 1UWB); static constexpr auto v8 = 1uWB; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'uWB', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v8 = 1uWB; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: UWB{{$}} // CHECK-FIXES: static constexpr auto v8 = 1UWB; static_assert(v8 == 1UWB); static constexpr auto v9 = 1Uwb; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'Uwb', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1Uwb; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: UWB{{$}} // CHECK-FIXES: static constexpr auto v9 = 1UWB; static_assert(v9 == 1UWB); @@ -87,17 +63,11 @@ void decimal_floating_point_suffix() { #if 0 static constexpr auto v1 = 1.df; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'df', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1.df; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: DF{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v1 = 1.DF; static_assert(v1 == 1.DF); static constexpr auto v2 = 1.e0df; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'df', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v2 = 1.e0df; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: DF{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v2 = 1.e0DF; static_assert(v2 == 1.DF); @@ -113,17 +83,11 @@ void decimal_floating_point_suffix() { #if 0 static constexpr auto v5 = 1.dd; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dd', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1.dd; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: DD{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v5 = 1.DD; static_assert(v5 == 1.DD); static constexpr auto v6 = 1.e0dd; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dd', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v6 = 1.e0dd; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: DD{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v6 = 1.e0DD; static_assert(v6 == 1.DD); @@ -139,17 +103,11 @@ void decimal_floating_point_suffix() { #if 0 static constexpr auto v9 = 1.dl; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dl', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1.dl; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: DL{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v9 = 1.DL; static_assert(v9 == 1.DL); static constexpr auto v10 = 1.e0dl; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'dl', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1.e0dl; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: DL{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v10 = 1.e0DL; static_assert(v10 == 1.DL); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp index f9432fc5e5c2e..6602fd92d6b5e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-cxx23.cpp @@ -18,18 +18,12 @@ void normal_literals() { #if 0 static constexpr auto v1 = 1.bf16; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 1.bf16; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v1 = 1.BF16; static_assert(is_same::value, ""); static_assert(v1 == 1.BF16, ""); static constexpr auto v2 = 1.e0bf16; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v2 = 1.e0bf16; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v2 = 1.e0BF16; static_assert(is_same::value, ""); static_assert(v2 == 1.BF16, ""); @@ -47,18 +41,12 @@ void normal_literals() { static constexpr auto v5 = 1.f16; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1.f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} // CHECK-FIXES: static constexpr auto v5 = 1.F16; static_assert(is_same::value, ""); static_assert(v5 == 1.F16, ""); static constexpr auto v6 = 1.e0f16; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v6 = 1.e0f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} // CHECK-FIXES: static constexpr auto v6 = 1.e0F16; static_assert(is_same::value, ""); static_assert(v6 == 1.F16, ""); @@ -76,18 +64,12 @@ void normal_literals() { #if 0 static constexpr auto v9 = 1.f32; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f32', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1.f32; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v9 = 1.F32; static_assert(is_same::value, ""); static_assert(v9 == 1.F32, ""); static constexpr auto v10 = 1.e0f32; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f32', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1.e0f32; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v10 = 1.e0F32; static_assert(is_same::value, ""); static_assert(v10 == 1.F32, ""); @@ -106,18 +88,12 @@ void normal_literals() { #if 0 static constexpr auto v13 = 1.f64; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f64', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v13 = 1.f64; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v13 = 1.F64; static_assert(is_same::value, ""); static_assert(v13 == 1.F64, ""); static constexpr auto v14 = 1.e0f64; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f64', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.e0f64; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v14 = 1.e0F64; static_assert(is_same::value, ""); static_assert(v14 == 1.F64, ""); @@ -136,18 +112,12 @@ void normal_literals() { #if 0 static constexpr auto v17 = 1.f128; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f128', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v17 = 1.f128; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v17 = 1.F128; static_assert(is_same::value, ""); static_assert(v17 == 1.F128, ""); static constexpr auto v18 = 1.e0f128; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f128', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v18 = 1.e0f128; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v18 = 1.e0F128; static_assert(is_same::value, ""); static_assert(v18 == 1.F128, ""); @@ -168,9 +138,6 @@ void hexadecimal_literals() { #if 0 static constexpr auto v1 = 0xfp0bf16; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'bf16', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v1 = 0xfp0bf16; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: BF16{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v1 = 0xfp0BF16; static_assert(is_same::value, ""); static_assert(v1 == 0xfp0BF16, ""); @@ -184,9 +151,6 @@ void hexadecimal_literals() { static constexpr auto v3 = 0xfp0f16; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 0xfp0f16; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F16{{$}} // CHECK-FIXES: static constexpr auto v3 = 0xfp0F16; static_assert(is_same::value, ""); static_assert(v3 == 0xfp0F16, ""); @@ -200,9 +164,6 @@ void hexadecimal_literals() { #if 0 static constexpr auto v5 = 0xfp0f32; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f32', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v5 = 0xfp0f32; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F32{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v5 = 0xfp0F32; static_assert(is_same::value, ""); static_assert(v5 == 0xfp0F32, ""); @@ -217,9 +178,6 @@ void hexadecimal_literals() { #if 0 static constexpr auto v7 = 0xfp0f64; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f64', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v7 = 0xfp0f64; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F64{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v7 = 0xfp0F64; static_assert(is_same::value, ""); static_assert(v7 == 0xfp0F64, ""); @@ -234,9 +192,6 @@ void hexadecimal_literals() { #if 0 static constexpr auto v9 = 0xfp0f128; // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f128', which is not uppercase - // DISABLED-CHECK-MESSAGES-NEXT: static constexpr auto v9 = 0xfp0f128; - // DISABLED-CHECK-MESSAGES-NEXT: ^ ~ - // DISABLED-CHECK-MESSAGES-NEXT: F128{{$}} // DISABLED-CHECK-FIXES: static constexpr auto v9 = 0xfp0F128; static_assert(is_same::value, ""); static_assert(v9 == 0xfp0F128, ""); @@ -253,9 +208,6 @@ void size_t_suffix() { static constexpr auto v29 = 1z; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'z', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v29 = 1z; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: Z{{$}} // CHECK-FIXES: static constexpr auto v29 = 1Z; static_assert(v29 == 1Z, ""); @@ -266,27 +218,18 @@ void size_t_suffix() { static constexpr auto v31 = 1zu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v31 = 1zu; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: ZU{{$}} // CHECK-FIXES: static constexpr auto v31 = 1ZU; static_assert(is_same::value, ""); static_assert(v31 == 1ZU, ""); static constexpr auto v32 = 1Zu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Zu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v32 = 1Zu; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: ZU{{$}} // CHECK-FIXES: static constexpr auto v32 = 1ZU; static_assert(is_same::value, ""); static_assert(v32 == 1ZU, ""); static constexpr auto v33 = 1zU; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'zU', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v33 = 1zU; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: ZU{{$}} // CHECK-FIXES: static constexpr auto v33 = 1ZU; static_assert(is_same::value, ""); static_assert(v33 == 1ZU, ""); @@ -299,27 +242,18 @@ void size_t_suffix() { static constexpr auto v35 = 1uz; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uz', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v35 = 1uz; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UZ{{$}} // CHECK-FIXES: static constexpr auto v35 = 1UZ; static_assert(is_same::value, ""); static_assert(v35 == 1UZ); static constexpr auto v36 = 1uZ; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uZ', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v36 = 1uZ; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UZ{{$}} // CHECK-FIXES: static constexpr auto v36 = 1UZ; static_assert(is_same::value, ""); static_assert(v36 == 1UZ); static constexpr auto v37 = 1Uz; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Uz', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v37 = 1Uz; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UZ{{$}} // CHECK-FIXES: static constexpr auto v37 = 1UZ; static_assert(is_same::value, ""); static_assert(v37 == 1UZ); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp index ef905da6e9f95..f6442352405c0 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp @@ -1,7 +1,4 @@ // RUN: %check_clang_tidy -std=cl2.0 %s readability-uppercase-literal-suffix %t -- -- -target x86_64-pc-linux-gnu -I %S -x cl -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -fix -- -target x86_64-pc-linux-gnu -I %S -std=cl2.0 -x cl -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target x86_64-pc-linux-gnu -I %S -std=cl2.0 -x cl #pragma OPENCL EXTENSION cl_khr_fp16 : enable @@ -12,16 +9,10 @@ void floating_point_half_suffix() { static half v2 = 1.h; // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: floating point literal has suffix 'h', which is not uppercase - // CHECK-MESSAGES-NEXT: static half v2 = 1.h; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: H{{$}} // CHECK-HIXES: static half v2 = 1.H; static half v3 = 1.e0h; // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: floating point literal has suffix 'h', which is not uppercase - // CHECK-MESSAGES-NEXT: static half v3 = 1.e0h; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: H{{$}} // CHECK-HIXES: static half v3 = 1.e0H; static half v4 = 1.H; // OK. diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp index d9f5bfbe3aa38..fc1976b0e6b22 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp @@ -1,7 +1,4 @@ // RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -fix -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers #include "integral_constant.h" @@ -18,18 +15,12 @@ void floating_point_suffix() { static constexpr auto v2 = 1.f; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v2 = 1.f; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v2 = 1.F; static_assert(is_same::value, ""); static_assert(v2 == 1.0F, ""); static constexpr auto v3 = 1.e0f; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1.e0f; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v3 = 1.e0F; static_assert(is_same::value, ""); static_assert(v3 == 1.0F, ""); @@ -46,18 +37,12 @@ void floating_point_suffix() { static constexpr auto v6 = 1.l; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'l', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v6 = 1.l; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v6 = 1.L; static_assert(is_same::value, ""); static_assert(v6 == 1., ""); static constexpr auto v7 = 1.e0l; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'l', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1.e0l; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v7 = 1.e0L; static_assert(is_same::value, ""); static_assert(v7 == 1., ""); @@ -74,18 +59,12 @@ void floating_point_suffix() { static constexpr auto v10 = 1.q; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'q', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1.q; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: Q{{$}} // CHECK-FIXES: static constexpr auto v10 = 1.Q; static_assert(is_same::value, ""); static_assert(v10 == 1., ""); static constexpr auto v11 = 1.e0q; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'q', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v11 = 1.e0q; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: Q{{$}} // CHECK-FIXES: static constexpr auto v11 = 1.e0Q; static_assert(is_same::value, ""); static_assert(v11 == 1., ""); @@ -104,18 +83,12 @@ void floating_point_complex_suffix() { static constexpr auto v14 = 1.i; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'i', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.i; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: I{{$}} // CHECK-FIXES: static constexpr auto v14 = 1.I; static_assert(is_same::value, ""); static_assert(v14 == 1.I, ""); static constexpr auto v15 = 1.e0i; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'i', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1.e0i; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: I{{$}} // CHECK-FIXES: static constexpr auto v15 = 1.e0I; static_assert(is_same::value, ""); static_assert(v15 == 1.I, ""); @@ -132,18 +105,12 @@ void floating_point_complex_suffix() { static constexpr auto v18 = 1.j; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'j', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v18 = 1.j; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: J{{$}} // CHECK-FIXES: static constexpr auto v18 = 1.J; static_assert(is_same::value, ""); static_assert(v18 == 1.J, ""); static constexpr auto v19 = 1.e0j; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'j', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v19 = 1.e0j; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: J{{$}} // CHECK-FIXES: static constexpr auto v19 = 1.e0J; static_assert(is_same::value, ""); static_assert(v19 == 1.J, ""); @@ -161,9 +128,6 @@ void macros() { #define PASSTHROUGH(X) X static constexpr auto m0 = PASSTHROUGH(1.f); // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: floating point literal has suffix 'f', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto m0 = PASSTHROUGH(1.f); - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto m0 = PASSTHROUGH(1.F); static_assert(is_same::value, ""); static_assert(m0 == 1.0F, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp index 72077153fb718..9bb1cee4bbdff 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp @@ -1,7 +1,4 @@ // RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -fix -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers #include "integral_constant.h" @@ -14,9 +11,6 @@ void floating_point_suffix() { static constexpr auto v1 = 0xfp0f; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v1 = 0xfp0f; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v1 = 0xfp0F; static_assert(is_same::value, ""); static_assert(v1 == 15, ""); @@ -27,9 +21,6 @@ void floating_point_suffix() { static constexpr auto v3 = 0xfP0f; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 0xfP0f; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v3 = 0xfP0F; static_assert(is_same::value, ""); static_assert(v3 == 15, ""); @@ -40,9 +31,6 @@ void floating_point_suffix() { static constexpr auto v5 = 0xFP0f; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 0xFP0f; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v5 = 0xFP0F; static_assert(is_same::value, ""); static_assert(v5 == 15, ""); @@ -53,9 +41,6 @@ void floating_point_suffix() { static constexpr auto v7 = 0xFp0f; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 0xFp0f; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v7 = 0xFp0F; static_assert(is_same::value, ""); static_assert(v7 == 15, ""); @@ -68,9 +53,6 @@ void floating_point_suffix() { static constexpr auto v9 = 0xfp0l; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'l', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 0xfp0l; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v9 = 0xfp0L; static_assert(is_same::value, ""); static_assert(v9 == 0xfp0, ""); @@ -83,9 +65,6 @@ void floating_point_suffix() { static constexpr auto v11 = 0xfp0q; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'q', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v11 = 0xfp0q; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: Q{{$}} // CHECK-FIXES: static constexpr auto v11 = 0xfp0Q; static_assert(is_same::value, ""); static_assert(v11 == 0xfp0, ""); @@ -100,9 +79,6 @@ void floating_point_complex_suffix() { static constexpr auto v14 = 0xfp0i; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'i', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 0xfp0i; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: I{{$}} // CHECK-FIXES: static constexpr auto v14 = 0xfp0I; static_assert(is_same::value, ""); static_assert(v14 == 0xfp0I, ""); @@ -115,9 +91,6 @@ void floating_point_complex_suffix() { static constexpr auto v18 = 0xfp0j; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'j', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v18 = 0xfp0j; - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: J{{$}} // CHECK-FIXES: static constexpr auto v18 = 0xfp0J; static_assert(is_same::value, ""); static_assert(v18 == 0xfp0J, ""); @@ -131,9 +104,6 @@ void macros() { #define PASSTHROUGH(X) X static constexpr auto m0 = PASSTHROUGH(0x0p0f); // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: floating point literal has suffix 'f', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto m0 = PASSTHROUGH(0x0p0f); - // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto m0 = PASSTHROUGH(0x0p0F); static_assert(is_same::value, ""); static_assert(m0 == 0x0p0F, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp index 3215075ebcf01..a4fcf3a3910e9 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp @@ -1,7 +1,4 @@ // RUN: %check_clang_tidy --match-partial-fixes %s readability-uppercase-literal-suffix %t -- -config="{CheckOptions: {readability-uppercase-literal-suffix.NewSuffixes: 'L;uL'}}" -- -I %clang_tidy_headers -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -fix -config="{CheckOptions: {readability-uppercase-literal-suffix.NewSuffixes: 'L;uL'}}" -- -I %clang_tidy_headers -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -config="{CheckOptions: {readability-uppercase-literal-suffix.NewSuffixes: 'L;uL'}}" -- -I %clang_tidy_headers #include "integral_constant.h" @@ -20,9 +17,6 @@ void integer_suffix() { static constexpr auto v5 = 1l; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1l; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v5 = 1L; static_assert(is_same::value, ""); static_assert(v5 == 1, ""); @@ -45,9 +39,6 @@ void integer_suffix() { static constexpr auto v9 = 1ul; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'ul', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1ul; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: uL{{$}} // CHECK-FIXES: static constexpr auto v9 = 1uL; static_assert(is_same::value, ""); static_assert(v9 == 1, ""); @@ -58,18 +49,12 @@ void integer_suffix() { static constexpr auto v11 = 1Ul; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Ul', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v11 = 1Ul; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: uL{{$}} // CHECK-FIXES: static constexpr auto v11 = 1uL; static_assert(is_same::value, ""); static_assert(v11 == 1, ""); static constexpr auto v12 = 1UL; // OK. // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'UL', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v12 = 1UL; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: uL{{$}} // CHECK-FIXES: static constexpr auto v12 = 1uL; static_assert(is_same::value, ""); static_assert(v12 == 1, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp index 7ac4a7502e7b7..74628188b15ad 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp @@ -1,14 +1,9 @@ // RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers -fms-extensions -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -fix -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers -fms-extensions -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target x86_64-pc-linux-gnu -I %clang_tidy_headers -fms-extensions #include "integral_constant.h" void integer_suffix() { static constexpr auto v0 = __LINE__; // synthetic - static_assert(v0 == 9 || v0 == 5, ""); - static constexpr auto v1 = __cplusplus; // synthetic, long static constexpr auto v2 = 1; // no literal @@ -19,9 +14,6 @@ void integer_suffix() { static constexpr auto v3 = 1i32; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'i32', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1i32; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: I32{{$}} // CHECK-FIXES: static constexpr auto v3 = 1I32; static_assert(is_same::value, ""); static_assert(v3 == 1I32, ""); @@ -34,9 +26,6 @@ void integer_suffix() { static constexpr auto v5 = 1i64; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'i64', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1i64; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: I64{{$}} // CHECK-FIXES: static constexpr auto v5 = 1I64; static_assert(is_same::value, ""); static_assert(v5 == 1I64, ""); @@ -49,9 +38,6 @@ void integer_suffix() { static constexpr auto v7 = 1i16; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'i16', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1i16; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: I16{{$}} // CHECK-FIXES: static constexpr auto v7 = 1I16; static_assert(is_same::value, ""); static_assert(v7 == 1I16, ""); @@ -64,9 +50,6 @@ void integer_suffix() { static constexpr auto v9 = 1i8; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'i8', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1i8; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: I8{{$}} // CHECK-FIXES: static constexpr auto v9 = 1I8; static_assert(is_same::value, ""); static_assert(v9 == 1I8, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp index f4b7d5db77d79..e4dd968f49c12 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp @@ -1,15 +1,10 @@ // RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I %clang_tidy_headers -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -fix -- -I %clang_tidy_headers -// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %clang_tidy_headers #include "integral_constant.h" #include void integer_suffix() { static constexpr auto v0 = __LINE__; // synthetic - static_assert(v0 == 10 || v0 == 6, ""); - static constexpr auto v1 = __cplusplus; // synthetic, long static constexpr auto v2 = 1; // no literal @@ -20,9 +15,6 @@ void integer_suffix() { static constexpr auto v3 = 1u; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'u', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1u; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: U{{$}} // CHECK-FIXES: static constexpr auto v3 = 1U; static_assert(is_same::value, ""); static_assert(v3 == 1, ""); @@ -35,9 +27,6 @@ void integer_suffix() { static constexpr auto v5 = 1l; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1l; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v5 = 1L; static_assert(is_same::value, ""); static_assert(v5 == 1, ""); @@ -50,9 +39,6 @@ void integer_suffix() { static constexpr auto v7 = 1ll; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'll', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1ll; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: LL{{$}} // CHECK-FIXES: static constexpr auto v7 = 1LL; static_assert(is_same::value, ""); static_assert(v7 == 1, ""); @@ -65,27 +51,18 @@ void integer_suffix() { static constexpr auto v9 = 1ul; // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'ul', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1ul; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UL{{$}} // CHECK-FIXES: static constexpr auto v9 = 1UL; static_assert(is_same::value, ""); static_assert(v9 == 1, ""); static constexpr auto v10 = 1uL; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uL', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1uL; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UL{{$}} // CHECK-FIXES: static constexpr auto v10 = 1UL; static_assert(is_same::value, ""); static_assert(v10 == 1, ""); static constexpr auto v11 = 1Ul; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Ul', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v11 = 1Ul; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: UL{{$}} // CHECK-FIXES: static constexpr auto v11 = 1UL; static_assert(is_same::value, ""); static_assert(v11 == 1, ""); @@ -98,27 +75,18 @@ void integer_suffix() { static constexpr auto v13 = 1lu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 1lu; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: LU{{$}} // CHECK-FIXES: static constexpr auto v13 = 1LU; static_assert(is_same::value, ""); static_assert(v13 == 1, ""); static constexpr auto v14 = 1Lu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Lu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1Lu; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: LU{{$}} // CHECK-FIXES: static constexpr auto v14 = 1LU; static_assert(is_same::value, ""); static_assert(v14 == 1, ""); static constexpr auto v15 = 1lU; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lU', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1lU; - // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: LU{{$}} // CHECK-FIXES: static constexpr auto v15 = 1LU; static_assert(is_same::value, ""); static_assert(v15 == 1, ""); @@ -131,27 +99,18 @@ void integer_suffix() { static constexpr auto v17 = 1ull; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'ull', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v17 = 1ull; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: ULL{{$}} // CHECK-FIXES: static constexpr auto v17 = 1ULL; static_assert(is_same::value, ""); static_assert(v17 == 1, ""); static constexpr auto v18 = 1uLL; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uLL', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v18 = 1uLL; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: ULL{{$}} // CHECK-FIXES: static constexpr auto v18 = 1ULL; static_assert(is_same::value, ""); static_assert(v18 == 1, ""); static constexpr auto v19 = 1Ull; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Ull', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v19 = 1Ull; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: ULL{{$}} // CHECK-FIXES: static constexpr auto v19 = 1ULL; static_assert(is_same::value, ""); static_assert(v19 == 1, ""); @@ -164,27 +123,18 @@ void integer_suffix() { static constexpr auto v21 = 1llu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v21 = 1llu; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: LLU{{$}} // CHECK-FIXES: static constexpr auto v21 = 1LLU; static_assert(is_same::value, ""); static_assert(v21 == 1, ""); static constexpr auto v22 = 1LLu; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'LLu', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v22 = 1LLu; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: LLU{{$}} // CHECK-FIXES: static constexpr auto v22 = 1LLU; static_assert(is_same::value, ""); static_assert(v22 == 1, ""); static constexpr auto v23 = 1llU; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llU', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v23 = 1llU; - // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: LLU{{$}} // CHECK-FIXES: static constexpr auto v23 = 1LLU; static_assert(is_same::value, ""); static_assert(v23 == 1, ""); @@ -199,9 +149,6 @@ void integer_complex_suffix() { static constexpr auto v25 = 1i; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'i', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v25 = 1i; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: I{{$}} // CHECK-FIXES: static constexpr auto v25 = 1I; static_assert(is_same::value, ""); static_assert(v25 == 1I, ""); @@ -214,9 +161,6 @@ void integer_complex_suffix() { static constexpr auto v27 = 1j; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'j', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto v27 = 1j; - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: J{{$}} // CHECK-FIXES: static constexpr auto v27 = 1J; static_assert(is_same::value, ""); static_assert(v27 == 1J, ""); @@ -230,9 +174,6 @@ void macros() { #define PASSTHROUGH(X) X static constexpr auto m0 = PASSTHROUGH(1u); // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: integer literal has suffix 'u', which is not uppercase - // CHECK-MESSAGES-NEXT: static constexpr auto m0 = PASSTHROUGH(1u); - // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: U{{$}} // CHECK-FIXES: static constexpr auto m0 = PASSTHROUGH(1U); static_assert(is_same::value, ""); static_assert(m0 == 1, "");