diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2015-08-28 19:27:19 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2015-08-28 19:27:19 +0000 |
commit | 327e97bb37ec535f134b0b3e7ecbb9c181ad4f4c (patch) | |
tree | 787f0b09c43bf1d18e7b891e8f6d33cd4bbc5956 /clang-tools-extra/clang-tidy/misc/AssignOperatorSignatureCheck.cpp | |
parent | ff7da34bc36d2859076876637ad2b04796cbb81c (diff) | |
download | bcm5719-llvm-327e97bb37ec535f134b0b3e7ecbb9c181ad4f4c.tar.gz bcm5719-llvm-327e97bb37ec535f134b0b3e7ecbb9c181ad4f4c.zip |
Disable clang-tidy misc checkers when not compiling in C++ mode. Many of the checkers do not 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: 246318
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/AssignOperatorSignatureCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/AssignOperatorSignatureCheck.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/AssignOperatorSignatureCheck.cpp b/clang-tools-extra/clang-tidy/misc/AssignOperatorSignatureCheck.cpp index ad62c565b18..5b71e0e1dbd 100644 --- a/clang-tools-extra/clang-tidy/misc/AssignOperatorSignatureCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/AssignOperatorSignatureCheck.cpp @@ -19,31 +19,37 @@ namespace misc { void AssignOperatorSignatureCheck::registerMatchers( ast_matchers::MatchFinder *Finder) { - const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType(pointee( - unless(isConstQualified()), hasDeclaration(equalsBoundNode("class")))))); + // Only register the matchers for C++; the functionality currently does not + // provide any benefit to other languages, despite being benign. + if (getLangOpts().CPlusPlus) { + const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType( + pointee(unless(isConstQualified()), + hasDeclaration(equalsBoundNode("class")))))); - const auto IsSelf = qualType( - anyOf(hasDeclaration(equalsBoundNode("class")), - referenceType(pointee(hasDeclaration(equalsBoundNode("class")))))); - const auto IsSelfAssign = - methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())), - hasName("operator="), ofClass(recordDecl().bind("class")), - hasParameter(0, parmVarDecl(hasType(IsSelf)))).bind("method"); + const auto IsSelf = qualType(anyOf( + hasDeclaration(equalsBoundNode("class")), + referenceType(pointee(hasDeclaration(equalsBoundNode("class")))))); + const auto IsSelfAssign = + methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())), + hasName("operator="), ofClass(recordDecl().bind("class")), + hasParameter(0, parmVarDecl(hasType(IsSelf)))) + .bind("method"); - Finder->addMatcher( - methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"), - this); + Finder->addMatcher( + methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"), + this); - const auto BadSelf = referenceType( - anyOf(lValueReferenceType(pointee(unless(isConstQualified()))), - rValueReferenceType(pointee(isConstQualified())))); + const auto BadSelf = referenceType( + anyOf(lValueReferenceType(pointee(unless(isConstQualified()))), + rValueReferenceType(pointee(isConstQualified())))); - Finder->addMatcher( - methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf)))) - .bind("ArgumentType"), - this); + Finder->addMatcher( + methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf)))) + .bind("ArgumentType"), + this); - Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this); + Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this); + } } |