diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-11-27 11:22:15 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-11-29 17:44:19 +0100 |
commit | 760835877c6d64da239cc4791bdbf786f88c8bb1 (patch) | |
tree | 5b931ec97b9d81a39d3cc3da4e1956763a3f31ae /compilerplugins | |
parent | 201edc324fb9c4922ab4aa3c7233676ed43a8e03 (diff) |
Avoid loplugin:toolslong in system header macros
...as experienced with clang-cl:
> C:/lo-clang/core/sal/osl/w32/socket.cxx(968,44): error: CStyleCastExpr, suspicious cast from 'unsigned long long' to 'long' [loplugin:toolslong]
> ioctlsocket(pSocket->m_Socket, FIONBIO, &Param);
> ^~~~~~~
> C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/um\winsock2.h(220,21): note: expanded from macro 'FIONBIO'
> #define FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
> ^~~~~~~~~~~~~~~~~~~~~~
> C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/um\winsock2.h(217,35): note: expanded from macro '_IOW'
> #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
> ^~~~~~~~~~~~~~~
Change-Id: Ie2ccc816a214cf39a77bd0ffeddd9f1636f19cd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106756
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/toolslong.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compilerplugins/clang/toolslong.cxx b/compilerplugins/clang/toolslong.cxx index 26105a2697d8..5a3932e90dbd 100644 --- a/compilerplugins/clang/toolslong.cxx +++ b/compilerplugins/clang/toolslong.cxx @@ -420,6 +420,12 @@ bool ToolsLong::VisitCStyleCastExpr(CStyleCastExpr* expr) SourceLocation loc{ compat::getBeginLoc(expr) }; while (compiler.getSourceManager().isMacroArgExpansion(loc)) loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); + if (compiler.getSourceManager().isMacroBodyExpansion(loc) + && compiler.getSourceManager().isInSystemHeader( + compiler.getSourceManager().getSpellingLoc(loc))) + { + return true; + } report(DiagnosticsEngine::Warning, "CStyleCastExpr, suspicious cast from %0 to %1", compat::getBeginLoc(expr)) << expr->getSubExpr()->IgnoreParenImpCasts()->getType() << expr->getType() |