[all-commits] [llvm/llvm-project] 60f965: [clang-tidy] Fix trailing semicolon and lost comme...

hehuan via All-commits all-commits at lists.llvm.org
Sat Aug 1 04:10:12 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60f965b1f62c0c77bcdb2997ea9bb6603aa0d002
      https://github.com/llvm/llvm-project/commit/60f965b1f62c0c77bcdb2997ea9bb6603aa0d002
  Author: hehuan <111408804+xxxxbc at users.noreply.github.com>
  Date:   2026-08-01 (Sat, 01 Aug 2026)

  Changed paths:
    M clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/test/clang-tidy/checkers/readability/use-std-min-max.cpp

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list