Commit Graph
234 Commits
Author SHA1 Message Date
Noel Grandin 12008e1054 loplugin:ostr in xmloff
Change-Id: I24f5626e57e03217e4bcf77289c785e255b9f904
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167667
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-05-15 20:37:38 +02:00
Noel Grandin e8d1eec3e5 use more OUString literals in XMLEvent
Change-Id: I77f9b7fc731be3c3f7cd0c642f9b210e28fdf545
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166974
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-05-02 02:45:34 +02:00
Arnaud VERSINI f16d04c95f xmloff : no need to use OUString literal for comparison
Change-Id: I2b8f75ec56d93003d8c9c14b3cad1e3978cc6a39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165227
Tested-by: Jenkins
Reviewed-by: Arnaud Versini <arnaud.versini@pm.me>
2024-03-25 17:30:27 +01:00
RMZeroFour e7eae3aa6e tdf#158067 Replace OUStringLiteral with _ustr
As part of the efforts in #158067 to replace static constexpr
OUStringLiteral variables with string literals of the form
u""_ustr, this commit performs the replacements in some files
of the xmloff module.

Change-Id: Icce2ed7f9a69ef023aaff498975d6afabf161d4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165200
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-23 20:49:49 +01:00
Gabor Kelemen 4496544f5d Remove unused namespaces from xmloff
Change-Id: Id46c9512b8024c9dc50edfb200599b1901fbf3c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164940
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2024-03-19 09:28:41 +01:00
Gabor Kelemen 7da8fce0cd tdf#146619 Recheck xmloff/*cxx with IWYU
Change-Id: I6e39a223fd567d70254998e55de5110db87ab4fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164486
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2024-03-12 10:37:31 +01:00
Gabor Kelemen f351faa3f7 tdf#146619 Recheck xmloff/*hxx with IWYU
Change-Id: I09676a038370ca76ad4d4ef54dae14fbd3bd287f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162319
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2024-01-22 08:41:30 +01:00
Stephan Bergmann fe7f4eab95 Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: xmloff
Change-Id: I2d58bbea770c4dd188cae13e11218a29f4cd5d05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158294
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-20 22:46:53 +02:00
Miklos Vajna 385d3323ce sw: prefix members of XMLEventsImportContext, XMLFontStylesContext, ...
... XMLMarkerStyleExport and XMLMarkerStyleImport

See tdf#94879 for motivation.

Change-Id: Ief48236f16c5525c6bd49d78e6ba4f9643ef1214
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152376
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2023-05-30 09:19:09 +02:00
Miklos Vajna d75f4673ac sw: prefix members of SvXMLAttrContainerData, XMLDashStyleExport, ...
... XMLDashStyleImport and XMLEventExport

See tdf#94879 for motivation.

Change-Id: I203cc1c789a1a33721b27754412da35c3ca8a56a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151755
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2023-05-15 11:17:39 +02:00
Gabor Kelemen 36db242816 Run clang-tidy with misc-unused-using-decls on module xmloff
To remove unneeded using declarations.

Via the simple script:

for i in $(find $dirname -name "*cxx" -o -name "*hxx" ); do
    clang-tidy-12  --checks="-*,misc-unused-using-decls" "$i";
done

Change-Id: Iccae38de41c809b39345ec6b31c9f6346e620f53
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150611
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <kelemeng@ubuntu.com>
2023-04-21 22:22:33 +02:00
Caolán McNamara 8a33bde528 tdf#152266 only warn about script:event-listener with non-empty targets
Change-Id: I19518c4872b522686b3df1881ccee02d840c3db4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143829
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-12-08 19:45:00 +00:00
Stephan Bergmann 91ba9654ba Move tools/diagnose_ex.h to comphelper/diagnose_ex.hxx
...so that its TOOLS_WARN_EXCEPTION can be used in
comphelper/source/misc/logging.cxx in a follow-up commit.  (And while at it,
rename from diangose_ex.h to the more appropriate diagnose_ex.hxx.  The
comphelper module is sufficiently low-level for this immediate use case, so use
that at least for now; o3tl might be even more suitable but doesn't have a
Library until now.  Also, for the immediate use case it would have sufficed to
only break DbgGetCaughtException, exceptionToString, TOOLS_WARN_EXCEPTION,
TOOLS_WARN_EXCEPTION_IF, and TOOLS_INFO_EXCEPTION out of
include/tools/diagnose_ex.h into an additional new
include/comphelper/diagnose_ex.hxx, but its probably easier overall to just move
the complete include file as is.)

Change-Id: I9f3222d4ccf1a9ac29d7eb9ba1530d53e2affaee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138451
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-08-18 17:10:19 +02:00
Noel Grandin ca2a4a4b1c clang-tidy modernize-pass-by-value in xmloff
Change-Id: Ica07e393763343d0f5caaad6a89fa3378f6ad344
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136995
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-12 15:59:38 +02:00
Noel Grandin cbaf1fbaa6 loplugin:stringview more o3tl conversion
look for call sequences that can use string_view and the new o3tl
functions in o3tl/string_view.hxx

Also add a few more wrappers to said #include file

Change-Id: I05d8752cc67a7b55b0b57e8eed803bd06bfcd9ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132840
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-12 12:42:15 +02:00
Noel Grandin 6299c8cae9 loplugin:constparams
Change-Id: Iebeb531fad5cc819b536788925cf8508737198b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124599
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-11-03 07:54:12 +01:00
Mike Kaganski 8cb57be792 Prepare for removal of non-const operator[] from Sequence in xmloff
Change-Id: I7ea7964f76f0a5db678510ac3533003726dc49fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124416
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-11-01 07:11:36 +01:00
Julien Nabet b7e7fee238 Leftover from 4477baeba5
... Simplify Sequences in xmloff (+ merge 2 SetError)

Thank you Mike for having spotted it! :-)

Change-Id: I532520aff6999a30a8b41dc95ff5eeb1086a21c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123791
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-10-19 09:27:11 +02:00
Julien Nabet 4477baeba5 Simplify Sequences in xmloff (+ merge 2 SetError)
Change-Id: If4055bbeb858b1b87ecb3f8c0b87da4b008e3c16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123716
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-10-17 12:51:09 +02:00
Mike Kaganski 8a017d25a6 Avoid COW overhead using css::uno::Sequence
The scenarios are:

1. Calling sequence's begin() and end() in pairs to pass to algorithms
   (both calls use getArray(), which does the COW checks)
2. In addition to #1, calling end() again when checking result of find
   algorithms, and/or begin() to calculate result's distance
3. Using non-const sequences in range-based for loops, which internally
   do #1
4. Assigning sequence to another sequence variable, and then modifying
   one of them

In many cases, the sequences could be made const, or treated as const
for the purposes of the algorithms (using std::as_const, std::cbegin,
and std::cend). Where algorithm modifies the sequence, it was changed
to only call getArray() once. For that, css::uno::toNonConstRange was
introduced, which returns a struct (sublclass of std::pair) with two
iterators [begin, end], that are calculated using one call to begin()
and one call to getLength().

To handle #4, css::uno::Sequence::swap was introduced, that swaps the
internal pointer to uno_Sequence. So when a local Sequence variable
should be assigned to another variable, and the latter will be modified
further, it's now possible to use swap instead, so the two sequences
are kept independent.

The modified places were found by temporarily removing non-const end().

Change-Id: I8fe2787f200eecb70744e8b77fbdf7a49653f628
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123542
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-14 06:00:49 +02:00
Noel Grandin 6cc1ee9035 clang-tidy:readability-redundant-member-init
Change-Id: Iede70151af052505b780c6ce708aa74d97da5c75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121545
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-09-03 12:44:22 +02:00
Julien Nabet 57796f2724 Simplify Sequences initializations (writerfilter/writerperfect/x*)
Change-Id: I1bd31fe6cf0f8aaf4f2cfe1d3d49e61a0633f361
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117057
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-06-11 16:03:10 +02:00
Gabor Kelemen 2633d5f97f Recheck include/ with IWYU
See tdf#42949 for motivation

Change-Id: Ifc253bf800bb1468b5774663a93f4fb30bec81d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113657
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2021-04-09 11:56:36 +02:00
Noel 7943752b9e loplugin:referencecasting in xmloff
Change-Id: Ib601b7045d773ab612569a8fd00d76545dea13af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111055
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-02-17 13:15:11 +01:00
Noel Grandin d0a60f7785 fastparser in XMLEventsImportContext
Change-Id: Ifeeb2220ec6dfe6ec91f238137796d7d9e517465
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106261
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-11-21 07:06:11 +01:00
Philipp Hofer c927d6daa9 tdf#123936 Formatting files in module xmloff with clang-format
Change-Id: I4d9016a0e646da5d9f0044762f6ecce86ce1242b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105732
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2020-11-19 19:25:20 +01:00
Noel 8c5ffecf1d make SvXMLImport capable of mixing fast- and slow- contexts adhoc
so I can convert even *ImportContext subclasses in the middle of
a context stack, and thus break the cyclic dependency nature
of the writer import.

and adjust the xmlimport loplugin for the new rules.

As a consequence of the loplugin:xmlimport's checking, we remove
a bunch of now unnecessary overrides of startFastElement.

Change-Id: I97464522ede8ec5e345e928cdafa4b18364b1b80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104730
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-11-02 08:17:00 +01:00
Caolán McNamara de74d98c58 OUStringLiteral/OStringLiteral coverity PARSE_ERROR workaround
do more like

commit 121771e37f
Date:   Mon Sep 21 09:17:54 2020 +0200

    Make some OUStringLiteral vars constexpr

cause coverity can live with that

Change-Id: I9efd7f848289c4865997a44c6780373068422227
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103147
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2020-09-22 12:58:14 +02:00
Stephan Bergmann 33ecd0d5c4 Change OUStringLiteral from char[] to char16_t[]
This is a prerequisite for making conversion from OUStringLiteral to OUString
more efficient at least for C++20 (by replacing its internals with a constexpr-
generated sal_uString-compatible layout with a SAL_STRING_STATIC_FLAG refCount,
conditionally for C++20 for now).

For a configure-wise bare-bones build on Linux, size reported by `du -bs
instdir` grew by 118792 bytes from 1155636636 to 1155755428.

In most places just a u"..." string literal prefix had to be added.  In some
places

  char const a[] = "...";

variables have been changed to char16_t, and a few places required even further
changes to code (which prompted the addition of include/o3tl/string_view.hxx
helper function o3tl::equalsIgnoreAsciiCase and the additional
OUString::createFromAscii overload).

For all uses of macros expanding to string literals, the relevant uses have been
rewritten as

  u"" MACRO

instead of changing the macro definitions.  It should be possible to change at
least some of those macro definitions (and drop the u"" from their call sites)
in follow-up commits.

Change-Id: Iec4ef1a057d412d22443312d40c6a8a290dc6144
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101483
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-08-28 08:07:09 +02:00
Noel Grandin bd2d082a0c fix bug in XMLEventsImportContext
ever since
    commit 10e08b1d39
	Date:   Fri Feb 14 13:27:23 2020 +0200
    convert XMLEventsImportContext to fastparser

Change-Id: I3bdc514f25a38f598d2a764c536b46f6ded9d14c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101473
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-08-27 15:59:55 +02:00
Noel Grandin 6b3089df68 rename xmlnmspe -> xmlnamespace
Change-Id: I8fdf9833dede6f4c9ba4bbb76b9ab9b6b419f155
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100722
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-08-14 13:59:05 +02:00
Noel Grandin 7c67a8f4e8 rename nmspmap.hxx -> namespacemap.hxx
we're not in DOS anymore, Dorothy

Change-Id: I79926e0d694163940ba7ebf20419724dd0a486f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100721
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-08-14 11:07:08 +02:00
Noel Grandin c525288fee loplugin:flatten in xmloff
Change-Id: Id35bf564b3fa2c9094f10b0d2030dae853fcd673
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100200
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-08-06 10:15:18 +02:00
Stephan Bergmann 9d6a532e49 Upcoming improved loplugin:staticanonymous -> redundantstatic: xmloff
Change-Id: I47bd2f4b6bbe47b8a6c0aa8102186bf25a3804f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97772
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-07-02 18:45:39 +02:00
Noel Grandin 3e9bef4b6e simplify handling of comparing XML_NAMESPACE values
Change-Id: I18bbf1ee206285842250891ce556d523489855b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93075
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-04-29 19:35:52 +02:00
Noel Grandin 1705fbe9da move the castToFastAttributeList function
to the slightly higher namespace, to make it easy and more readable to
use directly in a for-loop-range expression.

And make it return a reference rather than a pointer, since it is never
allowed to be nullptr.

Change-Id: I15d0b32493ef65cfc601b247c272b318f1eadfd8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93049
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-04-28 13:25:27 +02:00
Gabor Kelemen d3e1ada454 Remove unused using declarations in oox...xmlsecurity
Found by:
run-clang-tidy-10 -checks=-*,misc-unused-using-decls

Change-Id: I3e95791e223ef01e140a6217e29a9efae428a784
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90876
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-03-25 09:13:27 +01:00
Noel Grandin 729927f760 Revert "loplugin:constfields in xmloff"
This reverts commit 0302c9b192.

Change-Id: Ib919429e22ad039d6a82fe081f4e5421fe08905d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90549
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-03-16 10:55:27 +01:00
Noel Grandin ae854970bf use more FastParser in ScXMLContentValidationContext
Change-Id: I958d2ad1a8dc6c2a3da1c1a4fc6bd4f0011367fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90055
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-03-06 08:09:04 +01:00
Noel Grandin b623684c66 loplugin:constantparam
Change-Id: I62a0b760e49e38a4565eebf272492159047dda5b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89613
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-02-27 10:55:18 +01:00
Noel Grandin 4e97fa0f4e use fast-parser APIs for embedded script parsing
essentially, this duplicates and converts the service in
    xmlscript/source/xmlflat_impexp/
and then converts it to use SvXMLImport APIs, stripping about 3 layers
of unnecessary indirection in the process.

Also improve some exception throwing in sax/ to make the next
programmers life easier when finding the source of exceptions.

Change-Id: I1ac552ee0565349e8322a55f6f609cf9f4521cab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89084
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-02-20 13:37:48 +01:00
Noel Grandin 10e08b1d39 convert XMLEventsImportContext to fastparser
for now, it supports both fast and non-fast methods, since it is
constructed by both contexts

Change-Id: I925c50be161b95ecebd951cb7038a938c848a15d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88715
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-02-14 17:53:22 +01:00
Noel Grandin 5a73d3908c use FastParser in XMLScriptContext
Change-Id: I7c5f5b77a78307c556ee5718480346ed3dd159fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87075
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-01-21 08:21:29 +01:00
Noel Grandin f3797630be return nullptr from CreateChildContext methods in subclasses
the calling class handles this nicely, and also tells us when we are not
handling some part of the XML file

Change-Id: Ib64a704bc96bb4d6eff2d57116d62c9c15e25c6b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87073
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-01-20 15:41:53 +01:00
Noel Grandin e1383444c6 extract some common code from ImportContext classes
which reduces code bloat, and lets us log when elements are ignored

Change-Id: I5ca12bc1fcbfa3bea49ebde819fd80bd233a96a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86338
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-01-07 17:45:03 +01:00
Noel Grandin f656547d4d remove some useless comment lines
which merely announce that the next declaration is a class

Change-Id: Ifdb1398bcd99816b13e0b3769b46d0562bfbc1dc
Reviewed-on: https://gerrit.libreoffice.org/84229
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-12-03 12:46:27 +01:00
Michael Stahl 508dce40f8 xmloff,sw: fix handling of invalid attribute with multiple ':'
ooo53770-1.odt contains an invalid attribute
style:style:use-optimal-row-height, which was round-tripped as an
unknown attribute, triggering the assert in CheckValidName().

This reveals a confusing mess of SvXMLNamespaceMap::GetKeyByAttrName
functions.

The bCache flag for one of them was accidentally inverted in commit
78f0d15893 "loplugin:constantparam in xmloff/"

There are basically 2 use cases for this:
* XML element and attribute names, which are XML QName and contain at
  most 1 ':'
* XML attribute values, which are namespace-prefixed and may contain
  any number of ':' in the "local" part of the value

Because caching is explicitly disabled for Calc formulas, just resolve
the inconsistent bCache by always caching element and attribute names,
and never caching attribute values, so we need just 1 flag.

Change-Id: I363ea2229d0bf5c7199d61b0fee0d9f168911bfa
Reviewed-on: https://gerrit.libreoffice.org/83619
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-11-26 21:49:01 +01:00
Stephan Bergmann f853ec317f Extend loplugin:external to warn about classes
...following up on 314f15bff0 "Extend
loplugin:external to warn about enums".

Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:

  filter/source/svg/svgexport.cxx
  sc/source/filter/excel/xelink.cxx
  sc/source/filter/excel/xilink.cxx
  svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx

All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage.  (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)

For friend declarations using elaborate type specifiers, like

  class C1 {};
  class C2 { friend class C1; };

* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")

* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".

Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace.  But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".

Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.

And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.

And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is.  GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>)  The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.

Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-22 12:57:32 +01:00
Stephan Bergmann d526bd7dd5 Fix StringAdd::isCompileTimeConstant
...to find StringLiteral on the RHS of +=.  Which revealed that the
VisitCompoundStmt/checkForCompoundAssign logic needed to be fixed, too, so that

  s += side_effect();
  s += "literal";
  s += side_effect();

only gets combined to

  s += side_effect() + "literal";
  s += side_effect();

and not all the way to

  s += side_effect() + "literal" + side_effect();

Change-Id: I432e3458b933a7d0ad6141c747b675cc8b0f0ba4
Reviewed-on: https://gerrit.libreoffice.org/81804
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-31 09:14:39 +01:00
Noel Grandin 1db6a4c78f loplugin:virtualdead unused param in XMLEventContextFactory::CreateContext
Change-Id: I6fda2e04724d69fd218ffc85f9881b429714e63b
Reviewed-on: https://gerrit.libreoffice.org/81154
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-20 20:09:23 +02:00