[PATCH] D36822: [clang-tidy] Ignore statements inside a template instantiation.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 17 07:32:55 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311086: [clang-tidy] Ignore statements inside a template instantiation. (authored by hokein).
Repository:
rL LLVM
https://reviews.llvm.org/D36822
Files:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -86,15 +86,17 @@
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
equalsBoundNode(PointerType))))),
CanCallCtor)
- .bind(NewExpression)))
+ .bind(NewExpression)),
+ unless(isInTemplateInstantiation()))
.bind(ConstructorCall)))),
this);
Finder->addMatcher(
cxxMemberCallExpr(
thisPointerType(getSmartPointerTypeMatcher()),
callee(cxxMethodDecl(hasName("reset"))),
- hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
+ hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+ unless(isInTemplateInstantiation()))
.bind(ResetCall),
this);
}
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -451,3 +451,15 @@
// CHECK-FIXES: (*this) = std::make_unique<Foo>();
}
};
+
+// Ignore statements inside a template instantiation.
+template<typename T>
+void template_fun(T* t) {
+ std::unique_ptr<T> t2 = std::unique_ptr<T>(new T);
+ t2.reset(new T);
+}
+
+void invoke_template() {
+ Foo* foo;
+ template_fun(foo);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36822.111511.patch
Type: text/x-patch
Size: 1744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170817/2ecc1774/attachment.bin>
More information about the cfe-commits
mailing list