summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-11-19 15:45:57 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-11-19 18:30:47 +0100
commitd273ea2a43886138be553514218c0c3ffda5900f (patch)
treeeb43ab98485536cf8dc8ae468caaef0acfb48c4f
parentfd6d48cbb8b43aa13d475873f1a5355106b2e649 (diff)
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@redhat.com>
-rw-r--r--compilerplugins/clang/fakebool.cxx18
1 files changed, 6 insertions, 12 deletions
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();