[all-commits] [llvm/llvm-project] ab898f: [clang-tidy][NFC] Do less unnecessary work in `NoL...

Victor Chernyakin via All-commits all-commits at lists.llvm.org
Mon Sep 8 08:30:24 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ab898f32c60689d1d47d0b6de66c30d3476994bb
      https://github.com/llvm/llvm-project/commit/ab898f32c60689d1d47d0b6de66c30d3476994bb
  Author: Victor Chernyakin <chernyakin.victor.j at outlook.com>
  Date:   2025-09-08 (Mon, 08 Sep 2025)

  Changed paths:
    M clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
    M clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h

  Log Message:
  -----------
  [clang-tidy][NFC] Do less unnecessary work in `NoLintDirectiveHandler` (#147553)

Summary:
- `NoLintBlockToken` is too big: it stores a whole `NoLintToken` inside
itself, when all it needs from that `NoLintToken` is its `Pos` and
`ChecksGlob`.
- `formNoLintBlocks` builds up a vector of unmatched tokens, which are
later transformed into errors. We can skip the middle step and make
`formNoLintBlocks` create errors directly.
- In `generateCache`, the line `Cache[FileName] = ...;`
default-constructs a cache entry only to immediately overwrite it. We
can avoid that by using `Cache.try_emplace(FileName, ...);` instead.
- `NoLintToken`'s constructor takes `const std::optional<std::string>&`
when all it needs is `const std::optional<StringRef>&`. This forces its
caller, `getNoLints`, to create temporary strings.
- `NoLintToken::checks` returns `std::optional<std::string>` by value,
creating unnecessary copies in `formNoLintBlocks`.



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