[all-commits] [llvm/llvm-project] b041a5: [clang-tidy][NFC] concat static-analyzer name at c...

Victor Chernyakin via All-commits all-commits at lists.llvm.org
Wed Jul 9 05:06:04 PDT 2025


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

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

  Log Message:
  -----------
  [clang-tidy][NFC] concat static-analyzer name at compilation time (#147406)

```cpp
  for (std::string OptionName : {
#define GET_CHECKER_OPTIONS
#define CHECKER_OPTION(TYPE, CHECKER, OPTION_NAME, DESCRIPTION, DEFAULT,       \
                       RELEASE, HIDDEN)                                        \
  Twine(AnalyzerCheckNamePrefix).concat(CHECKER ":" OPTION_NAME).str(),

#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
#undef CHECKER_OPTION
#undef GET_CHECKER_OPTIONS
       }) {
    Result.Options.insert(OptionName);
  }
```
This code is doing a lot of unnecessary work at runtime. For each of the
(currently) 59 checker options, it runs
`Twine(AnalyzerCheckNamePrefix).concat(CHECKER ":" OPTION_NAME).str(),`,
which allocates a string (all of this is unrolled, leading to code
bloat). Then it copies all those strings (because `std::string
OptionName`, not `const std::string& OptionName`). All of this can be
done at compile time!



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