[clang-tools-extra] [clang-tidy] Add new `construct-reusable-objects-once` check (PR #131455)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 15 14:53:25 PDT 2025


PiotrZSL wrote:

"What about separating this check in two: construct-reusable-objects-once and initialize-big-containers-once?"
No point, try making generic check without a code specific for selected objects like std::regexp or containers.
Add ExcludeRegexp, to be able to make it work for all objects expect some.

Simplify marchers, for example check (make it generic - enable check only for objects that meet conditions):
- if object is used only as const (const method called, members passed only as const references or copies)
- object is not moved
- during initialization only constexpr variables are used, or other const global/static objects
- ...

https://github.com/llvm/llvm-project/pull/131455


More information about the cfe-commits mailing list