compilerplugins/clang/unnecessaryparen.cxx | 33 +++++++++-------------------- sc/source/ui/view/gridwin.cxx | 2 - 2 files changed, 12 insertions(+), 23 deletions(-)
New commits: commit 5640ef110094f33cf678f4e3ef4f3fd4334a00c8 Author: Stephan Bergmann <sberg...@redhat.com> Date: Wed Nov 22 09:54:10 2017 +0100 There appears to be no reason to ignore macros in these parts of... ...loplugin:unnecessaryparen Change-Id: I473a1e16cf9f485a61af5477aca22798996253a3 diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx index 57c9cd9c65b4..fe3b0dd4b028 100644 --- a/compilerplugins/clang/unnecessaryparen.cxx +++ b/compilerplugins/clang/unnecessaryparen.cxx @@ -146,15 +146,16 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr) } if (auto declRefExpr = dyn_cast<DeclRefExpr>(subExpr)) { - if (declRefExpr->getLocStart().isMacroID()) - return true; - - // hack for BAD_CAST macro - SourceManager& SM = compiler.getSourceManager(); - const char *p1 = SM.getCharacterData( declRefExpr->getLocStart().getLocWithOffset(-10) ); - const char *p2 = SM.getCharacterData( declRefExpr->getLocStart() ); - if ( std::string(p1, p2 - p1).find("BAD_CAST") != std::string::npos ) - return true; + // hack for libxml2's BAD_CAST object-like macro (expanding to "(xmlChar *)"), which is + // typically used as if it were a function-like macro, e.g., as "BAD_CAST(pName)" in + // SwNode::dumpAsXml (sw/source/core/docnode/node.cxx) + if (!declRefExpr->getLocStart().isMacroID()) { + SourceManager& SM = compiler.getSourceManager(); + const char *p1 = SM.getCharacterData( declRefExpr->getLocStart().getLocWithOffset(-10) ); + const char *p2 = SM.getCharacterData( declRefExpr->getLocStart() ); + if ( std::string(p1, p2 - p1).find("BAD_CAST") != std::string::npos ) + return true; + } report( DiagnosticsEngine::Warning, "unnecessary parentheses around identifier", @@ -163,9 +164,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr) } - if (auto cxxNamedCastExpr = dyn_cast<CXXNamedCastExpr>(subExpr)) { - if (cxxNamedCastExpr->getLocStart().isMacroID()) - return true; + if (isa<CXXNamedCastExpr>(subExpr)) { report( DiagnosticsEngine::Warning, "unnecessary parentheses around cast", parenExpr->getLocStart()) @@ -209,8 +208,6 @@ bool UnnecessaryParen::VisitReturnStmt(const ReturnStmt* returnStmt) { if (ignoreLocation(returnStmt)) return true; - if (returnStmt->getLocStart().isMacroID()) - return true; if (!returnStmt->getRetValue()) return true; @@ -240,8 +237,6 @@ void UnnecessaryParen::VisitSomeStmt(const Stmt * stmt, const Expr* cond, String { if (ignoreLocation(stmt)) return; - if (stmt->getLocStart().isMacroID()) - return; auto parenExpr = dyn_cast<ParenExpr>(ignoreAllImplicit(cond)); if (parenExpr) { @@ -269,8 +264,6 @@ bool UnnecessaryParen::VisitCallExpr(const CallExpr* callExpr) { if (ignoreLocation(callExpr)) return true; - if (callExpr->getLocStart().isMacroID()) - return true; if (callExpr->getNumArgs() != 1 || isa<CXXOperatorCallExpr>(callExpr)) return true; @@ -294,8 +287,6 @@ bool UnnecessaryParen::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr* callE { if (ignoreLocation(callExpr)) return true; - if (callExpr->getLocStart().isMacroID()) - return true; if (callExpr->getNumArgs() != 2) return true; @@ -334,8 +325,6 @@ bool UnnecessaryParen::VisitVarDecl(const VarDecl* varDecl) { if (ignoreLocation(varDecl)) return true; - if (varDecl->getLocStart().isMacroID()) - return true; if (!varDecl->getInit()) return true; diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 7dd772d5b2a1..3bc7ccbb9685 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3599,7 +3599,7 @@ sal_Int8 ScGridWindow::AcceptDrop( const AcceptDropEvent& rEvt ) // clear DND_ACTION_LINK when other actions are set. The usage below cannot handle // multiple set values - if((nMyAction & DND_ACTION_LINK) && (nMyAction & (DND_ACTION_COPYMOVE))) + if((nMyAction & DND_ACTION_LINK) && (nMyAction & DND_ACTION_COPYMOVE)) { nMyAction &= ~DND_ACTION_LINK; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits