-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillaclang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature
Description
| Bugzilla Link | 37348 |
| Version | unspecified |
| OS | Windows NT |
| Reporter | LLVM Bugzilla Contributor |
| CC | @EugeneZelenko |
Extended Description
When using clang-tidy on a Visual Studio 2017 codebase together with the VS2017 STL, readability-redundant-smartptr-get doesn't recognize std::shared_ptr as smart pointer and thus doesn't flag anything.
This seems to be caused by the QuacksLikeASmartptr matcher, which expects any smart pointer to have a operator-> and operator* method:
const auto QuacksLikeASmartptr = recordDecl(
recordDecl().bind("duck_typing"),
has(cxxMethodDecl(hasName("operator->"),
returns(qualType(pointsTo(type().bind("op->Type")))))),
has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
type().bind("op*Type")))))));
The VS2017 std::shared_ptr defines these operators as method templates and is thus not matched:
template<class _Ty2 = _Ty,
enable_if_t<!disjunction_v<is_array<_Ty2>, is_void<_Ty2>>, int> = 0>
_NODISCARD _Ty2& operator*() const _NOEXCEPT
template<class _Ty2 = _Ty,
enable_if_t<!is_array_v<_Ty2>, int> = 0>
_NODISCARD _Ty2 * operator->() const _NOEXCEPT
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillaclang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature