diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-15 14:56:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-17 10:16:35 +0200 |
commit | 2e975301023354695e686812382b67c858774f67 (patch) | |
tree | 652b23baf265603cf3556e977b606c98d3041a9b /compilerplugins/clang/useuniqueptr.cxx | |
parent | 48f89a858b13ac8d1bb7c1d2119126728e48d18a (diff) |
loplugin:useuniqueptr expand search for ranged-loop-delete
Change-Id: I78955f4db9b4da2858dfb25e69a5502eb0280418
Diffstat (limited to 'compilerplugins/clang/useuniqueptr.cxx')
-rw-r--r-- | compilerplugins/clang/useuniqueptr.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index c14d5fc5a57b..24992685df43 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -256,7 +256,11 @@ void UseUniquePtr::CheckForRangedLoopDelete(const CXXDestructorDecl* destructorD auto cxxForRangeStmt = dyn_cast<CXXForRangeStmt>(*i); if (!cxxForRangeStmt) continue; - auto deleteExpr = dyn_cast<CXXDeleteExpr>(cxxForRangeStmt->getBody()); + CXXDeleteExpr const * deleteExpr = nullptr; + if (auto compoundStmt = dyn_cast<CompoundStmt>(cxxForRangeStmt->getBody())) + deleteExpr = dyn_cast<CXXDeleteExpr>(*compoundStmt->body_begin()); + else + deleteExpr = dyn_cast<CXXDeleteExpr>(cxxForRangeStmt->getBody()); if (!deleteExpr) continue; auto memberExpr = dyn_cast<MemberExpr>(cxxForRangeStmt->getRangeInit()); |