llvm / llvm/llvm-project

[clang-tidy] pro-bounds-avoid-unchecked-container-access should only warn when method `at()` is present.

Open
#195,837 3 comments 2 reactions 0 assignees View on GitHub
clang-tidy enhancement
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

From https://github.com/llvm/llvm-project/pull/95220#issuecomment-4370119622:

> Would it be possible to add an option which only generates a warning if there is an at method available?

> For example, std::span in C++20 mode does not have .at() yet. But even worse, when using libraries with custom map types tons of these warnings are generated (all of which are false positives), making it somewhat useless since the only reasonable way to handle the flood of warnings is to disable it entirely (there are too many classes to ignore them all), which would be unfortunate.

Contributor guide

Open the contributing guide

Research direction

Start by locating the clang-tidy pro-bounds-avoid-unchecked-container-access check and read the linked PR discussion for the proposed option behavior. Done means the check warns only when the inspected type provides an at() method, while types such as std::span and custom map types without at() avoid the warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.