[clang-tidy] Add check to replace operator[] with at() Enforce SL.con.3 (#95220)

This PR is based on the PR #90043 by Sebastian Wolf who has given us
(Manuel and myself) permission to continue his work

The original PR message reads:

> The string based test to find out whether the check is applicable on
the class is not ideal, but I did not find a more elegant way, yet.
> If there is more clang-query magic available, that I'm not aware of,
I'm happy to adapt that.

As part of the reviews for that PR, Sebastian changed the following:

- Detect viable classes automatically instead of looking for fixed names
- Disable fix-it suggestions

This PR contains the same changes and, in addition, addresses further
feedback provided by the maintainers.

Changes in addition to the original PR:
- Exclude `std::map`, `std::flat_map`, and `std::unordered_map` from the
analysis by default, and add the ability for users to exclude additional
classes from the analysis
- Add the tests Piotr Zegar requested
- Rename the analysis from AvoidBoundsErrorsCheck to
PreferAtOverSubscriptOperatorCheck as requested by Piotr
- Add a more detailed description of what the analysis does as requested
by Piotr

We explicitly don't ignore unused code with
`TK_IgnoreUnlessSpelledInSource`, as requested by Piotr,
because it caused the template-related tests to fail.

We are not sure what the best behaviour for templates is; should we:

- not warn if using `at()` will make a different instantiation not
compile?
- warn at the place that requires the template instantiation?
- keep the warning and add the name of the class of the object / the
template parameters that lead to the message?
- not warn in templates at all because the code is implicit?

Carlos Galvez and Congcong Cai discussed the possibility of disabling
the check when exceptions are disabled, but we were unsure whether
they'd reached a conclusion and whether it was still relevant when
fix-it suggestions are disabled.

What do you think?

Co-authored-by: Manuel Pietsch <manuelpietsch@outlook.de>
Co-authored-by: Sebastian Wolf <wolf.sebastian@in.tum.de>

---------

Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
Co-authored-by: Baranov Victor <bar.victor.2002@gmail.com>
GitOrigin-RevId: bc278d00726fc7f37b3c6e6b1d0556f581f0865b
8 files changed