Author: hokein Date: Thu Aug 17 07:12:38 2017 New Revision: 311086 URL: http://llvm.org/viewvc/llvm-project?rev=311086&view=rev Log: [clang-tidy] Ignore statements inside a template instantiation.
Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36822 Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=311086&r1=311085&r2=311086&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Thu Aug 17 07:12:38 2017 @@ -86,7 +86,8 @@ void MakeSmartPtrCheck::registerMatchers cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType( equalsBoundNode(PointerType))))), CanCallCtor) - .bind(NewExpression))) + .bind(NewExpression)), + unless(isInTemplateInstantiation())) .bind(ConstructorCall)))), this); @@ -94,7 +95,8 @@ void MakeSmartPtrCheck::registerMatchers cxxMemberCallExpr( thisPointerType(getSmartPointerTypeMatcher()), callee(cxxMethodDecl(hasName("reset"))), - hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression))) + hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)), + unless(isInTemplateInstantiation())) .bind(ResetCall), this); } Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=311086&r1=311085&r2=311086&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Thu Aug 17 07:12:38 2017 @@ -451,3 +451,15 @@ class UniqueFoo : public std::unique_ptr // 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); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits