llvm-project/clang-tools-extra/test/clang-tidy
Adrian Vogelsgesang 3696c70e67 [clang-tidy] Add `readability-container-contains` check
This commit introduces a new check `readability-container-contains` which finds
usages of `container.count()` and `container.find() != container.end()` and
instead recommends the `container.contains()` method introduced in C++20.

For containers which permit multiple entries per key (`multimap`, `multiset`,
...), `contains` is more efficient than `count` because `count` has to do
unnecessary additional work.

While this this performance difference does not exist for containers with only
a single entry per key (`map`, `unordered_map`, ...), `contains` still conveys
the intent better.

Reviewed By: xazax.hun, whisperity

Differential Revision: http://reviews.llvm.org/D112646
2022-01-24 12:57:18 +01:00
..
checkers [clang-tidy] Add `readability-container-contains` check 2022-01-24 12:57:18 +01:00
infrastructure Disable clang-tidy warnings from system macros 2022-01-06 20:27:28 +00:00
check_clang_tidy.py [clang-tidy] Refactor: Extract Class CheckRunner on check_clang_tidy.py 2022-01-10 15:44:12 -07:00