[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 15 13:39:50 UTC 2019
compilerplugins/clang/consttobool.cxx | 9 +++++++++
1 file changed, 9 insertions(+)
New commits:
commit 82e1697d29fc783905a71278d36cec1d07e134a3
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Nov 15 11:24:24 2019 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Nov 15 14:38:27 2019 +0100
Fix loplugin:consttobool for assert on macOS
...which internally uses __builtin_expect and thus caused
> core/include/com/sun/star/uno/Any.hxx:750:13: error: implicit conversion of constant 1 of type 'long' to 'bool'; use 'true' instead [loplugin:consttobool]
> assert(false); // this cannot happen
> ^~~~~~~~~~~~~
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/assert.h:93:6: note: expanded from macro 'assert'
> (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~
(See 216bcceee1ba908f617deb3f2404aff8085d5358 "Special handling of
__builtin_expect in boolean expressions" for a similar fix in
loplugin:literaltoboolconversion.)
Change-Id: I4cf4b21006176c908995f5753dd0a38165383d87
Reviewed-on: https://gerrit.libreoffice.org/82773
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/compilerplugins/clang/consttobool.cxx b/compilerplugins/clang/consttobool.cxx
index 21fde3f547b1..a3c57d704b26 100644
--- a/compilerplugins/clang/consttobool.cxx
+++ b/compilerplugins/clang/consttobool.cxx
@@ -190,6 +190,15 @@ public:
return true;
}
}
+ if (auto const e = dyn_cast<CallExpr>(sub->IgnoreParenImpCasts()))
+ {
+ // Ignore use of `long __builtin_expect(long, long)`, as found in the definition of
+ // `assert` on macOS:
+ if (e->getBuiltinCallee() == Builtin::BI__builtin_expect)
+ {
+ return true;
+ }
+ }
bool suggestion;
bool replacement = {};
if (res.isInt())
More information about the Libreoffice-commits
mailing list