[clang-tools-extra] [clang-tidy] Detect std::rot[lr] pattern within modernize.use-std-bit (PR #186324)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 13 02:30:44 PDT 2026
================
@@ -195,3 +195,59 @@ unsigned invalid_popcount_bitset(unsigned x, signed y) {
};
}
+
+/*
+ * rotate patterns
+ */
+unsigned char rotate_left_pattern(unsigned char x) {
+ // CHECK-MESSAGES: :[[@LINE+2]]:10: warning: use 'std::rotl' instead [modernize-use-std-bit]
+ // CHECK-FIXES: return (int)std::rotl(x, 3);
+ return x << 3 | x >> 5;
----------------
localspook wrote:
Can we add tests where...
- the args are parenthesized? i.e. `(x << 3) | (x >> 5)`
- we rotate a variable wider than a byte?
https://github.com/llvm/llvm-project/pull/186324
More information about the cfe-commits
mailing list