[PATCH] D14291: Improve modernize-make-unique matcher.
Angel Garcia via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 3 09:50:01 PST 2015
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14291.39081.patch
Type: text/x-patch
Size: 1556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151103/f74c72bd/attachment.bin>
More information about the cfe-commits
mailing list