Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
arraySubscriptExpr(
hasBase(ignoringImpCasts(
anyOf(AllPointerTypes,
hasType(decayedType(hasDecayedType(pointerType())))))))
hasType(decayedType(hasDecayedType(pointerType())))))),
hasIndex(hasType(isInteger())))
.bind("expr"),
this);
}
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ Changes in existing checks
<clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by adding a
flag to specify the function used for forwarding instead of ``std::forward``.

- Improved :doc:`cppcoreguidelines-pro-bounds-pointer-arithmetic
<clang-tidy/checks/cppcoreguidelines/pro-bounds-pointer-arithmetic>` check by
fixing false positives when calling indexing operators that do not perform
pointer arithmetic in template, for example ``std::map::operator[]``.

- Improved :doc:`cppcoreguidelines-rvalue-reference-param-not-moved
<clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved>` check
by adding a flag to specify the function used for moving instead of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,25 @@ void okay() {

for(int ii : a) ; // OK, pointer arithmetic generated by compiler
}

namespace gh126424 {

namespace std {
template <typename, typename>
class pair {};

template <typename Key, typename Value>
class map {
public:
using value_type = pair<Key, Value>;
value_type& operator[](const Key& key);
value_type& operator[](Key&& key);
};
}

template <typename R>
int f(std::map<R*, int>& map, R* r) {
return map[r]; // OK
}

}
Loading