summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Garcia Gomez <angelgarcia@google.com>2015-11-04 10:27:51 +0000
committerAngel Garcia Gomez <angelgarcia@google.com>2015-11-04 10:27:51 +0000
commit3d7d92283274d835463d35829c3e6523f153612a (patch)
tree220ffa7be5aa522bce2ed7777821f7d043054843
parent8bfc772da0063a6a86315bad61d8d49d4e69e192 (diff)
downloadbcm5719-llvm-3d7d92283274d835463d35829c3e6523f153612a.tar.gz
bcm5719-llvm-3d7d92283274d835463d35829c3e6523f153612a.zip
Improve modernize-make-unique matcher.
Summary: "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. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D14291 llvm-svn: 252041
-rw-r--r--clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp7
-rw-r--r--clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp6
2 files changed, 10 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
index b7c630c87b5..a585fe3e813 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -42,9 +42,10 @@ void MakeUniqueCheck::registerMatchers(MatchFinder *Finder) {
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);
}
diff --git a/clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp b/clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
index 6d23c4cb1fe..842955486a1 100644
--- a/clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
+++ b/clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
@@ -195,3 +195,9 @@ void whitespaces() {
// 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);
+}
OpenPOWER on IntegriCloud