summaryrefslogtreecommitdiff
path: root/compilerplugins
AgeCommit message (Collapse)Author
2023-03-23loplugin:stringview: Constructing O[U]String from O[U]StringLiteral is cheapStephan Bergmann
...so don't warn about those, as requested in the comment at <https://gerrit.libreoffice.org/c/core/+/149254/8#message-6430dc5397ab7b60bf4e78e6856b44ab6cd72c97> "tdf#154319: fix TOC field codes parsing" Change-Id: I25989cd4b42bc3fe9062a8a0d6896d32a18635d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149417 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-18loplugin:stringadd use more O[U]StringCharNoel Grandin
Change-Id: I196e4539ad430a39415eff9d7170b33df7228230 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149062 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-17loplugin:rangedforcopy: Assume non-reference structured binding is intentionalStephan Bergmann
See pending <https://gerrit.libreoffice.org/c/core/+/149026> "tdf#148008: do not proceed after the marked range" for a use case. Change-Id: Ief7cbb215068b6f5428c16a72896ef5612204128 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149056 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-17Avoid loplugin:unusedmember crash for templated offsetofStephan Bergmann
Change-Id: I6cbac308d2911a502381067398d72136ca2b5ae3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149045 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-16Prepare compilerplugins for C++23 `if consteval`Stephan Bergmann
...for which clang::IfStmt::getCond returns null Change-Id: I8b86a033d52de87dedbdf6d867f2b3d3f57c1b5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148979 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-16Remove empty commentStephan Bergmann
...which I had added as part of 0025fa723afb9f6a0d94b9b3185ea14da18f1bd5 "Enable loplugin:unnecessaryparen for integer and Boolean literals", and where I apparently wanted to include a link but forgot to do so (and no longer know what link that would have been) Change-Id: I245725fea80ee0e13d76026656d433d5c42e4c19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148975 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-16Adapt loplugin:implicitboolconversion to _G_STR_NONNULLStephan Bergmann
...from glib2-devel-2.76.0-1.fc38.x86_64, causing > libreofficekit/source/gtk/lokdocview.cxx:390:28: error: implicit conversion (IntegralCast) from 'bool' to 'int' [loplugin:implicitboolconversion] > pLOEvent->m_pCommand = g_strdup(pCommand); > ^~~~~~~~~~~~~~~~~~ > /usr/include/glib-2.0/glib/gstrfuncs.h:212:35: note: expanded from macro 'g_strdup' > const char *const __str = _G_STR_NONNULL (___str); \ > ^~~~~~~~~~~~~~~~~~~~~~~ > /usr/include/glib-2.0/glib/gstrfuncs.h:157:34: note: expanded from macro '_G_STR_NONNULL' > #define _G_STR_NONNULL(x) ((x) + !(x)) > ^~~~ Change-Id: Iec20b20992a61fd48155f338a10dc313411448f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148948 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-10improve loplugin:unnecessarylockingNoel Grandin
to find more locking we can remove Change-Id: Ief7bc5ec2a1ff31f22a0ad366910b7fcc4725818 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148599 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-09Fix typoAndrea Gelmini
Change-Id: Ie69dd2bacbd1f1680d82ad113b707cca24950d2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148471 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-03-08new loplugin:unique2optionalNoel Grandin
I used this plugin to find places where we could inline a small child object into a parent object, saving allocation overhead. Moving it directly into store/ because it is not intended to be run under normal circumstances, needs hand-holding. Change-Id: I7245eef3dba187988bb9d4a39fd80624f46355d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148455 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-06The mentioned bug is fixed in Clang 17 trunk nowStephan Bergmann
Change-Id: Idb62b1b71a9f6fefc9225706655ca016304f1c42 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148191 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-02Record loplugin:unreffun false positive caused by a Clang bugStephan Bergmann
(see the comments at <https://gerrit.libreoffice.org/c/core/+/146634/7#message-5164bcbdb4efa4711f001ce05b670b592392d853> "test: Use css::awt::XExtentdedToolkit::addTopWindowListener()" for how this caused an issue in the wild) Change-Id: Id5ec77885db45d039aedc7e13d714aaa96572e91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148076 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-02-28Remove compilerplugins/clang/test/cppunitassertequals.hxxStephan Bergmann
...which isn't needed anymore to suppress warnings from other plugins like loplugin:external ever since 45c06838e95c94445359536d84c6328fa8b17a66 "only unit-test one loplugin at a time". Also, the declaration of the function test in cppunitassertequals.hxx had already started to deviate from its definition in cppunitassertequals.cxx. Change-Id: I3fbc8a9a805bd5bc4d8afbf958edff04b89add3f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148010 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-02-28Extend loplugin:cppunitassertequals to CPPUNIT_ASSERT_LESS etc.Stephan Bergmann
(Just in case, even though this doesn't find any actual issues in the code for now.) Change-Id: I80b8b0a647e89fdb6a4f0f4363fa1c3df8e5ddeb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147942 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-02-23Extend loplugin:cppunitassertequals to more argument typesStephan Bergmann
Change-Id: Ic2990ebc2e4a9a36dcd3f90c5f634ca7dd225d52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147491 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-02-15clean up SwRefMarkFieldUpdate a bitBjoern Michaelsen
- remove SwRefMarkFieldUpdate: * it has only one unused field * replace with a plain SwPtrMsgPoolItem - hint constness: * SwUndoFieldFromDoc: make ctor arg hint const * DocumentFieldsManager: make UpdateField arg hint const * however, seeing this hint is: a/ constructed on the stack, but b/ stored as pointer in undo likely it would be best to remove it altogether. For now, make it at least static, so that there is no use after free. Change-Id: Ica51a2a2ce19e1938c3a367e9b4a9e01bbb75374 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147030 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
2023-02-03Fix misuse of TagDecl::hasDefinitionStephan Bergmann
...that started to cause false > In file included from svl/source/items/itemiter.cxx:20: > include/svl/itemiter.hxx:25:1: error: SfxPoolItem subclass SfxPoolItem declares new fields, but does not override operator== [loplugin:sfxpoolitem] > class SfxPoolItem; > ^~~~~~~~~~~~~~~~~ etc. now as a side effect of <https://github.com/llvm/llvm-project/commit/b6121432da79c4b3d21f191864ff6c583e2e62eb> "[C++20] Fix a crash with modules." Change-Id: Ibbf7a7c840ecea2605d6ea76afd04a2c2720e54d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146544 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-01-31loplugin:unusedfieldsNoel Grandin
Change-Id: I6acce1578d21da0ac014410289def3dd500b4de3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146356 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-30loplugin:virtualdeadNoel Grandin
GetPDFAnchorStructureElementId was added in commit 6e5d59c2ca696, but was unused even there Change-Id: Id0624cac2854f5406ca93a4c495632fc3c1d0e74 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146354 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-30Missing include for llvm::OptionalStephan Bergmann
...with recent Clang 17 trunk after <https://github.com/llvm/llvm-project/commit/125f4457a54a550846732763ee36b1447ec8d66e> "[clang] Remove clang::Optional" Change-Id: If33406604a614a65dd17e269a0a5c167ea263328 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146347 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-01-20New loplugin:unoaggregationStephan Bergmann
"Find classes that derive from css::uno::XAggregation, but which implement queryInterface in violation of the protocol laid out in the documentation at udkapi/com/sun/star/uno/XAggregation.idl (which implies that such a class either doesn't actually make use of the deprecated XAggregation mechanism, which should thus be removed from that class hierarchy, or that its implementation of queryInterface needs to be fixed)." (compilerplugins/clang/unoaggregation.cxx) The basesHaveOnlyPureQueryInterface check in compilerplugins/clang/unoaggregation.cxx is "a crude approximation (but which appears to work OK)" to filter out any queryInterface base implementations of class hierarchies supporting XAggregation (i.e., cppu::OWeakAggObject::queryInterface). It only fails for the odd ChartDocumentWrapper::queryInterface, which manually implements the XAggregation functionality rather than (indirectly) deriving from OWeakAggObject. But changing that manual implementation looks tricky, so leave that alone for now and add a loplugin warning suppression there, and leave proper clean up for later. Change-Id: Ib16e26237bd703e60b0d9cb7134cb39840842d54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145912 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-01-20improve loplugin:refcountingNoel Grandin
to catch places where we are converting a weak reference to a strong reference, and then using a pointer to store the result Change-Id: I69b132907b574e5c6974fadf18bd9658107d3a0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145877 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-13Fix typo to complete commit 613baf157375Andrea Gelmini
See https://gerrit.libreoffice.org/c/core/+/145241 Change-Id: Ic9c229fc891ce81c52c7886055a0a3474020f233 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145392 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-01-13Merge OSingleFactoryHelper into OFactoryComponentHelperStephan Bergmann
Change-Id: I7faf7a3ad54c80bd3c53525c92c26c0f980110f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145423 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-01-12merge duplicate CairoTextRender implsCaolán McNamara
drop getSurfaceOffset because both impls just set these to 0, so its a no opt Change-Id: Ie4f28d57fb8a170c7a46d3cafceef3e049c26e2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145325 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-01-12loplugin:reservedid (clang-cl)Stephan Bergmann
...after ef533553559fe09b4afab651fc692885d1acf4ed "Rudimentary support for dynamic_cast on UNO proxy objects" added those > extern "C" IMAGE_DOS_HEADER const __ImageBase; Change-Id: I4d9cf2b7617180d66a8527e0e36631f81e0fb18d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145379 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-01-06Merge comphelper::OAccessibleContextHelper into ↵Stephan Bergmann
comphelper::OCommonAccessibleComponent Change-Id: I586ae8fe2842fd879ae2ae506c659d06dda16843 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145160 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-01-06writerfilter: removed remains of GAP_HALF define and its usageVasily Melenchuk
Change-Id: I8dee16f923686f557c8213d9a7870392bd5fe9bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145090 Tested-by: Jenkins Reviewed-by: Vasily Melenchuk <vasily.melenchuk@cib.de>
2023-01-02Remove unused imports from compilerplugins/clangBogdan B
Change-Id: I923ace7bedf022d49222e71c96c7e4c20f90e6cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142521 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
2023-01-01Bump copyright year to 2023Adolfo Jayme Barrientos
Change-Id: I699112a3e554013bab75b82d1eae00098216c886 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144893 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
2022-12-22Make namespace checks look through LinkageSpecsStephan Bergmann
My clang-cl --with-visual-studio=2022preview build against VS 2022 Preview 17.5.0 Preview 2.0 had started to fail with > [build CPT] compilerplugins/clang/test/getstr.cxx > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/getstr.cxx Line 42: directly use object of type '{{(rtl::)?}}OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > File compilerplugins/clang/test/getstr.cxx Line 48: directly use object of type 'S' (aka 'rtl::OString') in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > File compilerplugins/clang/test/getstr.cxx Line 49: directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > File compilerplugins/clang/test/getstr.cxx Line 55: directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > File compilerplugins/clang/test/getstr.cxx Line 57: directly use object of type '{{(rtl::)?}}OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > 5 errors generated. apparently because C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.35.32124/include/ostream now contains [...] > _EXPORT_STD extern "C++" template <class _Elem, class _Traits> > class basic_ostream : virtual public basic_ios<_Elem, _Traits> { // control insertions into a stream buffer [...] with a wrapping extern "C++", so the call to StdNamespace() in > if (!loplugin::TypeCheck(expr->getArg(0)->getType()) > .ClassOrStruct("basic_ostream") > .StdNamespace()) //TODO: check template args in compilerplugins/clang/getstr.cxx no longer matched Change-Id: Iaeb461d5aa855a8602c5c6f791407c08a1c5d309 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144735 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-12-20Revert "fix compile error in compilerplugins"Stephan Bergmann
This reverts commit 99b5e216f107259d6e402896800282948997c4fa. It should only have been necessary after <https://github.com/llvm/llvm-project/commit/205c0589f918f95d2f2c586a01bea2716d73d603> "Revert '[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional'" dropped the #include <optional> from clang/include/clang/Lex/PPCallbacks.h, and has been obsoleted by 3d7181caf3444d086be910545047550bac618968 "Adapt to PPCallbacks::InclusionDirective change in Clang 16 trunk". Change-Id: I89238a779fdda4c3ba15de93a4e647051e5844b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144594 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-12-20Adapt to PPCallbacks::InclusionDirective change in Clang 16 trunkNoel Grandin
Attempt to follow the unfolding debate here, it was std::optional briefly, but then that was reverted with commit 205c0589f918f95d2f2c586a01bea2716d73d603 Revert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional" and then a different changed landed with commit 854c10f8d185286d941307e1033eb492e085c203 Date: Tue Dec 20 00:15:11 2022 +0100 [Clang] Prepare for llvm::Optional becoming std::optional. Change-Id: I0068960a45695014405437206d8d4565562b0af9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144575 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-20fix compile error in compilerpluginsNoel Grandin
home/noel/libo2/compilerplugins/clang/includeform.cxx:33:9: error: no template named 'optional' in namespace 'std'; did you mean 'Optional'? std::optional<FileEntryRef> File, after commit b5023fa9abea248831271df99df0810351bd8c21 Date: Mon Dec 19 13:16:29 2022 +0100 Adapt to clang::PPCallbacks::InclusionDirective change in Clang 16 trunk Change-Id: I7acbfeac4fd138a1f6ae89f8b4b8cf918da04e30 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144574 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-20new loplugin:implinheritancehelperNoel Grandin
Look for places we should be using ImplInheritanceHelper, which handles various boilerplate for us Change-Id: Icff6babf682c95b60aca86e6d6c2e2181eefc2f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144444 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-19Avoid -Werror,-Wdeprecated-declarationsStephan Bergmann
...when building against recent Clang 16 trunk, > In file included from compilerplugins/clang/sharedvisitor/sharedvisitor.cxx:30: > In file included from compilerplugins/clang/cppunitassertequals.cxx:13: > compilerplugins/clang/compat.hxx:40:14: error: 'value' is deprecated: std::optional::value is throwing. Use *X instead [-Werror,-Wdeprecated-declarations] > return o.value(); > ^~~~~ > *X > compilerplugins/clang/pointerbool.cxx:118:52: note: in instantiation of function template specialization 'compat::value<llvm::APSInt>' requested here > if (compat::has_value(ret) && (compat::value(ret) == 1 || compat::value(ret) == 0)) > ^ > ~/llvm/inst/include/llvm/ADT/Optional.h:273:3: note: 'value' has been explicitly marked deprecated here > LLVM_DEPRECATED("std::optional::value is throwing. Use *X instead", "*X") > ^ > ~/llvm/inst/include/llvm/Support/Compiler.h:143:50: note: expanded from macro 'LLVM_DEPRECATED' > #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX))) > ^ Change-Id: I4320c279a464e52ad608df2a340f62795558a7b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144472 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-12-19Adapt to clang::PPCallbacks::InclusionDirective change in Clang 16 trunkStephan Bergmann
<https://github.com/llvm/llvm-project/commit/8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d> "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional" Change-Id: I60bf4a770d6037edcfe0129591fd46941c8903db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144471 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-12-16Merge sdr::table::TableDesignUser into sdr::table::SdrTableObjImplStephan Bergmann
Change-Id: Ia7841447df4a7db1b5dd9fad93cab66fbca48981 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144316 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-12-07loplugin:unusedmethodsNoel Grandin
Change-Id: I5497d5b39620ff9fde09af923d3e41dedbab3326 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143774 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-07loplugin:unusedfieldsNoel Grandin
Change-Id: I4c9c27e5fd8193b87ac46318671f787939f2d64e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143773 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-07loplugin:singlevalfieldsNoel Grandin
Change-Id: Ic7dd2cb433add02ecc72eee0c85dd7f0efe1d47b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143771 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-06weld InformationDialog info dialogCaolán McNamara
Change-Id: I6a3631fe06a1b46164f01d706ecefd7252509382 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143740 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-12-06Resolves: tdf#121297 weld Presentation MinimizerCaolán McNamara
Change-Id: Ifdf1746bc9f6567a1aded233a4350f6828604c9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143678 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-11-29New loplugin:crosscastStephan Bergmann
...inspired by 2fa426da15a12e2a63554247e3c1c3f8c0ec5c24 "Fix dynamic_cast after splitting OutputDevice and vcl::Window class hierarchies": "Find uses of dynamic_cast that cast between unrelated classes, which is suspicious and might indicate a bug. The heuristic used to consider two classes unrelated is that neither derives from the other (directly or indirectly) and they do not both virtually derive (directly or indirectly) from a common third class. Additionally, class definitions can be attributed with SAL_LOPLUGIN_ANNOTATE("crosscast") (from sal/types.h) to suppress false warnings about known-good cases casting from or to such a class." (quoting compilerplugins/clang/crosscast.cxx) This found two additional errors, 7a82ea5c79adee70eddf74ac53347544766a91b0 "Fix presumed typo" and fc6aa9e49973c845915754caf765ff57e5b0cd59 "fix assert", and one still-open case that looks like an error, see the TODO comment in sw/source/core/unocore/unodraw.cxx. In addition to that it flagged another 102 uses of dynamic_cast as suspicious, which have all been addressed, at least for now, by marking certain classes as SAL_LOPLUGIN_ANNOTATE("crosscast"), see below. (Where this commit also adds that generic SAL_LOPLUGIN_ANNOTATE mechanism to include/sal/types.h.) However, some of those annotations might benefit from further inspection and clean up similar to recent 8858962ec09478c203d43feb58f550bb36af37bb "Introduce ParagraphProeprtiesPropertyMap", 8467aa93e2038b3030e1add94e0ca6cc4ad44032 "Replace a dynamic_cast with UNO_QUERY", a534361141d69096d896e6e0552d19f3138eeeb3 "Fold OldBasicPassword into basic::SfxScriptLibraryContainer", and 589e03fb4c3b05bf3742c0cb8b366322ffdf1fa9 "[PATCH] Replace some dynamic_cast with UNO_QUERY". * canvas/source/cairo/cairo_repainttarget.hxx RepaintTarget: > canvas/source/cairo/cairo_cachedbitmap.cxx:62:34: error: suspicious dynamic cross cast from 'com::sun::star::rendering::XCanvas *' to 'RepaintTarget *' [loplugin:crosscast] > RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get()); * canvas/source/cairo/cairo_surfaceprovider.hxx SurfaceProvider: > canvas/source/cairo/cairo_canvashelper.cxx:301:45: error: suspicious dynamic cross cast from 'com::sun::star::rendering::XBitmap *' to 'SurfaceProvider *' [loplugin:crosscast] > SurfaceProvider* pSurfaceProvider = dynamic_cast<SurfaceProvider*>( xBitmap.get() ); * canvas/source/vcl/repainttarget.hxx RepaintTarget: > canvas/source/vcl/cachedbitmap.cxx:73:34: error: suspicious dynamic cross cast from 'com::sun::star::rendering::XCanvas *' to 'RepaintTarget *' [loplugin:crosscast] > RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get()); * chart2/inc/ChartModel.hxx ChartModel: > chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx:82:31: error: suspicious dynamic cross cast from 'com::sun::star::awt::XWindow *' to 'ChartModel *' [loplugin:crosscast] > ChartModel* pChartModel = dynamic_cast<ChartModel*>(rParent.get()); * chart2/source/controller/inc/TabPageNotifiable.hxx TabPageNotifiable: > chart2/source/controller/dialogs/tp_RangeChooser.cxx:70:28: error: suspicious dynamic cross cast from 'weld::DialogController *' to 'TabPageNotifiable *' [loplugin:crosscast] > , m_pTabPageNotifiable(dynamic_cast<TabPageNotifiable*>(pController)) > chart2/source/controller/dialogs/tp_DataSource.cxx:171:28: error: suspicious dynamic cross cast from 'weld::DialogController *' to 'TabPageNotifiable *' [loplugin:crosscast] > , m_pTabPageNotifiable(dynamic_cast<TabPageNotifiable*>(pController)) * include/drawinglayer/primitive2d/svggradientprimitive2d.hxx SvgGradientHelper: > drawinglayer/source/primitive2d/svggradientprimitive2d.cxx:582:59: error: suspicious dynamic cross cast from 'const BasePrimitive2D *' to 'const SvgGradientHelper *' [loplugin:crosscast] > const SvgGradientHelper* pSvgGradientHelper = dynamic_cast< const SvgGradientHelper* >(&rPrimitive); > drawinglayer/source/primitive2d/svggradientprimitive2d.cxx:819:59: error: suspicious dynamic cross cast from 'const BasePrimitive2D *' to 'const SvgGradientHelper *' [loplugin:crosscast] > const SvgGradientHelper* pSvgGradientHelper = dynamic_cast< const SvgGradientHelper* >(&rPrimitive); * include/editeng/unotext.hxx SvxUnoTextRangeBase: > writerfilter/source/dmapper/DomainMapper_Impl.cxx:7645:62: error: suspicious dynamic cross cast from 'com::sun::star::text::XTextCursor *' to 'SvxUnoTextRangeBase *' [loplugin:crosscast] > SvxUnoTextRangeBase* pDrawText = dynamic_cast<SvxUnoTextRangeBase*>(xCrsr.get()); * include/embeddedobj/embeddedupdate.hxx EmbeddedUpdate: > svtools/source/misc/embedhlp.cxx:932:35: error: suspicious dynamic cross cast from 'com::sun::star::embed::XEmbeddedObject *' to 'embed::EmbeddedUpdate *' [loplugin:crosscast] > embed::EmbeddedUpdate* pObj = dynamic_cast<embed::EmbeddedUpdate*> (GetObject().get()); * include/oox/core/contexthandler2.hxx ContextHandler2Helper: > oox/source/core/contexthandler2.cxx:183:21: error: suspicious dynamic cross cast from 'const ContextHandler2Helper' to 'const ContextHandler &' [loplugin:crosscast] > ContextHandler( dynamic_cast< ContextHandler const & >( rParent ) ), * include/oox/mathml/export.hxx FormulaExportBase: > oox/source/export/shapes.cxx:2475:42: error: suspicious dynamic cross cast from 'com::sun::star::frame::XModel *' to 'oox::FormulaExportBase *' [loplugin:crosscast] > oox::FormulaExportBase *const pMagic(dynamic_cast<oox::FormulaExportBase*>(xMathModel.get())); * include/oox/mathml/import.hxx FormulaImportBase: > oox/source/drawingml/shape.cxx:1298:25: error: suspicious dynamic cross cast from 'com::sun::star::uno::XInterface *' to 'oox::FormulaImportBase *' [loplugin:crosscast] > dynamic_cast<oox::FormulaImportBase*>(xMathModel.get())); > writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:2287:38: error: suspicious dynamic cross cast from 'SfxBaseModel' to 'oox::FormulaImportBase &' [loplugin:crosscast] > oox::FormulaImportBase& import = dynamic_cast<oox::FormulaImportBase&>(dynamic_cast<SfxBaseModel&>(*component)); > writerfilter/source/rtftok/rtfdocumentimpl.cxx:2973:33: error: suspicious dynamic cross cast from 'SfxBaseModel' to 'oox::FormulaImportBase &' [loplugin:crosscast] > auto& rImport = dynamic_cast<oox::FormulaImportBase&>( > writerfilter/source/dmapper/DomainMapper_Impl.cxx:3000:53: error: suspicious dynamic cross cast from 'com::sun::star::uno::XInterface *' to 'oox::FormulaImportBase *' [loplugin:crosscast] > if( oox::FormulaImportBase* formulaimport = dynamic_cast< oox::FormulaImportBase* >( xInterface.get())) * include/sfx2/Metadatable.hxx Metadatable: > sw/source/core/doc/docbm.cxx:1837:17: error: suspicious dynamic cross cast from 'const IBookmark *const' to 'const ::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable const* >(pBookmark)); > sw/source/core/doc/docbm.cxx:1924:13: error: suspicious dynamic cross cast from '::sw::mark::IBookmark *const' to '::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); > sw/source/core/doc/DocumentContentOperationsManager.cxx:342:21: error: suspicious dynamic cross cast from 'const sw::mark::IMark *const' to 'const ::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable const* >(pMark)); > sw/source/core/doc/DocumentContentOperationsManager.cxx:344:21: error: suspicious dynamic cross cast from '::sw::mark::IMark *const' to '::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable * >(pNewMark)); > sw/source/core/unocore/unobkm.cxx:381:12: error: suspicious dynamic cross cast from '::sw::mark::IMark *' to '::sfx2::Metadatable *' [loplugin:crosscast] > return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark); > sw/source/core/undo/rolbck.cxx:635:13: error: suspicious dynamic cross cast from 'const ::sw::mark::IBookmark *const' to 'const ::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable const* >(pBookmark)); > sw/source/core/undo/rolbck.cxx:713:13: error: suspicious dynamic cross cast from '::sw::mark::IBookmark *const' to '::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); * include/sfx2/digitalsignatures.hxx DigitalSignatures: > sfx2/source/doc/docfile.cxx:3999:25: error: suspicious dynamic cross cast from 'com::sun::star::security::XDocumentDigitalSignatures *' to 'sfx2::DigitalSignatures *' [loplugin:crosscast] > auto xModelSigner = dynamic_cast<sfx2::DigitalSignatures*>(xSigner.get()); * include/sfx2/sidebar/IContextChangeReceiver.hxx IContextChangeReceiver: > sfx2/source/sidebar/SidebarPanelBase.cxx:105:11: error: suspicious dynamic cross cast from 'pointer' (aka 'PanelLayout *') to 'IContextChangeReceiver *' [loplugin:crosscast] > = dynamic_cast<IContextChangeReceiver*>(mxControl.get()); * include/sfx2/sidebar/ILayoutableWindow.hxx ILayoutableWindow: > sfx2/source/sidebar/SidebarPanelBase.cxx:164:44: error: suspicious dynamic cross cast from 'pointer' (aka 'PanelLayout *') to 'ILayoutableWindow *' [loplugin:crosscast] > ILayoutableWindow* pLayoutableWindow = dynamic_cast<ILayoutableWindow*>(mxControl.get()); * include/sfx2/sidebar/SidebarModelUpdate.hxx SidebarModelUpdate: > sfx2/source/sidebar/SidebarPanelBase.cxx:189:40: error: suspicious dynamic cross cast from 'pointer' (aka 'PanelLayout *') to 'SidebarModelUpdate *' [loplugin:crosscast] > SidebarModelUpdate* pModelUpdate = dynamic_cast<SidebarModelUpdate*>(mxControl.get()); * include/sfx2/xmldump.hxx XmlDump: > svtools/source/misc/embedhlp.cxx:290:27: error: suspicious dynamic cross cast from 'com::sun::star::util::XCloseable *' to 'sfx2::XmlDump *' [loplugin:crosscast] > auto pComponent = dynamic_cast<sfx2::XmlDump*>(mxObj->getComponent().get()); * include/svl/stylesheetuser.hxx StyleSheetUser: > sd/source/core/stlsheet.cxx:294:48: error: suspicious dynamic cross cast from 'SfxListener *' to 'svl::StyleSheetUser *' [loplugin:crosscast] > const svl::StyleSheetUser* const pUser(dynamic_cast<svl::StyleSheetUser*>(pListener)); * include/svl/undo.hxx SfxRepeatTarget: > starmath/source/action.cxx:45:5: error: suspicious dynamic cross cast from 'SfxRepeatTarget' to 'SmDocShell &' [loplugin:crosscast] > dynamic_cast< SmDocShell & >(rDocSh).SetFormat(aNewFormat); * include/svx/ipolypolygoneditorcontroller.hxx IPolyPolygonEditorController: > sd/source/ui/view/drbezob.cxx:127:22: error: suspicious dynamic cross cast from 'sd::SmartTag *' to 'IPolyPolygonEditorController *' [loplugin:crosscast] > pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() ); > sd/source/ui/view/drbezob.cxx:216:26: error: suspicious dynamic cross cast from 'sd::SmartTag *' to 'IPolyPolygonEditorController *' [loplugin:crosscast] > pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() ); * include/vcl/IContext.hxx IContext: > vcl/source/window/builder.cxx:3650:54: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IContext *' [loplugin:crosscast] > vcl::IContext* pContextControl = dynamic_cast<vcl::IContext*>(pCurrentChild.get()); * include/vcl/ITiledRenderable.hxx ITiledRenderable: > In file included from test/source/a11y/swaccessibletestbase.cxx:10: > In file included from include/test/a11y/swaccessibletestbase.hxx:22: > include/test/a11y/accessibletestbase.hxx:54:15: error: suspicious dynamic cross cast from 'com::sun::star::lang::XComponent *' to 'vcl::ITiledRenderable *' [loplugin:crosscast] > = dynamic_cast<vcl::ITiledRenderable*>(mxDocument.get()); * include/vcl/NotebookbarContextControl.hxx NotebookbarContextControl: > vcl/source/control/notebookbar.cxx:113:33: error: suspicious dynamic cross cast from 'vcl::Window *' to 'NotebookbarContextControl *' [loplugin:crosscast] > pContextContainer = dynamic_cast<NotebookbarContextControl*>(m_pUIBuilder->get<Window>(OUStringToOString(aName, RTL_TEXTENCODING_UTF8))); * include/vcl/gdimetafiletools.hxx MetafileAccessor: > vcl/source/gdi/impgraph.cxx:716:61: error: suspicious dynamic cross cast from 'drawinglayer::primitive2d::BasePrimitive2D *' to 'const MetafileAccessor *' [loplugin:crosscast] > const MetafileAccessor* pMetafileAccessor = dynamic_cast< const MetafileAccessor* >(pUnoPrimitive->getBasePrimitive2D().get()); * include/vcl/syswin.hxx VclBuilderContainer: > vcl/source/app/salvtables.cxx:7465:11: error: suspicious dynamic cross cast from 'vcl::Window *' to 'VclBuilderContainer *' [loplugin:crosscast] > = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get())) * include/vcl/toolkit/field.hxx NumericFormatter: > vcl/source/window/builder.cxx:583:37: error: suspicious dynamic cross cast from 'vcl::Window *' to 'NumericFormatter *' [loplugin:crosscast] > NumericFormatter *pTarget = dynamic_cast<NumericFormatter*>(get(elem.m_sID)); * include/vcl/transfer.hxx DragSourceHelper: > svx/source/sdr/contact/sdrmediawindow.cxx:163:47: error: suspicious dynamic cross cast from 'vcl::Window *' to 'DragSourceHelper *' [loplugin:crosscast] > DragSourceHelper* pDragSourceHelper = dynamic_cast< DragSourceHelper* >( pWindow ); * include/vcl/transfer.hxx DropTargetHelper: > svx/source/sdr/contact/sdrmediawindow.cxx:126:47: error: suspicious dynamic cross cast from 'vcl::Window *' to 'DropTargetHelper *' [loplugin:crosscast] > DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow ); > svx/source/sdr/contact/sdrmediawindow.cxx:145:47: error: suspicious dynamic cross cast from 'vcl::Window *' to 'DropTargetHelper *' [loplugin:crosscast] > DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow ); * include/vcl/wizardmachine.hxx IWizardPageController: > vcl/source/control/wizardmachine.cxx:1274:46: error: suspicious dynamic cross cast from 'BuilderPage *' to 'IWizardPageController *' [loplugin:crosscast] > IWizardPageController* pController = dynamic_cast<IWizardPageController*>(pCurrentPage); * include/xmloff/settingsstore.hxx DocumentSettingsSerializer: > xmloff/source/draw/sdxmlimp.cxx:540:15: error: suspicious dynamic cross cast from 'com::sun::star::beans::XPropertySet *' to 'DocumentSettingsSerializer *' [loplugin:crosscast] > pFilter = dynamic_cast<DocumentSettingsSerializer *>(xProps.get()); > xmloff/source/draw/sdxmlexp.cxx:2474:41: error: suspicious dynamic cross cast from 'com::sun::star::beans::XPropertySet *' to 'DocumentSettingsSerializer *' [loplugin:crosscast] > DocumentSettingsSerializer *pFilter(dynamic_cast<DocumentSettingsSerializer *>(xProps.get())); * include/xmloff/xmlimp.hxx SvXMLImport: > sdext/source/pdfimport/sax/emitcontext.cxx:45:37: error: suspicious dynamic cross cast from 'com::sun::star::xml::sax::XDocumentHandler *' to 'SvXMLImport *' [loplugin:crosscast] > if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport*>(m_xDocHdl.get())) > writerperfect/source/common/DocumentHandler.cxx:118:37: error: suspicious dynamic cross cast from 'com::sun::star::xml::sax::XDocumentHandler *' to 'SvXMLImport *' [loplugin:crosscast] > if (SvXMLImport* pFastHandler = dynamic_cast<SvXMLImport*>(mxHandler.get())) * reportdesign/inc/RptObject.hxx OObjectBase: > reportdesign/source/ui/report/ViewsWindow.cxx:843:53: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObjBase = dynamic_cast<OObjectBase*>(pObj); > reportdesign/source/core/sdr/ReportUndoFactory.cxx:30:25: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(&rObject); > reportdesign/source/core/sdr/RptPage.cxx:62:29: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(GetObj(i)); > reportdesign/source/core/sdr/RptPage.cxx:77:30: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pBase = dynamic_cast<OObjectBase*>(GetObj(nPos)); > reportdesign/source/core/sdr/RptPage.cxx:116:28: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObject = dynamic_cast< OObjectBase* >(SdrObject::getSdrObjectFromXShape( _xObject )); > reportdesign/source/core/sdr/RptPage.cxx:184:32: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObjectBase = dynamic_cast< OObjectBase* >( pObj ); > reportdesign/source/core/sdr/ReportDrawPage.cxx:60:29: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj); > reportdesign/source/ui/report/dlgedfunc.cxx:455:25: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(_pOverlappedObj); > reportdesign/source/ui/report/SectionView.cxx:177:37: error: suspicious dynamic cross cast from 'SdrObject' to 'OObjectBase &' [loplugin:crosscast] > OObjectBase& rBaseObj = dynamic_cast<OObjectBase&>(*pObj); > reportdesign/source/ui/report/ReportSection.cxx:338:29: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(pSdrObject); > reportdesign/source/ui/report/ReportSection.cxx:513:38: error: suspicious dynamic cross cast from 'SdrObject' to 'OObjectBase &' [loplugin:crosscast] > OObjectBase& rBase = dynamic_cast<OObjectBase&>(*pObject); > reportdesign/source/ui/report/ReportSection.cxx:644:33: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(pDlgEdObj); > reportdesign/source/ui/report/ReportSection.cxx:663:35: error: suspicious dynamic cross cast from 'const SdrObject *' to 'const OObjectBase *' [loplugin:crosscast] > const OObjectBase* pObj = dynamic_cast<const OObjectBase*>(pDlgEdObj); > reportdesign/source/ui/report/propbrw.cxx:286:33: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(pCurrent); > reportdesign/source/ui/report/ViewsWindow.cxx:843:53: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObjBase = dynamic_cast<OObjectBase*>(pObj); * sc/source/ui/inc/IAnyRefDialog.hxx IAnyRefDialog: > sc/source/ui/app/scmod.cxx:1607:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1646:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1697:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1766:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1813:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1853:38: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/view/tabview3.cxx:470:30: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(xDlgController.get()); > sc/source/ui/view/tabview3.cxx:2053:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/view/tabvwsh4.cxx:210:46: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pController.get()); * sd/source/filter/eppt/epptbase.hxx PPTExBulletProvider: > sd/source/filter/eppt/pptx-epptbase.cxx:497:74: error: suspicious dynamic cross cast from 'PPTWriterBase *' to 'PPTExBulletProvider *' [loplugin:crosscast] > maStyleSheetList.emplace_back( new PPTExStyleSheet( nDefaultTab, dynamic_cast<PPTExBulletProvider*>(this) ) ); * sdext/source/presenter/PresenterViewFactory.hxx CachablePresenterView: > sdext/source/presenter/PresenterViewFactory.cxx:218:36: error: suspicious dynamic cross cast from 'com::sun::star::drawing::framework::XResource *' to 'CachablePresenterView *' [loplugin:crosscast] > CachablePresenterView* pView = dynamic_cast<CachablePresenterView*>(rxView.get()); > sdext/source/presenter/PresenterViewFactory.cxx:274:23: error: suspicious dynamic cross cast from 'com::sun::star::drawing::framework::XView *' to 'CachablePresenterView *' [loplugin:crosscast] > = dynamic_cast<CachablePresenterView*>(iView->second.first.get()); > sdext/source/presenter/PresenterViewFactory.cxx:325:40: error: suspicious dynamic cross cast from 'com::sun::star::drawing::framework::XView *' to 'CachablePresenterView *' [loplugin:crosscast] > CachablePresenterView* pView = dynamic_cast<CachablePresenterView*>(xView.get()); * slideshow/source/inc/cursormanager.hxx CursorManager: > slideshow/source/engine/slide/userpaintoverlay.cxx:449:49: error: suspicious dynamic cross cast from 'CursorManager' to 'Slide &' [loplugin:crosscast] > dynamic_cast<Slide&>(rContext.mrCursorManager), * svx/source/inc/celltypes.hxx TableDesignUser: > svx/source/table/tabledesign.cxx:267:38: error: suspicious dynamic cross cast from 'com::sun::star::util::XModifyListener *' to 'TableDesignUser *' [loplugin:crosscast] > TableDesignUser* pUser = dynamic_cast< TableDesignUser* >( it.next().get() ); * svx/source/inc/tablemodel.hxx ICellRange: > svx/source/table/tablemodel.cxx:285:26: error: suspicious dynamic cross cast from 'com::sun::star::table::XCellRange *' to 'ICellRange *' [loplugin:crosscast] > ICellRange* pRange = dynamic_cast< ICellRange* >( rRange.get() ); * sw/inc/IDocumentUndoRedo.hxx IDocumentUndoRedo: > sw/source/uibase/shells/drwtxtsh.cxx:585:38: error: suspicious dynamic cross cast from 'SfxUndoManager *' to 'IDocumentUndoRedo *' [loplugin:crosscast] > auto* pUndoManager = dynamic_cast<IDocumentUndoRedo*>(GetUndoManager()); * sw/inc/IMark.hxx IFieldmark: > sw/source/core/doc/docbm.cxx:1415:15: error: suspicious dynamic cross cast from 'sw::mark::MarkBase *const' to 'IFieldmark *' [loplugin:crosscast] > : dynamic_cast<IFieldmark*>(*pFieldmark); > sw/source/core/doc/docbm.cxx:1437:16: error: suspicious dynamic cross cast from 'sw::mark::MarkBase *' to 'IFieldmark *' [loplugin:crosscast] > return dynamic_cast<IFieldmark*>(pFieldmark); > sw/source/core/doc/docbm.cxx:1570:37: error: suspicious dynamic cross cast from 'sw::mark::MarkBase *' to 'IFieldmark *' [loplugin:crosscast] > IFieldmark *pMark = dynamic_cast<IFieldmark*>(*aIter); * sw/inc/calbck.hxx BroadcastingModify: > sw/source/core/attr/swatrset.cxx:228:29: error: suspicious dynamic cross cast from 'const sw::BroadcastingModify *' to 'const sw::FormatDropDefiner *' [loplugin:crosscast] > auto pDropDefiner = dynamic_cast<const sw::FormatDropDefiner*>(pModify); > sw/source/core/txtnode/OnlineAccessibilityCheck.cxx:38:28: error: suspicious dynamic cross cast from 'SwNode *' to 'sw::BroadcastingModify *' [loplugin:crosscast] > auto* pBroadcast = dynamic_cast<sw::BroadcastingModify*>(m_pNode); * sw/inc/contentindex.hxx SwContentIndexReg: > sw/source/core/doc/DocumentRedlineManager.cxx:56:20: error: suspicious dynamic cross cast from 'SwNode *' to 'SwContentIndexReg *' [loplugin:crosscast] > assert(dynamic_cast<SwContentIndexReg*>(&pPos->GetNode()) * sw/source/core/inc/flowfrm.hxx SwFlowFrame: > sw/source/core/layout/frmtool.cxx:3044:35: error: suspicious dynamic cross cast from 'SwFrame *' to 'SwFlowFrame *' [loplugin:crosscast] > SwFlowFrame *pFlowFrame = dynamic_cast<SwFlowFrame*>(pSibling); * sw/source/uibase/inc/FrameControl.hxx ISwFrameControl: > sw/source/uibase/docvw/FrameControlsManager.cxx:283:15: error: suspicious dynamic cross cast from 'vcl::Window *' to 'ISwFrameControl *' [loplugin:crosscast] > mpIFace = dynamic_cast<ISwFrameControl *>( pWindow.get() ); * vcl/inc/IPrioritable.hxx IPrioritable: > vcl/source/control/NotebookbarPopup.cxx:40:37: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > vcl::IPrioritable* pChild = dynamic_cast<vcl::IPrioritable*>(GetChild(0)); > vcl/source/control/PriorityHBox.cxx:89:43: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pChild); > vcl/source/control/PriorityHBox.cxx:127:32: error: suspicious dynamic cross cast from 'vcl::IPrioritable *' to 'vcl::Window *' [loplugin:crosscast] > vcl::Window* pWindow = dynamic_cast<vcl::Window*>(pPrioritable); > vcl/source/control/PriorityHBox.cxx:142:32: error: suspicious dynamic cross cast from 'vcl::IPrioritable *' to 'vcl::Window *' [loplugin:crosscast] > vcl::Window* pWindow = dynamic_cast<vcl::Window*>(*pChildR); > vcl/source/control/PriorityHBox.cxx:186:43: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pChild); > vcl/source/window/NotebookBarAddonsMerger.cxx:128:19: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > = dynamic_cast<vcl::IPrioritable*>(pOptionalParent.get()); > ovcl/source/window/builder.cxx:3643:55: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pCurrentChild.get()); * vcl/inc/jsdialog/jsdialogbuilder.hxx BaseJSWidget: > vcl/jsdialog/executor.cxx:41:26: error: suspicious dynamic cross cast from 'weld::Widget *' to 'BaseJSWidget *' [loplugin:crosscast] > if (auto pJSWidget = dynamic_cast<BaseJSWidget*>(pWidget)) > vcl/jsdialog/executor.cxx:49:26: error: suspicious dynamic cross cast from 'weld::Widget *' to 'BaseJSWidget *' [loplugin:crosscast] > if (auto pJSWidget = dynamic_cast<BaseJSWidget*>(pWidget)) > vcl/jsdialog/executor.cxx:155:49: error: suspicious dynamic cross cast from 'weld::MenuButton *' to 'BaseJSWidget *' [loplugin:crosscast] > BaseJSWidget* pMenuButton = dynamic_cast<BaseJSWidget*>(pButton); * vcl/inc/unx/x11/x11gdiimpl.h X11GraphicsImpl: > vcl/unx/generic/gdi/salgdi.cxx:387:36: error: suspicious dynamic cross cast from 'pointer' (aka 'SalGraphicsImpl *') to 'X11GraphicsImpl *' [loplugin:crosscast] > if( X11GraphicsImpl* x11Impl = dynamic_cast< X11GraphicsImpl* >( mxImpl.get())) * xmlsecurity/inc/certificate.hxx Certificate: > xmlsecurity/source/helper/documentsignaturemanager.cxx:334:33: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > if (auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCert.get())) > xmlsecurity/source/helper/documentsignaturemanager.cxx:381:33: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > if (auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCert.get())) > xmlsecurity/source/component/documentdigitalsignatures.cxx:688:28: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > auto pAuthor = dynamic_cast<xmlsecurity::Certificate*>(xAuthor.get()); > xmlsecurity/source/component/documentdigitalsignatures.cxx:689:26: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > auto pCert = dynamic_cast<xmlsecurity::Certificate*>(xCert.get()); > xmlsecurity/qa/unit/signing/signing.cxx:130:29: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCertificate.get()); Change-Id: If4f9efd8c012d0f650fe670450cf7ac0c8978036 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143458 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-25Fold OldBasicPassword into basic::SfxScriptLibraryContainerStephan Bergmann
Change-Id: Iaeaf30f63760185a2b1dd72feb980b94d9931d55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143253 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-23Fix loplugin:redundantcast check for same-type dynamic_castStephan Bergmann
...when the target type is a reference type and the source and target type have different cv qualifiers. (And fix the fallout. And make the tests cover that somewhat more exhaustively; and while at it also test that the plugin can cope with dynamic_cast to void pointers, which is the only legitimate case where a dynamic_cast can involve types that are not (pointers or references to) non-class types.) Change-Id: Ia568ddb5dbc4a84c275db172791c345d95964857 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143133 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-22loplugin:unusedfields update the post-process scriptNoel Grandin
(*) ignore temporary fields in lambdas (*) don't ignore the vcl/weld stuff anymore Change-Id: I4cda18f779588409891a2b2f8b1371e60f9b9ac0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143090 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-11-18Related tdf#104597, tdf#151546: Introduce comphelper::string::reverseCodePointsStephan Bergmann
69e9925ded584113e52f84ef0ed7c224079fa061 "sdext.pdfimport: resolves tdf#104597: RTL script text runs are reversed" and f6004e1c457ddab5e0c91e6159875d25130b108a "tdf#151546: RTL text is reversed (Writer pdfimport)" had introduced two calls to comphelper::string::reverseString into sdext. That function reverts on the basis of individual UTF-16 code units, not on the basis of Unicode code points. And while at least some pre-existing callers of that function want the former semantics (see below), these two new callers in sdext apparently want the latter semantics. Therefore, introduce an additional function comphelper::string::reverseCodePoints with the latter semantics. I identified three other places that call comphelper::string::reverseString: * SbRtl_StrReverse in basic/source/runtime/methods1.cxx apparently implements some StrReverse Basic function, where a (presumably non-existing) Basic spec would need to decide which of the two semantics is called for. So leave it alone for now. * SvtFileDialog::IsolateFilterFromPath_Impl in fpicker/source/office/iodlg.cxx reverts a string, operates on it, then reverts (parts of) it back. Whether or not that is the most elegant code, using the latter semantics here would apparently be wrong, as double invocation of comphelper::string::reverseCodePoints is not idempotent when the input is a malformed sequence of UTF-16 code units containing a low surrogate followed by a high surrogate. * AccessibleCell::getCellName in svx/source/table/accessiblecell.cxx apparently always operates on a string consisting only of Latin uppercase letters A--Z, for which both semantics are equivalent. (So we can just as well stick with the simpler comphelper::string::reverseString here.) (Extending the tests in comphelper/qa/string/test_string.cxx ran into an issue where loplugin:stringliteralvar warns about deliberate uses of sal_Unicode arrays rather than UTF-16 string literals wrapped in OUStringLiteral, as those arrays deliberately contain malformed UTF-16 code unit sequences and thus converting them into UTF-16 string literals might be considered inappropriate, see the newly added comment at StringLiteralVar::isPotentiallyInitializedWithMalformedUtf16 in compilerplugins/clang/stringliteralvar.cxx for details. So that loplugin had to be improved here, too.) Change-Id: I641cc32c76b0c5f6339ae44d8aa85df0022ffb05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142949 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-11New loplugin:constmoveStephan Bergmann
"Find occurrences of std::move on const-qualified types. While there might theoretically be legitimate uses for such (for which this plugin would generate false positives and would need to be updated), in practice they tend to point at suspicious code that should be cleaned up in some way." (All issues found for a Linux build have already been addressed with eleven recent commits mentioning in their commit messages: "I came across this code with an upcoming loplugin:constmove that flags suspicious uses of std::move involving const-qualified types.") Change-Id: I891a66eb0ec5f9b7d93536bbccea0359893383df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142589 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-06-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): compilerpluginsStephan Bergmann
Change-Id: I9a4d20cd42d6c836aa74837688a272f849d9d373 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142322 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>