[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() (PR #90043)

Carlos Galvez via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 10:49:55 PDT 2024


carlosgalvezp wrote:

> I don't think it is a good solution.

Can you elaborate?

As I wrote above, the C++ Core Guidelines do not require using `at()`. Therefore the check would be doing something different than what the guidelines require. The reason they don't require it is that there's multiple solutions to this problem, and using `at()` can even do more harm than good.

Warning about operator[] is good; but the fix is not globally accepted best practice (as per comments above). All I'm saying is that if this fix is wanted, it should be opt-in, which should be fairly easy to achieve?

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


More information about the cfe-commits mailing list