[clang-tools-extra] [clang-tidy] Fix false positive for cppcoreguidelines-pro-bounds-pointer-arithmetic (PR #127394)

via cfe-commits cfe-commits at lists.llvm.org
Thu May 1 01:49:24 PDT 2025


flovent wrote:

> but won't this fail with a std::map<int, int>, since the key is an integer?

It won't, `ArraySubScriptExpr` is generated here because variable `map`'s type is dependent, it's AST:
```
ArraySubscriptExpr <col:10, col:15> '<dependent type>' lvalue
      -DeclRefExpr <col:10> 'std::map<R *, int>':'map<R *, int>' lvalue ParmVar 0x227b3b48 'map' 'std::map<R *, int> &'
      -DeclRefExpr <col:14> 'R *' lvalue ParmVar 0x227b3bc8 'r' 'R *'
```
`std::map`'s key is unrelated here, for `std::map<int, int>` a `CallExpr` will be generated since it's known that `std::map<int, int>` has a overload operator `[]`


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


More information about the cfe-commits mailing list