Disable clang-tidy Google checkers when not compiling in C++ mode. None of the checkers require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct.

llvm-svn: 246663
This commit is contained in:
Aaron Ballman 2015-09-02 16:20:42 +00:00
parent fb497d79f6
commit ec3e5d6fd8
7 changed files with 32 additions and 11 deletions

View File

@ -20,8 +20,11 @@ namespace tidy {
namespace google {
void ExplicitConstructorCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(constructorDecl(unless(isInstantiated())).bind("ctor"),
this);
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
if (getLangOpts().CPlusPlus)
Finder->addMatcher(constructorDecl(unless(isInstantiated())).bind("ctor"),
this);
}
// Looks for the token matching the predicate and returns the range of the found

View File

@ -27,6 +27,11 @@ namespace build {
void
ExplicitMakePairCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
if (!getLangOpts().CPlusPlus)
return;
// Look for std::make_pair with explicit template args. Ignore calls in
// templates.
Finder->addMatcher(

View File

@ -22,15 +22,12 @@ namespace runtime {
using namespace ast_matchers;
void IntegerTypesCheck::registerMatchers(MatchFinder *Finder) {
// Find all TypeLocs.
Finder->addMatcher(typeLoc().bind("tl"), this);
// Find all TypeLocs. The relevant Style Guide rule only applies to C++.
if (getLangOpts().CPlusPlus)
Finder->addMatcher(typeLoc().bind("tl"), this);
}
void IntegerTypesCheck::check(const MatchFinder::MatchResult &Result) {
// The relevant Style Guide rule only applies to C++.
if (!Result.Context->getLangOpts().CPlusPlus)
return;
auto TL = *Result.Nodes.getNodeAs<TypeLoc>("tl");
SourceLocation Loc = TL.getLocStart();

View File

@ -21,6 +21,11 @@ namespace runtime {
void
OverloadedUnaryAndCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
if (!getLangOpts().CPlusPlus)
return;
// Match unary methods that overload operator&.
Finder->addMatcher(methodDecl(parameterCountIs(0), hasOverloadedOperatorName(
"&")).bind("overload"),

View File

@ -21,6 +21,11 @@ namespace runtime {
void StringReferenceMemberCheck::registerMatchers(
ast_matchers::MatchFinder *Finder) {
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
if (!getLangOpts().CPlusPlus)
return;
// Look for const references to std::string or ::string.
auto String = anyOf(recordDecl(hasName("::std::basic_string")),
recordDecl(hasName("::string")));

View File

@ -21,8 +21,11 @@ namespace build {
void UnnamedNamespaceInHeaderCheck::registerMatchers(
ast_matchers::MatchFinder *Finder) {
Finder->addMatcher(namespaceDecl(isAnonymous()).bind("anonymousNamespace"),
this);
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
if (getLangOpts().CPlusPlus)
Finder->addMatcher(namespaceDecl(isAnonymous()).bind("anonymousNamespace"),
this);
}
void

View File

@ -21,7 +21,10 @@ namespace build {
void UsingNamespaceDirectiveCheck::registerMatchers(
ast_matchers::MatchFinder *Finder) {
Finder->addMatcher(usingDirectiveDecl().bind("usingNamespace"), this);
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
if (getLangOpts().CPlusPlus)
Finder->addMatcher(usingDirectiveDecl().bind("usingNamespace"), this);
}
void