[clang-tools-extra] [clang-tidy] Preserve comments in `readability-use-std-min-max` (PR #169908)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 2 08:23:27 PST 2025


================
@@ -273,3 +273,14 @@ void useRight() {
 }
 
 } // namespace gh121676
+
+void testComment() {
+  int box_depth = 10;
+  int max_depth = 5;
+  // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max]
+  // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); // limit the depth to max
+  if (box_depth > max_depth) // limit the depth to max
----------------
vbvictor wrote:

Could we add more tests with different style of comments (maybe you can think more cases):
```cpp
if () /* here */ {}

if ()
// here
{}

if () /* here
and here
*/ {}

if () { /* here */
}
```



https://github.com/llvm/llvm-project/pull/169908


More information about the cfe-commits mailing list