diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-07-24 08:34:42 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-07-24 08:34:42 +0000 |
| commit | c1730e9bb9a9a8c4e222d65a1964265d0622f423 (patch) | |
| tree | fea23ca71a02826fc7d1ff98a0cd1194eb6b4ee6 | |
| parent | 9acb9781050ed5e9b7f3a0fa87a49e2770c522d9 (diff) | |
| download | bcm5719-llvm-c1730e9bb9a9a8c4e222d65a1964265d0622f423.tar.gz bcm5719-llvm-c1730e9bb9a9a8c4e222d65a1964265d0622f423.zip | |
[clang-tidy] Fix a heap use-after-free bug detected by asan.
llvm-svn: 213845
| -rw-r--r-- | clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp b/clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp index f1d90425108..1aabf6a10ba 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp @@ -17,7 +17,7 @@ namespace clang { namespace ast_matchers { AST_MATCHER(CXXRecordDecl, hasUserDeclaredDestructor) { // TODO: If the dtor is there but empty we don't want to warn either. - return Node.hasUserDeclaredDestructor(); + return Node.hasDefinition() && Node.hasUserDeclaredDestructor(); } } // namespace ast_matchers @@ -73,9 +73,9 @@ void UnusedRAIICheck::check(const MatchFinder::MatchResult &Result) { // Otherwise just suggest adding a name. To find the place to insert the name // find the first TypeLoc in the children of E, which always points to the // written type. - const auto *TL = - selectFirst<TypeLoc>("t", match(expr(hasDescendant(typeLoc().bind("t"))), - *E, *Result.Context)); + auto Matches = + match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context); + const auto *TL = selectFirst<TypeLoc>("t", Matches); D << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(TL->getLocEnd(), 0, *Result.SourceManager, Result.Context->getLangOpts()), |

