From 08967d36ba0da5bf85e52ff64f41732a12b37a2e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 7 May 2015 11:18:25 +0200 Subject: workaround for clang3.2 in vclwidgets clang plugin Change-Id: I7ac67dd14d14a93fe163febe0f18df56dd613376 --- compilerplugins/clang/vclwidgets.cxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'compilerplugins/clang') 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(*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(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(x)) + nNumExtraStatements++; } + ok = bFoundDisposeOnce && nNumExtraStatements == 0; } if (!ok) { SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc( -- cgit