Bug 1613176 - Prove to the incoming clang plugin that our templates are indeed trivially copiable. r=boris

Otherwise it'd error, which is not great. We could add a custom attribute in
there if needed or something, or fix cbindgen to generate these for us as
described in the issue linked from the comments.

Do this in ServoStyleConstsInlines as that's where we have the guarantee that
the templates have been defined, and that the file is included every time
ServoStyleConsts is included.

Differential Revision: https://phabricator.services.mozilla.com/D61625

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2020-02-05 22:20:29 +00:00
parent d94307cf3a
commit 227891b140
2 changed files with 37 additions and 0 deletions

View File

@ -20,6 +20,13 @@ namespace mozilla {
//
// But they only contain pointers so it is ok. Also, this warning hilariously
// doesn't exist in GCC.
//
// A solution for this is to explicitly instantiate the template, but duplicate
// instantiations are an error.
//
// https://github.com/eqrion/cbindgen/issues/402 tracks an improvement to
// cbindgen that would allow it to autogenerate the template instantiations on
// its own.
#pragma GCC diagnostic push
#ifdef __clang__
# pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"

View File

@ -22,6 +22,36 @@
namespace mozilla {
// We need to explicitly instantiate these so that the clang plugin can see that
// they're trivially copiable...
//
// https://github.com/eqrion/cbindgen/issues/402 tracks doing something like
// this automatically from cbindgen.
template struct StyleOwned<RawServoAnimationValueMap>;
template struct StyleOwned<RawServoAuthorStyles>;
template struct StyleOwned<RawServoSourceSizeList>;
template struct StyleOwned<StyleUseCounters>;
template struct StyleOwnedOrNull<StyleUseCounters>;
template struct StyleOwnedOrNull<RawServoSelectorList>;
template struct StyleStrong<ComputedStyle>;
template struct StyleStrong<ServoCssRules>;
template struct StyleStrong<RawServoAnimationValue>;
template struct StyleStrong<RawServoDeclarationBlock>;
template struct StyleStrong<RawServoStyleSheetContents>;
template struct StyleStrong<RawServoKeyframe>;
template struct StyleStrong<RawServoMediaList>;
template struct StyleStrong<RawServoStyleRule>;
template struct StyleStrong<RawServoImportRule>;
template struct StyleStrong<RawServoKeyframesRule>;
template struct StyleStrong<RawServoMediaRule>;
template struct StyleStrong<RawServoMozDocumentRule>;
template struct StyleStrong<RawServoNamespaceRule>;
template struct StyleStrong<RawServoPageRule>;
template struct StyleStrong<RawServoSupportsRule>;
template struct StyleStrong<RawServoFontFeatureValuesRule>;
template struct StyleStrong<RawServoFontFaceRule>;
template struct StyleStrong<RawServoCounterStyleRule>;
template <typename T>
inline void StyleOwnedSlice<T>::Clear() {
if (!len) {