diff options
author | Noel Grandin <noel@peralex.com> | 2015-05-07 11:18:25 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-05-07 11:18:49 +0200 |
commit | 08967d36ba0da5bf85e52ff64f41732a12b37a2e (patch) | |
tree | 877d2ab21f9d0aa83f5b000a9e098dc385657167 /compilerplugins/clang/vclwidgets.cxx | |
parent | 4eeaaf84d4251d77a86155609e21f86add086f3f (diff) |
workaround for clang3.2 in vclwidgets clang plugin
Change-Id: I7ac67dd14d14a93fe163febe0f18df56dd613376
Diffstat (limited to 'compilerplugins/clang/vclwidgets.cxx')
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index 2e7d4eb86fa3..a09f8dbbd73d 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -186,16 +186,25 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD } // check that the destructor for a OutputDevice subclass does nothing except call into the disposeOnce() method bool ok = false; - if (pCompoundStatement && pCompoundStatement->size() == 1) { - const CXXMemberCallExpr *pCallExpr = dyn_cast<CXXMemberCallExpr>(*pCompoundStatement->body_begin()); - if (pCallExpr) { - if( const FunctionDecl* func = pCallExpr->getDirectCallee()) { - if( func->getNumParams() == 0 && func->getIdentifier() != NULL - && ( func->getName() == "disposeOnce" )) { - ok = true; + if (pCompoundStatement) { + bool bFoundDisposeOnce = false; + int nNumExtraStatements = 0; + for(auto const * x : pCompoundStatement->body()) + { + const CXXMemberCallExpr *pCallExpr = dyn_cast<CXXMemberCallExpr>(x); + if (pCallExpr) { + if( const FunctionDecl* func = pCallExpr->getDirectCallee()) { + if( func->getNumParams() == 0 && func->getIdentifier() != NULL + && ( func->getName() == "disposeOnce" )) { + bFoundDisposeOnce = true; + } } } + // checking for ParenExpr is a hacky way to ignore assert statements in older versions of clang (i.e. <= 3.2) + if (!pCallExpr && !dyn_cast<ParenExpr>(x)) + nNumExtraStatements++; } + ok = bFoundDisposeOnce && nNumExtraStatements == 0; } if (!ok) { SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc( |