[clang-tidy] performance-unnecessary-copy-initialization: Fix false negative.
authorClement Courbet <courbet@google.com>
Fri, 19 Nov 2021 15:42:32 +0000 (16:42 +0100)
committerClement Courbet <courbet@google.com>
Wed, 24 Nov 2021 07:07:21 +0000 (08:07 +0100)
commitba4411e7c6a5879ce8acf246b0cd03ec738d9d6b
tree455c7ea64dd21718a87a2e03b03fe343cf2bb907
parentb9fd7247a71d7ab652c3e827b7018d6ea446024e
[clang-tidy] performance-unnecessary-copy-initialization: Fix false negative.

`isConstRefReturningMethodCall` should be considering
`CXXOperatorCallExpr` in addition to `CXXMemberCallExpr`. Clang considers
these to be distinct (`CXXOperatorCallExpr` derives from `CallExpr`, not
`CXXMemberCallExpr`), but we don't care in the context of this
check.

This is important because of
`std::vector<Expensive>::operator[](size_t) const`.

Differential Revision: https://reviews.llvm.org/D114249
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp