================
@@ -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:

You may need to add logic to sometimes insert a space before the fix-it, to 
handle cases like:
```cpp
return(x << 3) | (x >> 5);
// should become
return std::rotl(x, 3);
// not
returnstd::rotl(x, 3);
```
(see 
[here](https://github.com/llvm/llvm-project/blob/887d2d4bf7380113b27f199f323eeee883f17191/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp#L94-L104)
 for an example).

There was some talk recently in #185108 about this and how it would be good to 
have a reusable facility for this, but for now you can just copy paste.

https://github.com/llvm/llvm-project/pull/186324
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to