mirror-llvm-project/clang-tools-extra
hehuan 60f965b1f6
[clang-tidy] Fix trailing semicolon and lost comment in readability-use-std-min-max (#208782)
Fix two bugs in readability-use-std-min-max when the if body has no
braces.

For brace-less if bodies, If->getEndLoc() points to the expression end
rather than the trailing semicolon, truncating replacements and losing
comments. We find the semicolon via findNextToken and extend the range
consistent with compound statement logic.

Before:
  if (n < -1) n = -1 ;          ->  n = std::max(n, -1); ;
  if (n > 1) n = 1/*comment*/;  ->  n = std::min(n, 1);;

After:
  if (n < -1) n = -1 ;          ->  n = std::max(n, -1);
  if (n > 1) n = 1/*comment*/;  ->  n = std::min(n, 1); /*comment*/

Fixes #208708.

AI Usage: This patch is AI-assisted, reviewed and verified by me.
2026-08-01 19:09:50 +08:00
..
clang-apply-replacements [clang-apply-replacements] Change cleanup to only happen with --format (#178763) 2026-02-05 18:54:44 -08:00
clang-change-namespace [Tooling][clang-tools-extra] Consume CommonOptionsParser errors in tools (#193675) 2026-04-24 13:25:26 +08:00
clang-doc Fix clang-doc crash when comment contains invalid UTF-8 bytes (#210886) 2026-07-25 05:20:11 +08:00
clang-include-fixer [Tooling][clang-tools-extra] Consume CommonOptionsParser errors in tools (#193675) 2026-04-24 13:25:26 +08:00
clang-move Associate documentation comments with macro definitions (#198452) 2026-05-21 14:49:40 -07:00
clang-query
clang-reorder-fields [Tooling][clang-tools-extra] Consume CommonOptionsParser errors in tools (#193675) 2026-04-24 13:25:26 +08:00
clang-tidy [clang-tidy] Fix trailing semicolon and lost comment in readability-use-std-min-max (#208782) 2026-08-01 19:09:50 +08:00
clangd [Clang] Treat line directives as header names. (#211512) 2026-07-29 19:04:17 +02:00
docs [clang-tidy] Fix trailing semicolon and lost comment in readability-use-std-min-max (#208782) 2026-08-01 19:09:50 +08:00
include-cleaner [include-cleaner] Support ObjC interface and protocol declarations in LocateSymbol (#212617) 2026-07-28 23:19:34 +02:00
modularize Remove unused variables in the monorepo (#204994) 2026-06-24 11:50:30 +02:00
pp-trace [Clang-tools-extra] Add missing values to CharacteristicKindStrings (#205455) 2026-06-25 10:55:10 -07:00
test [clang-tidy] Fix trailing semicolon and lost comment in readability-use-std-min-max (#208782) 2026-08-01 19:09:50 +08:00
tool-template
unittests [clang-format][clang-tools-extra] Fix leaking of host-level config into test environment (#206358) 2026-07-23 13:59:53 +08:00
.gitignore
CMakeLists.txt reapply "[clang-tidy] support query based custom check" (#159547) 2025-09-19 21:47:57 +08:00
LICENSE.TXT
Maintainers.md [clang-tools-extra][docs] Convert maintainers file to Markdown (#200365) 2026-06-01 11:13:00 +01:00
README.txt

//===----------------------------------------------------------------------===//
// Clang Tools repository
//===----------------------------------------------------------------------===//

Welcome to the repository of extra Clang Tools.  This repository holds tools
that are developed as part of the LLVM compiler infrastructure project and the
Clang frontend.  These tools are kept in a separate "extra" repository to
allow lighter weight checkouts of the core Clang codebase.

All discussion regarding Clang, Clang-based tools, and code in this repository
should be held using the standard Clang forums:
  https://discourse.llvm.org/c/clang
  https://discourse.llvm.org/c/clang/clang-tidy/71
  https://discourse.llvm.org/c/clang/clangd/34

Code review for this tree should take place on Github:
  https://github.com/llvm/llvm-project/pulls?q=label%3Aclang-tools-extra

If you find a bug in these tools, please file it in the LLVM bug tracker:
  https://github.com/llvm/llvm-project/issues/