[all-commits] [llvm/llvm-project] 74f859: [clang-tidy] Fix readability-trailing-comma false ...
Aayush Mainali via All-commits
all-commits at lists.llvm.org
Mon Sep 28 06:02:33 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 74f859b9d46e480fe43d7b904b1e80efb8a331a2
https://github.com/llvm/llvm-project/commit/74f859b9d46e480fe43d7b904b1e80efb8a331a2
Author: Aayush Mainali <aayushmainali.codes at gmail.com>
Date: 2026-09-28 (Mon, 28 Sep 2026)
Changed paths:
M clang-tools-extra/clang-tidy/readability/TrailingCommaCheck.cpp
M clang-tools-extra/docs/ReleaseNotes.md
M clang-tools-extra/test/clang-tidy/checkers/readability/trailing-comma-cxx11.cpp
M clang-tools-extra/test/clang-tidy/checkers/readability/trailing-comma.cpp
Log Message:
-----------
[clang-tidy] Fix readability-trailing-comma false positive on #endif (#219634)
The `readability-trailing-comma` check looks at the token immediately
before an enum's closing brace to decide whether a trailing comma is
present. When the last enumerators are wrapped in `#ifdef` / `#else` /
`#endif`, that token is the directive identifier `endif`, so the check
reports a missing comma and `-fix` inserts `,` after `#endif`. That is
outside the enumerator list and corrupts the source even when every
enumerator already has a trailing comma.
Skip the diagnostic when the token before `}` is a preprocessor
directive (`#` or a token preceded by `#`). An enumerator whose name
happens to be `endif` is still diagnosed, because it is not preceded by
`#`.
Fixes #218957
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