[clang-tidy] google-explicit-constructor: don't match in template instantiations

This helps avoiding false positives related to the recently added
std::initializer_list<> handling.

llvm-svn: 222981
This commit is contained in:
Alexander Kornienko 2014-11-30 19:41:41 +00:00
parent 7432a64dcb
commit ad5074df0c
2 changed files with 20 additions and 1 deletions

View File

@ -19,7 +19,8 @@ namespace clang {
namespace tidy {
void ExplicitConstructorCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(constructorDecl().bind("ctor"), this);
Finder->addMatcher(constructorDecl(unless(isInstantiated())).bind("ctor"),
this);
}
// Looks for the token matching the predicate and returns the range of the found

View File

@ -78,3 +78,21 @@ struct C {
C(const initializer_list<unsigned> &list2) {}
C(initializer_list<unsigned> &&list3) {}
};
struct D {
template <typename T>
explicit D(T t) {}
};
template <typename T>
struct E {
explicit E(T t) {}
template <typename U>
explicit E(U u) {}
};
void f(std::initializer_list<int> list) {
D d(list);
E<decltype(list)> e(list);
E<int> e2(list);
}