diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp index ffd114d4bab..c5798949605 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp @@ -27,20 +27,21 @@ namespace misc { void UnusedRAIICheck::registerMatchers(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) { - // Look for temporaries that are constructed in-place and immediately - // destroyed. Look for temporaries created by a functional cast but not for - // those returned from a call. - auto BindTemp = bindTemporaryExpr(unless(has(callExpr()))).bind("temp"); - Finder->addMatcher( - exprWithCleanups( - unless(isInTemplateInstantiation()), - hasParent(compoundStmt().bind("compound")), - hasType(recordDecl(hasNonTrivialDestructor())), - anyOf(has(BindTemp), has(functionalCastExpr(has(BindTemp))))) - .bind("expr"), - this); - } + if (!getLangOpts().CPlusPlus) + return; + + // Look for temporaries that are constructed in-place and immediately + // destroyed. Look for temporaries created by a functional cast but not for + // those returned from a call. + auto BindTemp = bindTemporaryExpr(unless(has(callExpr()))).bind("temp"); + Finder->addMatcher( + exprWithCleanups( + unless(isInTemplateInstantiation()), + hasParent(compoundStmt().bind("compound")), + hasType(recordDecl(hasNonTrivialDestructor())), + anyOf(has(BindTemp), has(functionalCastExpr(has(BindTemp))))) + .bind("expr"), + this); } void UnusedRAIICheck::check(const MatchFinder::MatchResult &Result) { |

