diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-05-30 13:40:53 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-05-30 13:40:53 +0200 |
commit | f6dda4e1603ee1d901bf747c60f232db1f1b56a5 (patch) | |
tree | 0f69a52d737129af8d2e6e2e33f9c8f65adc24ab /compilerplugins/clang/redundantcast.cxx | |
parent | db38e3f201517acf22c1773ae9fc4cb2514788b1 (diff) |
Make loplugin:redundantcast accept bool(FD_ISSET(...)) again
Change-Id: I4e96c55c246cf806f17df31844a00d0e8a5e4f56
Diffstat (limited to 'compilerplugins/clang/redundantcast.cxx')
-rw-r--r-- | compilerplugins/clang/redundantcast.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 148cdbead9be..6a554a774ee2 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -483,6 +483,30 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/svx/source/tbxctrls/fillctrl.cxx")) return true; + // See the commit message of d0e7d020fa405ab94f19916ec96fbd4611da0031 + // "socket.c -> socket.cxx" for the reason to have + // + // bool(FD_ISSET(...)) + // + // in sal/osl/unx/socket.cxx: + auto const sub = compat::getSubExprAsWritten(expr); + //TODO: Better check that sub is exactly an expansion of FD_ISSET: + if (sub->getLocEnd().isMacroID()) { + for (auto loc = sub->getLocStart(); + loc.isMacroID() + && (compiler.getSourceManager() + .isAtStartOfImmediateMacroExpansion(loc)); + loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc)) + { + if (Lexer::getImmediateMacroName( + loc, compiler.getSourceManager(), compiler.getLangOpts()) + == "FD_ISSET") + { + return true; + } + } + } + auto const t1 = expr->getTypeAsWritten(); auto const t2 = compat::getSubExprAsWritten(expr)->getType(); if (t1 != t2) |