From 969990becc001d5fe5a34ff976cb022786c10c76 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 9 Oct 2023 16:36:11 +0200 Subject: Avoid a false loplugin:casttovoid on macOS ...involving conditional preprocessed code at > vcl/skia/SkiaHelper.cxx:265:13: error: unnecessary cast to void [loplugin:casttovoid] > 265 | (void)blockDisable; > | ^~~~~~~~~~~~~~~~~~ > vcl/skia/SkiaHelper.cxx:286:22: note: first consumption is here [loplugin:casttovoid] > 286 | if (!blockDisable && !DefaultMTLDeviceIsSupported()) > | ^~~~~~~~~~~~ Change-Id: I222d72d240852be2d64fe08d345f00d137cd5a63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157707 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- compilerplugins/clang/casttovoid.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/casttovoid.cxx b/compilerplugins/clang/casttovoid.cxx index bddfcb4da503..c02cf6887365 100644 --- a/compilerplugins/clang/casttovoid.cxx +++ b/compilerplugins/clang/casttovoid.cxx @@ -425,6 +425,11 @@ private: } } } else { + if (auto const fun = dyn_cast_or_null(i.first->getDeclContext())) { + if (containsPreprocessingConditionalInclusion(fun->getSourceRange())) { + continue; + } + } for (auto const j: i.second.castToVoid) { report( DiagnosticsEngine::Warning, "unnecessary cast to void", -- cgit