angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: cfe-commits, alexfh.

"std::unique_ptr<int>" is not the same type as "std::unique_ptr<int, 
std::default_delete<int>>", unless we insert a "hasCanonicalType" in the 
middle. Probably it also happens in other cases related to default template 
argument.

http://reviews.llvm.org/D14291

Files:
  clang-tidy/modernize/MakeUniqueCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===================================================================
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -195,3 +195,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
   // CHECK-FIXES: auto Spaces = std::make_unique<int>();
 }
+
+void nesting() {
+  auto Nest = std::unique_ptr<std::unique_ptr<int>>(new 
std::unique_ptr<int>(new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use std::make_unique instead
+  // CHECK-FIXES: auto Nest = std::make_unique<std::unique_ptr<int>>(new int);
+}
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===================================================================
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -42,9 +42,10 @@
                                               qualType(equalsBoundNode(
                                                   PointerType))))))))))))))),
                 argumentCountIs(1),
-                hasArgument(0, cxxNewExpr(hasType(pointsTo(qualType(
-                                              equalsBoundNode(PointerType)))))
-                                   .bind(NewExpression)))
+                hasArgument(
+                    0, cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
+                                      equalsBoundNode(PointerType))))))
+                           .bind(NewExpression)))
                 .bind(ConstructorCall))),
         this);
   }


Index: test/clang-tidy/modernize-make-unique.cpp
===================================================================
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -195,3 +195,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
   // CHECK-FIXES: auto Spaces = std::make_unique<int>();
 }
+
+void nesting() {
+  auto Nest = std::unique_ptr<std::unique_ptr<int>>(new std::unique_ptr<int>(new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use std::make_unique instead
+  // CHECK-FIXES: auto Nest = std::make_unique<std::unique_ptr<int>>(new int);
+}
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===================================================================
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -42,9 +42,10 @@
                                               qualType(equalsBoundNode(
                                                   PointerType))))))))))))))),
                 argumentCountIs(1),
-                hasArgument(0, cxxNewExpr(hasType(pointsTo(qualType(
-                                              equalsBoundNode(PointerType)))))
-                                   .bind(NewExpression)))
+                hasArgument(
+                    0, cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
+                                      equalsBoundNode(PointerType))))))
+                           .bind(NewExpression)))
                 .bind(ConstructorCall))),
         this);
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to