File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -74,9 +74,11 @@ void UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
7474 // Matcher for standard smart pointers.
7575 const auto SmartPointerType = qualType (hasUnqualifiedDesugaredType (
7676 recordType (hasDeclaration (classTemplateSpecializationDecl (
77- hasAnyName (" ::std::shared_ptr" , " ::std::unique_ptr" ,
78- " ::std::weak_ptr" , " ::std::auto_ptr" ),
79- templateArgumentCountIs (1 ))))));
77+ anyOf (allOf (hasAnyName (" ::std::shared_ptr" , " ::std::weak_ptr" ,
78+ " ::std::auto_ptr" ),
79+ templateArgumentCountIs (1 )),
80+ allOf (hasName (" ::std::unique_ptr" ),
81+ templateArgumentCountIs (2 ))))))));
8082
8183 // We will warn only if the class has a pointer or a C array field which
8284 // probably causes a problem during self-assignment (e.g. first resetting
Original file line number Diff line number Diff line change @@ -233,6 +233,10 @@ Changes in existing checks
233233 `bsl::optional ` and `bdlb::NullableValue ` from
234234 <https://github.com/bloomberg/bde>_.
235235
236+ - Improved :doc: `bugprone-unhandled-self-assignment
237+ <clang-tidy/checks/bugprone/unhandled-self-assignment>` check by fixing smart
238+ pointer check against std::unique_ptr type.
239+
236240- Improved :doc: `bugprone-unsafe-functions
237241 <clang-tidy/checks/bugprone/unsafe-functions>` check to allow specifying
238242 additional functions to match.
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ template <class T>
1010T &&move(T &x) {
1111}
1212
13- template <class T >
13+ template <typename T> class default_delete {};
14+
15+ template <class T , typename Deleter = std::default_delete<T>>
1416class unique_ptr {
1517};
1618
You can’t perform that action at this time.
0 commit comments