llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tidy @llvm/pr-subscribers-clang-tools-extra Author: None (flovent) <details> <summary>Changes</summary> Unlike other standard smart pointer types, std::unique_ptr has two template arguments. testcase need to be updated too. --- Full diff: https://github.com/llvm/llvm-project/pull/121266.diff 2 Files Affected: - (modified) clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp (+5-3) - (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp (+3-1) ``````````diff diff --git a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp index 8121a36f803460..1f432c4ccc5f00 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp @@ -74,9 +74,11 @@ void UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) { // Matcher for standard smart pointers. const auto SmartPointerType = qualType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(classTemplateSpecializationDecl( - hasAnyName("::std::shared_ptr", "::std::unique_ptr", - "::std::weak_ptr", "::std::auto_ptr"), - templateArgumentCountIs(1)))))); + anyOf(allOf(hasAnyName("::std::shared_ptr", "::std::weak_ptr", + "::std::auto_ptr"), + templateArgumentCountIs(1)), + allOf(hasName("::std::unique_ptr"), + templateArgumentCountIs(2)))))))); // We will warn only if the class has a pointer or a C array field which // probably causes a problem during self-assignment (e.g. first resetting diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp index 14d27855d7c5a6..8610393449f97f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp @@ -10,7 +10,9 @@ template <class T> T &&move(T &x) { } -template <class T> +template <typename T> class default_delete {}; + +template <class T, typename Deleter = std::default_delete<T>> class unique_ptr { }; `````````` </details> https://github.com/llvm/llvm-project/pull/121266 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits