forked from OSchip/llvm-project
[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 llvm-svn: 311086
This commit is contained in:
parent
36070ed8d2
commit
80330ffc6b
|
@ -86,7 +86,8 @@ void MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
|
|||
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
|
||||
equalsBoundNode(PointerType))))),
|
||||
CanCallCtor)
|
||||
.bind(NewExpression)))
|
||||
.bind(NewExpression)),
|
||||
unless(isInTemplateInstantiation()))
|
||||
.bind(ConstructorCall)))),
|
||||
this);
|
||||
|
||||
|
@ -94,7 +95,8 @@ void MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
|
|||
cxxMemberCallExpr(
|
||||
thisPointerType(getSmartPointerTypeMatcher()),
|
||||
callee(cxxMethodDecl(hasName("reset"))),
|
||||
hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
|
||||
hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
|
||||
unless(isInTemplateInstantiation()))
|
||||
.bind(ResetCall),
|
||||
this);
|
||||
}
|
||||
|
|
|
@ -451,3 +451,15 @@ class UniqueFoo : public std::unique_ptr<Foo> {
|
|||
// 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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue