This will be useful in later parts, as otherwise the changed callers would hit
the static analysis added in part 2. This new approach should also
theoretically be slightly more efficient in some cases.
Differential Revision: https://phabricator.services.mozilla.com/D286155
As mentioned in https://en.cppreference.com/w/cpp/string/byte/memcpy,
memcpy requires trivially copyable types. Same property holds for
memset.
GCC checks this, and clang will do in next release. In both cases it can
be silenced locally by casting the destination parameter to void*.
This patch introduces the following changes:
- AssignRangeAlgorithm was dispatching on the trivially constructable
trait, not trivially copyable. Note that it is basically a
reimplementation of std::uninitialized_copy_n, but using the later would
by-pass some specialization of nsTArrayElementTraits<T>::Construct.
- ShBuiltInResources default constructor already performs a memset
- mCachedAnonymousContentStyleIndexes used to contain std::pair<uint8_t,
uint8_t> which is not trivially copyable (!) at least under older
libstdc++. Use a more explicit POD type instead.
- PodOperations.h was not checking type requirements, it now does and
issue a compilation error in case of misuse.
- NetAddr copy and default constructors are already defined, so use them
instead of plain memset/memcpy.
- NetAddr has a copy constructor from PSNetAddr*, use it instead of a
plain memcpy.
- Do not create a temporary mozilla::phc::AddrInfo through a memcpy when
what we actually want is a reintepret_cast. Still perform a memcpy on
the bytes to enforce alignment.
Differential Revision: https://phabricator.services.mozilla.com/D231203