summaryrefslogtreecommitdiff
path: root/include/o3tl
AgeCommit message (Collapse)AuthorFilesLines
2020-12-04include cstddef for gcc11Jeff Law1-0/+1
Change-Id: I2f845ce9bb660ad6c1eea80ea81dd71add2c0db1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107204 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2020-03-12comparison operators should be constNoel Grandin1-1/+1
Change-Id: Ifa76e004128223460945d58d1c59c4e23db0f108 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90370 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-02-22Adapt o3tl::span to removal of std::span::cbegin et alStephan Bergmann1-7/+0
<https://cplusplus.github.io/LWG/issue3320> "span::cbegin/cend methods produce different results than std::[ranges::]cbegin/cend", as implemented now in <https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=commit; h=247f410b83797a1840573840cc2a539ef9d7f96b> "libstdc++: Remove std::span::cbegin and std::span::cend (LWG 3320)". Turns out we only used the removed member functions in o3tl/qa/test-span.cxx. Change-Id: I6c73797594b4e0e753a88840033d54961e271df5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89261 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-02-21Drop o3tl::optional wrapperStephan Bergmann2-65/+19
...now that macOS builds are guaranteed to have std::optional since 358146bbbd1b9775c12770fb5e497b6ec5adfc51 "Bump macOS build baseline to Xcode 11.3 and macOS 10.14.4". The change is done mostly mechanically with > for i in $(git grep -Fl optional); do > sed -i -e 's:<o3tl/optional\.hxx>\|\"o3tl/optional\.hxx\":<optional>:' \ > -e 's/\<o3tl::optional\>/std::optional/g' \ > -e 's/\<o3tl::make_optional\>/std::make_optional/g' "$i" > done > for i in $(git grep -Flw o3tl::nullopt); do > sed -i -e 's/\<o3tl::nullopt\>/std::nullopt/g' "$i" > done (though that causes some of the resulting #include <optional> to appear at different places relative to other includes than if they had been added manually), plus a few manual modifications: * adapt bin/find-unneeded-includes * adapt desktop/IwyuFilter_desktop.yaml * remove include/o3tl/optional.hxx * quote resulting "<"/">" as "&lt;"/"&gt;" in officecfg/registry/cppheader.xsl * and then solenv/clang-format/reformat-formatted-files Change-Id: I68833d9f7945e57aa2bc703349cbc5a56b342273 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89165 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-02-01std::unordered_set<T*> -> o3tl::sorted_vectorNoel Grandin1-0/+5
which is much better for CPU cache, since the representation is more compact, and since we almost always do insert() in pointer order, there is surprisingly little sorting Also add a count() method for compatibility with std::set and the proposed std::flat_set Change-Id: I2a3211dc59919cfec5cac1497530a4c3600d50ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87793 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-01-26move "remove duplicates" for a vector to o3tl/vector_utils.hxxTomaž Vajngerl1-0/+27
Change-Id: I9ecf95a2bf975912b7029cdfb459a9ebc159c75d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87429 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2020-01-09Introduce o3tl::make_unsigned to cast from signed to unsigned typeStephan Bergmann1-0/+8
...without having to spell out a specific type to cast to (and also making it more obvious what the intend of such a cast is) Change-Id: Id9c68b856a4ee52e5a40d15dc9d83e95d1c231cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86502 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-12-07Better not use constexpr hereStephan Bergmann1-1/+1
With a locally modified include/o3tl/optional.hxx to always pick the boost::optional branch, to prepare <https://gerrit.libreoffice.org/#/c/84672/> "Fix more new dependencies on boost_headers", that constexpr caused > In file included from idlc/source/errorhandler.cxx:20: > In file included from idlc/inc/errorhandler.hxx:23: > In file included from idlc/inc/astexpression.hxx:27: > include/o3tl/optional.hxx:28:23: error: constexpr variable cannot have non-literal type 'const boost::none_t' > inline constexpr auto nullopt = boost::none; > ^ > workdir/UnpackedTarball/boost/boost/none_t.hpp:29:8: note: 'none_t' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors > struct none_t > ^ at least with recent Clang 10 trunk and --without-system-boost. Change-Id: I679a6ca5d135d3f5571845a15afe20d28a1f9039 Reviewed-on: https://gerrit.libreoffice.org/84673 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-12-07Adapt o3tl::span to P1872R0Stephan Bergmann1-6/+8
..."span should have size_type, not index_type" (<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1872r0.pdf>), as implemented by libc++ since <https://github.com/llvm/llvm-project/commit/ 1466335cf4b2854a0be1defcf279fe50772bad6f> "[libc++][P1872] span should have size_type, not index_type." All uses of index_type had been added to mitigate the previous std::span change from signed (ptrdiff_t) to unsigned (size_t) index_type, see 6ef8420fdbf8dff16de13147c5ab833bc5e01121 "Adapt o3tl::span to updated C++2a std::span". There is no easy solution to transparently support all three std::span variants currently out there (signed index_type, unsigned index_type, unsigned size_type), without causing compilation failures due to CPPUNIT_ASSERT_EQUAL with arguments of different types, or compiler warnings about mixed signed/unsigned comparisons. So rule out the oldest std::span variant (signed index_type) in configure.ac (so that o3tl::span will use its own hand-rolled code in that case) and simplify the uses of index_type to std::size_t (as had already been mentioned in 6ef8420fdbf8dff16de13147c5ab833bc5e01121). Change-Id: I6ddf424ffb7941da3f69ad66fd29ecd35f09afae Reviewed-on: https://gerrit.libreoffice.org/84652 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-12-03Adapt CPPUNIT_ASSERT to C++20 deleted ostream << for sal_Unicode (aka char16_t)Stephan Bergmann1-0/+27
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r3.html> "char8_t backward compatibility remediation", as implemented now by <https://gcc.gnu.org/ git/?p=gcc.git;a=commit;h=0c5b35933e5b150df0ab487efb2f11ef5685f713> "libstdc++: P1423R3 char8_t remediation (2/4)" for -std=c++2a, deletes operator << overloads that would print an integer rather than a (presumably expected) character. But for simplicity (and to avoid issues with non-printing characters), keep printing an integer here. Change-Id: I751b99ee32d418eb488131ffa130d6f7d6d38dc7 Reviewed-on: https://gerrit.libreoffice.org/84348 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-12-01Introduce o3tl::optional as an alias for std::optionalStephan Bergmann2-19/+65
...with a boost::optional fallback for Xcode < 10 (as std::optional is only available starting with Xcode 10 according to <https://en.cppreference.com/w/cpp/compiler_support>, and our baseline for iOS and macOS is still Xcode 9.3 according to README.md). And mechanically rewrite all code to use o3tl::optional instead of boost::optional. One immediate benefit is that disabling -Wmaybe-uninitialized for GCC as per fed7c3deb3f4ec81f78967c2d7f3c4554398cb9d "Slience bogus -Werror=maybe-uninitialized" should no longer be necessary (and whose check happened to no longer trigger for GCC 10 trunk, even though that compiler would still emit bogus -Wmaybe-uninitialized for uses of boost::optional under --enable-optimized, which made me ponder whether this switch from boost::optional to std::optional would be a useful thing to do; I keep that configure.ac check for now, though, and will only remove it in a follow up commit). Another longer-term benefit is that the code is now already in good shape for an eventual switch to std::optional (a switch we would have done anyway once we no longer need to support Xcode < 10). Only desktop/qa/desktop_lib/test_desktop_lib.cxx heavily uses boost::property_tree::ptree::get_child_optional returning boost::optional, so let it keep using boost::optional for now. After a number of preceding commits have paved the way for this change, this commit is completely mechanical, done with > git ls-files -z | grep -vz -e '^bin/find-unneeded-includes$' -e '^configure.ac$' -e '^desktop/qa/desktop_lib/test_desktop_lib.cxx$' -e '^dictionaries$' -e '^external/' -e '^helpcontent2$' -e '^include/IwyuFilter_include.yaml$' -e '^sc/IwyuFilter_sc.yaml$' -e '^solenv/gdb/boost/optional.py$' -e '^solenv/vs/LibreOffice.natvis$' -e '^translations$' -e '\.svg$' | xargs -0 sed -i -E -e 's|\<boost(/optional)?/optional\.hpp\>|o3tl/optional.hxx|g' -e 's/\<boost(\s*)::(\s*)(make_)?optional\>/o3tl\1::\2\3optional/g' -e 's/\<boost(\s*)::(\s*)none\>/o3tl\1::\2nullopt/g' (before committing include/o3tl/optional.hxx, and relying on some GNU features). It excludes some files where mention of boost::optional et al should apparently not be changed (and the sub-repo directory stubs). It turned out that all uses of boost::none across the code base were in combination with boost::optional, so had all to be rewritten as o3tl::nullopt. Change-Id: Ibfd9f4b3d5a8aee6e6eed310b988c4e5ffd8b11b Reviewed-on: https://gerrit.libreoffice.org/84128 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-27tdf#108642 simplify comparison data calculationNoel Grandin1-0/+10
Complex table-based writer doc with sidebar slow to open. We are only using the extent data in SwAccessibleTableData_Impl as a comparison method to see if that table structure has changed. So just compare the rows and columns arrays instead of calculating extents. The downside is that we might fire events a little more often. This takes the opening time from 17s to 10s for me. Change-Id: I936cbc01072345d6360c0ec162de20b3111a588e Reviewed-on: https://gerrit.libreoffice.org/83682 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-11-26Remove bogus enumarray[_const]_iterator assignment opsStephan Bergmann1-14/+10
...that write into the m_buf of reference type (or at least would try to if the assignment op were ever instantiated for enumarray_const_iterator). They have been present since a0032a2dc2e4ac7615baaacdde5fefa64048822e "improve o3tl::enumarray const-ness" turned m_buf from a pointer to a reference. (Found with recent Clang 10 trunk -Werror,-Wdeprecated-copy, cf. <https://gerrit.libreoffice.org/#/c/83698/> "Remove some redundantly user-declared copy ctors and assignment ops".) But then at least some MSVC 2017 would still want to implicitly define them as non-deleted (see <https://ci.libreoffice.org/job/gerrit_windows/50602/> trying to build a prior version of this change) and fail, so change m_buf from reference to pointer. Change-Id: I3d4a420d2c4c6a6e966df74cfa33b5e00e0af5f6 Reviewed-on: https://gerrit.libreoffice.org/83701 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-06ofz#12553 TimeoutCaolán McNamara1-0/+13
before: real 1m37.479s user 1m30.682s sys 0m0.261s after: real 0m44.166s user 0m44.010s sys 0m0.056s Change-Id: I9832a2aac0278120fb62fe4a6a3e4507fc80e36f Reviewed-on: https://gerrit.libreoffice.org/82129 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-10-29loplugin:finalclasses jvmaccess..o3tlNoel Grandin1-1/+1
Change-Id: Iadb8621d7490b55ee6dbcadffb3c7e2527958424 Reviewed-on: https://gerrit.libreoffice.org/81655 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-08Introduce o3tl::unsafe_downcast for known-good dynamic_cast downcastsStephan Bergmann1-0/+35
(This helps rewrite code that silences Coverity unchecked dynamic_cast warnings, like 57b89ea1c2ff07b53c3cc002e5ec9e52abd0c1bd "coverity#704563 Unchecked dynamic cast", in a way that is cleaner and potentially executes faster.) Change-Id: I3319c0eeec2aa822f686feacd499a76c8c9b9499 Reviewed-on: https://gerrit.libreoffice.org/80458 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-25constinit, here we comeStephan Bergmann1-2/+2
Following up on b13421011d9377676e1adc282634991d5064a866 "better data structures for some static const vars": * Make the o3tl::sorted_vector ctor taking an initializer_list constexpr. <https://wg21.link/P0202R3> "Add Constexpr Modifiers to Functions in <algorithm> and <utility> Headers", which will be in C++2a and is already implemented by recent libc++ and libstdc++ according to <https://en.cppreference.com/w/cpp/compiler_support #C.2B.2B2a_library_features>, makes std::sort constexpr but explicitly keeps std::stable_sort non-constexpr. ("Algorithms stable_partition, inplace_merge and stable_sort allocate memory, construct variables using placement new, use unique_ptr and do other things not acceptable in constexpr expressions. Making those algorithms constexpr seems to be a hard task that would require a lot of intrinsics. Those algorithms are not marked with constexpr in this wording.") But keep o3tl::sorted_vector::Resort (which was introduced in c59355e936446fe55960209e543b072acb6b2170 "fdo#58793: re-implement SwpHintsArray::Resort()") using std::stable_sort instead of std::sort, in case that is relevant for its pre-exisiting uses. * <https://wg21.link/P1004R2> "Making std::vector constexpr", which was voted into C++2a according to <https://wg21.link/n4829> "Editors' Report -- Programming Languages -- C++", will make the relevant parts of std::vector constexpr. But none of libc++, libstdc++, and MSVC implement that as of now. * Introduce HAVE_CPP_CONSTINIT_SORTED_VECTOR to hide the constinit behind for now for the one case from b13421011d9377676e1adc282634991d5064a866 "better data structures for some static const vars" that can clearly be constinit once constexpr std::vector is supported by compilers. The other three cases (s_aContainerDocumentCommands in chart2/source/controller/main/CommandDispatchContainer.cxx, aMetricCompatibleMap in vcl/source/font/PhysicalFontCollection.cxx, and aBlacklist in writerfilter/source/dmapper/PropertyMap.cxx) would each need a constexpr OUString first. (Technically, the constinit would not even be needed, but it nicely documents our intent that this will actually be initialized at compile-time once compilers support that.) Change-Id: Ibeb138f120528be3a7a09b3912143bf795fbab29 Reviewed-on: https://gerrit.libreoffice.org/79556 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-25better data structures for some static const varsNoel Grandin1-0/+12
use compact, cache-friendly structures for some static const stuff and add a std::initialiser_list constructor to o3tl::sorted_vector Change-Id: I6a6049bf19a7f48dae1843a81cd2257944ada9d5 Reviewed-on: https://gerrit.libreoffice.org/79470 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-09-06TyposAndrea Gelmini1-1/+1
Mainly fixing '....' and '..' Change-Id: Ic928701b319868671b826d757dd94c296fd5e942 Reviewed-on: https://gerrit.libreoffice.org/78668 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Julien Nabet <serval2412@yahoo.fr>
2019-08-23Mark move ctors/assignments noexceptMike Kaganski1-2/+2
This should enable using move semantics where possible e.g. in standard containers. According to https://en.cppreference.com/w/cpp/language/move_constructor: To make strong exception guarantee possible, user-defined move constructors should not throw exceptions. For example, std::vector relies on std::move_if_noexcept to choose between move and copy when the elements need to be relocated. Change-Id: I6e1e1cdd5cd430b139ffa2fa7031fb0bb625decb Reviewed-on: https://gerrit.libreoffice.org/77957 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2019-08-23loplugin:returnconstval in o3tlNoel Grandin1-3/+3
Change-Id: Ib36382243552cd80dab431741f45dc767beccf59 Reviewed-on: https://gerrit.libreoffice.org/77993 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-08-13Fix Clang 10 -Werror,-Wimplicit-int-float-conversionStephan Bergmann1-0/+57
> idlc/source/astexpression.cxx:330:68: error: implicit conversion from 'sal_Int32' (aka 'int') to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion] > if (ev->u.fval < SAL_MIN_INT32 || ev->u.fval > SAL_MAX_INT32) > ~ ^~~~~~~~~~~~~ > include/sal/types.h:209:32: note: expanded from macro 'SAL_MAX_INT32' > #define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF) > ^~~~~~~~~~~~~~~~~~~~~~~ > idlc/source/astexpression.cxx:414:58: error: implicit conversion from 'sal_uInt32' (aka 'unsigned int') to 'float' changes value from 4294967295 to 4294967296 [-Werror,-Wimplicit-int-float-conversion] > if (ev->u.fval < 0.0 || ev->u.fval > SAL_MAX_UINT32) > ~ ^~~~~~~~~~~~~~ > include/sal/types.h:210:32: note: expanded from macro 'SAL_MAX_UINT32' > #define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF) > ^~~~~~~~~~~~~~~~~~~~~~~ > idlc/source/astexpression.cxx:492:68: error: implicit conversion from 'sal_Int64' (aka 'long') to 'float' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion] > if (ev->u.fval < SAL_MIN_INT64 || ev->u.fval > SAL_MAX_INT64) > ~ ^~~~~~~~~~~~~ > include/sal/types.h:212:32: note: expanded from macro 'SAL_MAX_INT64' > #define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF)) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > idlc/source/astexpression.cxx:501:68: error: implicit conversion from 'sal_Int64' (aka 'long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion] > if (ev->u.dval < SAL_MIN_INT64 || ev->u.dval > SAL_MAX_INT64) > ~ ^~~~~~~~~~~~~ > include/sal/types.h:212:32: note: expanded from macro 'SAL_MAX_INT64' > #define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF)) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > idlc/source/astexpression.cxx:574:58: error: implicit conversion from 'sal_uInt64' (aka 'unsigned long') to 'float' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion] > if (ev->u.fval < 0.0 || ev->u.fval > SAL_MAX_UINT64) > ~ ^~~~~~~~~~~~~~ > include/sal/types.h:213:32: note: expanded from macro 'SAL_MAX_UINT64' > #define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF)) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > idlc/source/astexpression.cxx:583:58: error: implicit conversion from 'sal_uInt64' (aka 'unsigned long') to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion] > if (ev->u.dval < 0.0 || ev->u.dval > SAL_MAX_UINT64) > ~ ^~~~~~~~~~~~~~ > include/sal/types.h:213:32: note: expanded from macro 'SAL_MAX_UINT64' > #define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF)) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consitently use the new o3tl::convertsToAtLeast/Most(o3tl::roundAway(...), ...) for all cases in coerce_value that check that a floating-point value falls into an integer range, even those that don't cause a warning. The new idlc/test/parser/conversion.tests is deliberately left out of unoidl/CustomTarget_unoidl-write_test.mk. as unoidl-write doesn't support such conversions from floating-point to integer types. Change-Id: Ie00923e665f2bcb306e1e328614c75b9247512ee Reviewed-on: https://gerrit.libreoffice.org/77353 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-06-03fix crash in lru_map/SalBitmap on shutdownNoel Grandin1-0/+8
When we shut down, we destroy the various caches, in the process of which SalBitmap calls back into it's owning cache, causing a SIGSEGV. Found while loading files from tdf#83426 Change-Id: I53db1621a0fdb75a8e66582662b0e2666499192b Reviewed-on: https://gerrit.libreoffice.org/73387 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-16tdf#125254 Performance: A spreadsheet opens too slow, part1Noel Grandin1-0/+5
This takes the opening time from 55s to 48s for me. Change-Id: Ia60fff33e9948e0bd6906c82b48aa30f8b2551bb Reviewed-on: https://gerrit.libreoffice.org/72394 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-09add missing include guardsLuboš Luňák1-0/+5
Change-Id: I337c0f567112f95e2a1d762e511d5b632dd2892f Reviewed-on: https://gerrit.libreoffice.org/71997 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2019-03-18Adapt o3tl::span to updated C++2a std::spanStephan Bergmann1-3/+3
...where index_type has changed from ptrdiff_t to size_t, see <https:// github.com/cplusplus/draft/commit/7f2493e2e2d34b42a6c12c8806e536d4feb3aee3> "P1227R2 Signed ssize() functions, unsigned size() functions". Ideally, ece27693ba52417bc4b68045f5544a5cc43299dc "Adapt to C++2a std::span<>::index_type being unsigned size_t" could be simplified now to use std::size_t, but there may be build environments that include a C++2a <span> that hasn't been adapted to P1227R2 yet. Change-Id: I7bfc0da65d415ef06e94d95b5f62030aeb8b35f6 Reviewed-on: https://gerrit.libreoffice.org/69391 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-03-07log nice exception messages whereever possibleNoel Grandin1-2/+2
Change-Id: Idd125c18bee1a39b9ea8cc4f8c55cddfd37c33e1 Reviewed-on: https://gerrit.libreoffice.org/68579 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-05Introduce o3tl::underlyingEnumValueStephan Bergmann2-60/+77
Change-Id: I6554eb86326159b0da707539f45c411f61c0f3de Reviewed-on: https://gerrit.libreoffice.org/68761 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-02-25Drop include/o3tl/make_unique.hxxGabor Kelemen1-51/+0
In favor of std::make_unique Change-Id: I0428076a10fb7b61c5add994c9970661b375b82c Reviewed-on: https://gerrit.libreoffice.org/68254 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-01Introduce O3TL_UNREACHABLE as a better alternative to assert(false)Stephan Bergmann1-0/+39
The code in sw/source/core/fields/reffld.cxx had turned into whack-a-mole: MSVC needed the unreachable default:assert(false); to fall through to init some vars to avoid C4701 ("potentially uninitialized local variable"). But Clang (with !NDEBUG, and an implementation of assert marked as noreturn) reported that as "fallthrough annotation in unreachable code", requiring the #ifdef NDEBUG guards to be added. And now clang-cl (also with !NDEBUG, but with the MSVC implementation of assert apparently not marked as noreturn) complained about "unannotated fall-through between switch labels", which wold require the #ifdef NDEBUG guards to be removed again. O3TL_UNREACHABLE (inspired by LLVM's llvm_unreachable and underyling LLVM_BUILTIN_UNREACHABLE) hopefully improves on that for all compilers involved. For non-MSVC (i.e., Clang or GCC) it assumes that __builtin_unreachable is supported (which it is at least for GCC 7, which is our current baseline per README.md). Change-Id: I4474f95664d97c3d0e506bab90f80d5ab252ec6e Reviewed-on: https://gerrit.libreoffice.org/67232 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-13array_view was changed to span in upcoming C++20Stephan Bergmann2-163/+95
...see <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0122r7.pdf> "span: bounds-safe views for sequences of objects". o3tl::span is still an incomplete approximation of std::span; removed those o3tl::array_view members that are not present in std::span (and were not used in the code). Relies on C++17 __has_include to use standard <span> where available (e.g., in LLVM 7 libc++). Change-Id: I82a7e246b61b2456fa6183025d25eec4121ad3c9 Reviewed-on: https://gerrit.libreoffice.org/66215 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-11Drop o3tl/clamp.hxx, use C++17 std::clamp insteadStephan Bergmann1-39/+0
Change-Id: I5043c787dcc3b78bc7fdff130564801194e39f46 Reviewed-on: https://gerrit.libreoffice.org/66177 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-11Drop o3tl/string_view.hxxStephan Bergmann1-808/+0
...now that all of its uses have been replaced with C++17 <string_view>. The LO-specific o3tl::basic_string_view ctors with OString and OUString params have meanwhile been replaced with OString and OUString conversion functions (in dac7be50cff94e0c34cdca5ac7e35c19685c40c1 "o3tl::string_view -> std::string_view (in configmgr)"), the ctor with OUStringLiteral turned out to be no longer(?) needed anyway, and the LO-specific o3tl::toOUString has meanwhile been replaced with an OUString ctor with std::u16string_view param (in 6856da30665705be6380e84cf55de954c41f15d1 "o3tl::string_view -> std::string_view (in embedserv)"). Change-Id: Ie5215b07e2387560fb7e94de8b5a963241539c64 Reviewed-on: https://gerrit.libreoffice.org/66144 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-12-16Fix o3tl::string_view streaming operator <<Stephan Bergmann1-6/+5
(The unnecessary os.setstate(std::ios_base::failbit) was due to a misreading of C++17 [ostream.formatted.reqmts]/1.) Change-Id: I7d8285230cb316c7af45c76029e9629517d05d56 Reviewed-on: https://gerrit.libreoffice.org/65217 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-12-07HAVE_CXX14_CONSTEXPR is always true nowStephan Bergmann5-127/+23
...but for safety, leave the configure.ac check in for some longer. o3tl::array_view::max_size (include/o3tl/array_view.hxx) and o3tl::basic_string_view::max_size (include/o3tl/string_view.hxx) started to produce loplugin:staticmethods warnings, which I silenced by /not/ making the functions static. Those classes are meant to be temporary drop-in replacements for standard classes (std::span slated for C++20, prev. std::array_view; and std::basic_string_view, resp.), so should have the same behavior as their standard counterparts (and making the functions static would likely cause loplugin:staticaccess warnings at call sites). Change-Id: If21674dbf02886f453ca447544e37b184df5a25e Reviewed-on: https://gerrit.libreoffice.org/64768 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-12-06Remove obsolete GCC version checksStephan Bergmann1-1/+1
...after <https://gerrit.libreoffice.org/63951> "Bump (Linux) GCC baseline to 7.0.0". (In some cases, those checks now need to check for __clang__, which was implicitly covered in the past by Clang consistently reporting to be GCC 4.2.1.) Change-Id: I860fef8c4ca41c22a7541f0fb2d34b37d1d69bed Reviewed-on: https://gerrit.libreoffice.org/63952 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-11-30Remove obsolete _MSC_VER checksStephan Bergmann1-10/+1
...after 206b8c4ae320d7d8614f21800d8f77fa29f8f5ff "On Windows, check for at least Visual Studio 2017 version 15.7" Change-Id: I38ee86e1649bbdc828a7e328f2dbbac0dc163c8a Reviewed-on: https://gerrit.libreoffice.org/64250 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-10-24remove more rtl::OUString and OString prefixesNoel Grandin1-6/+6
which seem to have snuck back in since the great rounds of removals. Change-Id: I85f7f5f4801c0b48dae8b50f51f83595b286d6a1 Reviewed-on: https://gerrit.libreoffice.org/62229 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-06Convert ImplFontCache to use o3tl::lru_mapJan-Marek Glogowski1-3/+4
We still do our own cleanup of the LRU map, as we can't drop any fonts in use. Change-Id: I8ec5c6ce8f80893635621357e9085950e7010f5b Reviewed-on: https://gerrit.libreoffice.org/61455 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2018-10-06Add a glyph-bound-rect cache to the font cacheJan-Marek Glogowski1-1/+26
This way the font cache can correctly invalidate the cached glyph rects when a font is dropped from the cache. Change-Id: I050866099742334f01cac1b872228a017ddb5e9b Reviewed-on: https://gerrit.libreoffice.org/61371 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2018-10-06loplugin:useuniqueptr in SwHTMLPosFlyFramesNoel Grandin1-0/+11
and add a new method erase_extract to o3tl::sorted_vector, otherwise there is no decent way to extract an element from such a vector without freeing it. Change-Id: I769782c04a54a2d7433e8349c99134f997a54689 Reviewed-on: https://gerrit.libreoffice.org/61345 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-06lru_map: fix std::move insertJan-Marek Glogowski1-3/+7
After the move the std::pair is invalid. That caused invalid iterators on lookups - hard to debug... Also adds an assertion to warn if size of map and list differ. Change-Id: Ib987d47963d5e1009d64a96dcdd588a0bc27cd77 Reviewed-on: https://gerrit.libreoffice.org/61451 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2018-10-04loplugin:useuniqueptr in SetGetExpFieldsNoel Grandin1-0/+20
and a couple more utility methods to o3tl::sorted_vector to make this easier Change-Id: Iebbbb8899b67fffa1ac98ae46b7fa70a7e35f866 Reviewed-on: https://gerrit.libreoffice.org/61344 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-19implement find(T*) for o3tl::sorted_vector when it contains unique_ptr<T>Noel Grandin1-0/+12
and add some unit tests Change-Id: I9a01c9fa2fbbf3a553663a980ee6e958f9819645 Reviewed-on: https://gerrit.libreoffice.org/60737 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-06make SwWriteTableRows be a vector of std::unique_ptrNoel Grandin1-2/+46
and update o3tl::sorted_vector to handle that Change-Id: I11a9ec3ec09f835cbd7e49ccda133b9f210d761e Reviewed-on: https://gerrit.libreoffice.org/59931 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-2932-bit Clang trunk (towards Clang 9) still doesn't have __mulodi4Stephan Bergmann1-2/+2
Change-Id: I7579ff88d34c931a51c820b53960a281e6e3678e Reviewed-on: https://gerrit.libreoffice.org/59763 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-15RTF picture sizes are 32-bit signedStephan Bergmann1-0/+43
...not 16-bit unsigned. Word2007RTFSpec9.docx states "A small number of control words take values in the range −2,147,483,648 to 2,147,483,647 (32-bit signed integer)." and for \picwN, \pichN, \picwgoalN, and \pichgoalN it states "The N argument is a long integer." This was found with Clang's new -fsanitize=implicit-conversion during CppunitTest_writerfilter_rtftok, where writerfilter/qa/cppunittests/rtftok/data/pass/TCI-TN65GP-DDRHDLL-partial.rtf contains "\pich81306": > Testing file:///home/sbergman/lo/core/writerfilter/qa/cppunittests/rtftok/data/pass/TCI-TN65GP-DDRHDLL-partial.rtf: [...] > writerfilter/source/rtftok/rtfdispatchvalue.cxx:770:48: runtime error: implicit conversion from type 'int' of value 81306 (32-bit, signed) to type 'sal_uInt16' (aka 'unsigned short') changed the value to 15770 (16-bit, unsigned) > #0 in writerfilter::rtftok::RTFDocumentImpl::dispatchValue(writerfilter::rtftok::RTFKeyword, int) at writerfilter/source/rtftok/rtfdispatchvalue.cxx:770:48 (instdir/program/libwriterfilterlo.so +0xb96f2f) > #1 in writerfilter::rtftok::RTFTokenizer::dispatchKeyword(rtl::OString const&, bool, int) at writerfilter/source/rtftok/rtftokenizer.cxx:311:29 (instdir/program/libwriterfilterlo.so +0xd86c93) > #2 in writerfilter::rtftok::RTFTokenizer::resolveKeyword() at writerfilter/source/rtftok/rtftokenizer.cxx:243:12 (instdir/program/libwriterfilterlo.so +0xd84b06) > #3 in writerfilter::rtftok::RTFTokenizer::resolveParse() at writerfilter/source/rtftok/rtftokenizer.cxx:123:27 (instdir/program/libwriterfilterlo.so +0xd8299a) > #4 in writerfilter::rtftok::RTFDocumentImpl::resolve(writerfilter::Stream&) at writerfilter/source/rtftok/rtfdocumentimpl.cxx:786:27 (instdir/program/libwriterfilterlo.so +0xbf03bd) > #5 in RtfFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at writerfilter/source/filter/RtfFilter.cxx:144:20 (instdir/program/libwriterfilterlo.so +0x132d911) > #6 in RtfTest::load(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at writerfilter/qa/cppunittests/rtftok/testrtftok.cxx:58:27 (workdir/LinkTarget/CppunitTest/libtest_writerfilter_rtftok.so +0x15c6e) > #7 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:130:20 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x5724c) > #8 in test::FiltersTest::testDir(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:155:5 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x57ec9) > #9 in RtfTest::test() at writerfilter/qa/cppunittests/rtftok/testrtftok.cxx:78:5 (workdir/LinkTarget/CppunitTest/libtest_writerfilter_rtftok.so +0x16214) (Needs to add o3tl::clamp as a compatibility wrapper for C++17 std::clamp.) Change-Id: I515e70a435c2585777062fd5a27d1de8ddbe1b74 Reviewed-on: https://gerrit.libreoffice.org/59038 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins
2018-07-30Add missing sal/log.hxx headersGabor Kelemen1-0/+1
rtl/string.hxx and rtl/ustring.hxx both unnecessarily #include <sal/log.hxx> (and don't make use of it themselves), but many other files happen to depend on it. This is a continuation of commit 6ff2d84ade299cb3d14d4110e4cf1a4b8070c030 to be able to remove those unneeded includes. This commit adds missing headers to every file found by: grep -FwL sal/log.hxx $(git grep -Elw 'SAL_INFO|SAL_INFO_IF|SAL_WARN|SAL_WARN_IF|SAL_DETAIL_LOG_STREAM|SAL_WHERE|SAL_STREAM|SAL_DEBUG') to directories from filter to jvmfwk Change-Id: I2a73d63f2aaef5f26d7d08957daaa8a30b412ac5 Reviewed-on: https://gerrit.libreoffice.org/58204 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-07-26o3tl: avoid -Werror=deprecated-copy (GCC trunk towards GCC 9)Stephan Bergmann1-7/+0
...by removing explicitly user-provided functions that do the same as their implicitly-defined counterparts, but may prevent implicitly declared copy functions from being defined as non-deleted in the future Change-Id: If3430e23fff7bb0da12ae20579696869bdf9b3d8 Reviewed-on: https://gerrit.libreoffice.org/58082 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-06-04o3tl: add more strong_int operatorsMichael Stahl1-0/+9
Change-Id: Ibb0f883353b6d172275744eaa59d27ba39930623 Reviewed-on: https://gerrit.libreoffice.org/55264 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>