Skip to content

Fix a batch of clang-tidy findings in src/#2252

Open
devtejasx wants to merge 5 commits into
google:mainfrom
devtejasx:clang-tidy-cleanups
Open

Fix a batch of clang-tidy findings in src/#2252
devtejasx wants to merge 5 commits into
google:mainfrom
devtejasx:clang-tidy-cleanups

Conversation

@devtejasx

Copy link
Copy Markdown
Contributor

Works through a slice of the clang-tidy findings collated in #1925, scoped to src/ and split into one commit per check for easier review:

  • misc-const-correctness: declare immutable locals const (13 files, includes the MutexLock guards and the State objects constructed for Setup/Teardown callbacks)
  • readability-uppercase-literal-suffix: 0u -> 0U
  • readability-simplify-boolean-expr / readability-isolate-declaration / readability-use-anyofallof: De Morgan simplifications in benchmark_runner.cc and commandlineflags.cc, split a multi-variable declaration in sysinfo.cc, replace a hand-written find loop in SameNames with std::all_of
  • misc-use-anonymous-namespace: move the file-static IgnoreColorPrint/FormatTime helpers in console_reporter.cc into an anonymous namespace

Not included on purpose: readability-convert-member-functions-to-static on PerfCountersMeasurement::Read (the suggestion is only valid for the non-libpfm stub, making it static would break the Linux/libpfm build), and the cppcoreguidelines-avoid-non-const-global-variables findings on flag definitions and registration globals, which look intentional.

The remaining findings were re-checked with clang-tidy 20 against a fresh compile_commands.json; the checks addressed here now report clean for src/ in a Windows configuration (Linux-only code paths, e.g. libpfm perf counters, were not analyzed and may retain findings).

Testing: full CMake test suite passes locally in Debug and the library and tests build warning-free in Release (-Wall -Wextra -Werror, MinGW-w64 GCC 15.2 on Windows 11).

Refs #1925

AI disclosure (per AGENTS.md): this change was developed with AI assistance (Anthropic's Claude).

devtejasx and others added 5 commits July 15, 2026 21:38
Applies the misc-const-correctness fixes flagged in google#1925 across
src/, covering the findings reachable in a Windows configuration.

Refs google#1925
Fixes the readability-uppercase-literal-suffix findings from google#1925
in src/ (0u -> 0U).

Refs google#1925
Fixes readability-simplify-boolean-expr, readability-isolate-declaration
and readability-use-anyofallof findings from google#1925 in src/: apply De
Morgan simplifications in benchmark_runner.cc and commandlineflags.cc,
split a multi-variable declaration in sysinfo.cc, and replace a
hand-written find loop in SameNames with std::all_of.

Refs google#1925
Fixes the misc-use-anonymous-namespace findings from google#1925 in src/:
IgnoreColorPrint and FormatTime in console_reporter.cc were
file-static functions.

Refs google#1925
@dmah42

dmah42 commented Jul 16, 2026

Copy link
Copy Markdown
Member

is there any kind of enforcement we can apply? we have a clang-tidy workflow that runs on PRs but it wasn't flagging any of these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants