hokein updated this revision to Diff 111510. hokein marked an inline comment as done. hokein added a comment.
Remove the CHECK-MESSAGE-NOT. https://reviews.llvm.org/D36822 Files: clang-tidy/modernize/MakeSmartPtrCheck.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 @@ -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); +} Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp =================================================================== --- clang-tidy/modernize/MakeSmartPtrCheck.cpp +++ 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: test/clang-tidy/modernize-make-unique.cpp =================================================================== --- test/clang-tidy/modernize-make-unique.cpp +++ 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); +} Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp =================================================================== --- clang-tidy/modernize/MakeSmartPtrCheck.cpp +++ 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); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits