forked from OSchip/llvm-project
[clang-tidy] Use new ASTMatchers to identify template instantiations instead of copying it everywhere.
No intended functionality change. llvm-svn: 217035
This commit is contained in:
parent
0a53727502
commit
b7f59d6bbd
|
|
@ -21,15 +21,12 @@ namespace runtime {
|
|||
|
||||
void
|
||||
MemsetZeroLengthCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
|
||||
auto InTemplateInstantiation = hasAncestor(
|
||||
decl(anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),
|
||||
functionDecl(ast_matchers::isTemplateInstantiation()))));
|
||||
// Look for memset(x, y, 0) as those is most likely an argument swap.
|
||||
// TODO: Also handle other standard functions that suffer from the same
|
||||
// problem, e.g. memchr.
|
||||
Finder->addMatcher(
|
||||
callExpr(callee(functionDecl(hasName("::memset"))), argumentCountIs(3),
|
||||
unless(InTemplateInstantiation)).bind("decl"),
|
||||
unless(isInTemplateInstantiation())).bind("decl"),
|
||||
this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,12 +26,8 @@ void StringReferenceMemberCheck::registerMatchers(
|
|||
auto ConstString = qualType(isConstQualified(), hasDeclaration(String));
|
||||
|
||||
// Ignore members in template instantiations.
|
||||
auto InTemplateInstantiation = hasAncestor(
|
||||
decl(anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),
|
||||
functionDecl(ast_matchers::isTemplateInstantiation()))));
|
||||
|
||||
Finder->addMatcher(fieldDecl(hasType(references(ConstString)),
|
||||
unless(InTemplateInstantiation)).bind("member"),
|
||||
unless(isInstantiated())).bind("member"),
|
||||
this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@ AST_MATCHER(QualType, isBoolean) { return Node->isBooleanType(); }
|
|||
namespace tidy {
|
||||
|
||||
void BoolPointerImplicitConversion::registerMatchers(MatchFinder *Finder) {
|
||||
auto InTemplateInstantiation = hasAncestor(
|
||||
decl(anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),
|
||||
functionDecl(ast_matchers::isTemplateInstantiation()))));
|
||||
// Look for ifs that have an implicit bool* to bool conversion in the
|
||||
// condition. Filter negations.
|
||||
Finder->addMatcher(
|
||||
|
|
@ -36,7 +33,7 @@ void BoolPointerImplicitConversion::registerMatchers(MatchFinder *Finder) {
|
|||
hasType(pointerType(pointee(isBoolean()))),
|
||||
ignoringParenImpCasts(declRefExpr().bind("expr")))),
|
||||
isPointerToBoolean())))),
|
||||
unless(InTemplateInstantiation)).bind("if"),
|
||||
unless(isInTemplateInstantiation())).bind("if"),
|
||||
this);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue