[clang-tools-extra] 53fce75 - [clang-tidy] Fix `readability-uppercase-literal-suffix` warning with hex literals (#156584)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 3 08:01:12 PDT 2025
Author: Victor Chernyakin
Date: 2025-09-03T08:00:48-07:00
New Revision: 53fce759fb35f2a162bc7bcc1e56911643b0e7a8
URL: https://github.com/llvm/llvm-project/commit/53fce759fb35f2a162bc7bcc1e56911643b0e7a8
DIFF: https://github.com/llvm/llvm-project/commit/53fce759fb35f2a162bc7bcc1e56911643b0e7a8.diff
LOG: [clang-tidy] Fix `readability-uppercase-literal-suffix` warning with hex literals (#156584)
This is a regression I introduced in #148275 and was [noticed
by](https://github.com/llvm/llvm-project/pull/148275#issuecomment-3246670841)
nettle. The check incorrectly fires on hex literals containing the
letter `b`.
(I felt a revert was unnecessary in this case. Maybe others disagree?)
Added:
Modified:
clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
index 4ec2a63ab33fc..e66e1c52b5979 100644
--- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -29,7 +29,7 @@ struct IntegerLiteralCheck {
// 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("uUlLzZwWbBiIjJ");
+ llvm::StringLiteral("uUlLzZwWiIjJ");
};
struct FloatingLiteralCheck {
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 e7c0dd679871b..6d6d83d6cac49 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
@@ -128,3 +128,12 @@ void integer_suffix() {
static_assert(is_same<decltype(v24), const unsigned long long>::value, "");
static_assert(v24 == 1, "");
}
+
+void no_warning_on_hex_literals() {
+ int a = 0xa;
+ int b = 0xb;
+ int c = 0xc;
+ int d = 0xd;
+ int e = 0xe;
+ int f = 0xf;
+}
More information about the cfe-commits
mailing list