[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 19 17:31:49 UTC 2019
compilerplugins/clang/fakebool.cxx | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
New commits:
commit d273ea2a43886138be553514218c0c3ffda5900f
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Nov 19 15:45:57 2019 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Nov 19 18:30:47 2019 +0100
Fix loplugin:fakebool (clang-cl)
...where it failed with
> [build CXX] setup_native/source/win32/customactions/sellang/sorttree.cxx
> C:/lo-clang/core/setup_native/source/win32/customactions/sellang/sorttree.cxx(43,5): error: CStyleCastExpr, suspicious cast from 'LRESULT' (aka 'long long') to 'BOOL' (aka 'int') [loplugin:fakebool]
> TreeView_SortChildren(hwndTV, dicts, TRUE);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/um\commctrl.h(5227,5): note: expanded from macro 'TreeView_SortChildren'
> (BOOL)SNDMSG((hwnd), TVM_SORTCHILDREN, (WPARAM)(recurse), (LPARAM)(HTREEITEM)(hitem))
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> C:/lo-clang/core/setup_native/source/win32/customactions/sellang/sorttree.cxx(43,5): error: conversion from 'LRESULT' (aka 'long long') to 'BOOL' (aka 'int') [loplugin:fakebool]
> TreeView_SortChildren(hwndTV, dicts, TRUE);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/um\commctrl.h(5227,11): note: expanded from macro 'TreeView_SortChildren'
> (BOOL)SNDMSG((hwnd), TVM_SORTCHILDREN, (WPARAM)(recurse), (LPARAM)(HTREEITEM)(hitem))
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/um\prsht.h(73,16): note: expanded from macro 'SNDMSG'
> #define SNDMSG ::SendMessage
> ^
(And the improved check in FakeBool::VisitImplicitCastExpr nicely removes the
need to list all the individual false/true macros.)
Change-Id: I815172f32f493bba336008aaacc00545e61ada7b
Reviewed-on: https://gerrit.libreoffice.org/83215
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/compilerplugins/clang/fakebool.cxx b/compilerplugins/clang/fakebool.cxx
index 93fdeddaa83d..da42db3fde69 100644
--- a/compilerplugins/clang/fakebool.cxx
+++ b/compilerplugins/clang/fakebool.cxx
@@ -689,6 +689,9 @@ bool FakeBool::VisitCStyleCastExpr(CStyleCastExpr * expr) {
}
return true;
}
+ if (isSharedCAndCppCode(loc)) {
+ return true;
+ }
}
report(
DiagnosticsEngine::Warning,
@@ -743,24 +746,15 @@ bool FakeBool::VisitImplicitCastExpr(ImplicitCastExpr * expr) {
if (ignoreLocation(expr)) {
return true;
}
- auto const k = isFakeBool(expr->getType());
- if (k == FBK_No) {
+ if (isFakeBool(expr->getType()) == FBK_No) {
return true;
}
auto l = compat::getBeginLoc(expr);
while (compiler.getSourceManager().isMacroArgExpansion(l)) {
l = compiler.getSourceManager().getImmediateMacroCallerLoc(l);
}
- if (compiler.getSourceManager().isMacroBodyExpansion(l)) {
- auto n = Lexer::getImmediateMacroName(
- l, compiler.getSourceManager(), compiler.getLangOpts());
- if ((k == FBK_GLboolean && (n == "GL_FALSE" || n == "GL_TRUE"))
- || (k == FBK_UBool && (n == "FALSE" || n == "TRUE"))
- || (k == FBK_jboolean && (n == "JNI_FALSE" || n == "JNI_TRUE"))
- || (k == FBK_sal_Bool && (n == "sal_False" || n == "sal_True")))
- {
- return true;
- }
+ if (compiler.getSourceManager().isMacroBodyExpansion(l) && isSharedCAndCppCode(l)) {
+ return true;
}
auto e1 = expr->getSubExprAsWritten();
auto t = e1->getType();
More information about the Libreoffice-commits
mailing list