Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/bindings/WebIDLSerializable.cpp
Warning:line 19, column 8
Excessive padding in 'struct mozilla::dom::WebIDLSerializableEntry' (10 padding bytes, where 2 is optimal). Optimal fields order: mDeserialize, mTag, mExposedGlobals, consider reordering the fields or adding explicit padding members

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name WebIDLSerializable.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/bindings -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/bindings -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D GOOGLE_PROTOBUF_NO_RTTI -D GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/dom/bindings -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/bindings -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom -I /root/firefox-clang/dom/base -I /root/firefox-clang/dom/battery -I /root/firefox-clang/dom/canvas -I /root/firefox-clang/dom/geolocation -I /root/firefox-clang/dom/html -I /root/firefox-clang/dom/indexedDB -I /root/firefox-clang/dom/media/webaudio -I /root/firefox-clang/dom/media/webrtc -I /root/firefox-clang/dom/media/webrtc/common/time_profiling -I /root/firefox-clang/dom/media/webrtc/jsapi -I /root/firefox-clang/dom/media/webrtc/libwebrtcglue -I /root/firefox-clang/dom/media/webrtc/transport -I /root/firefox-clang/dom/media/webspeech/recognition -I /root/firefox-clang/dom/svg -I /root/firefox-clang/dom/xml -I /root/firefox-clang/dom/xslt/base -I /root/firefox-clang/dom/xslt/xpath -I /root/firefox-clang/dom/xul -I /root/firefox-clang/js/xpconnect/src -I /root/firefox-clang/js/xpconnect/wrappers -I /root/firefox-clang/layout/generic -I /root/firefox-clang/layout/style -I /root/firefox-clang/layout/xul/tree -I /root/firefox-clang/media/webrtc -I /root/firefox-clang/netwerk/base -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/third_party/libwebrtc -I /root/firefox-clang/third_party/msgpack/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-10-17-231001-351276-1 -x c++ WebIDLSerializable.cpp
1#include "DOMExceptionBinding.h"
2#include "DOMMatrixBinding.h"
3#include "DOMPointBinding.h"
4#include "DOMQuadBinding.h"
5#include "DOMRectBinding.h"
6#include "FileSystemDirectoryHandleBinding.h"
7#include "FileSystemFileHandleBinding.h"
8#include "FileSystemHandleBinding.h"
9#include "ImageDataBinding.h"
10#include "QuotaExceededErrorBinding.h"
11#include "RTCCertificateBinding.h"
12#include "StructuredCloneTesterBinding.h"
13#include "SubtleCryptoBinding.h"
14#include "WebTransportErrorBinding.h"
15#include "mozilla/PerfectHash.h"
16#include "mozilla/dom/WebIDLSerializable.h"
17
18namespace mozilla::dom {
19struct WebIDLSerializableEntry {
Excessive padding in 'struct mozilla::dom::WebIDLSerializableEntry' (10 padding bytes, where 2 is optimal). Optimal fields order: mDeserialize, mTag, mExposedGlobals, consider reordering the fields or adding explicit padding members
20 StructuredCloneTags mTag;
21 WebIDLDeserializer mDeserialize;
22 uint16_t mExposedGlobals;
23};
24
25static const WebIDLSerializableEntry sEntries[] = {
26 {
27 /* mTag */ SCTAG_DOM_CRYPTOKEY,
28 /* mDeserialize */ CryptoKey_Binding::Deserialize,
29 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
30 },
31 {
32 /* mTag */ SCTAG_DOM_DOMEXCEPTION,
33 /* mDeserialize */ DOMException_Binding::Deserialize,
34 /* mExposedGlobals */ GlobalNames::AudioWorkletGlobalScope | GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::PaintWorkletGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window | GlobalNames::WorkerDebuggerGlobalScope,
35 },
36 {
37 /* mTag */ SCTAG_DOM_DOMMATRIX,
38 /* mDeserialize */ DOMMatrix_Binding::Deserialize,
39 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
40 },
41 {
42 /* mTag */ SCTAG_DOM_DOMMATRIXREADONLY,
43 /* mDeserialize */ DOMMatrixReadOnly_Binding::Deserialize,
44 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
45 },
46 {
47 /* mTag */ SCTAG_DOM_DOMPOINT,
48 /* mDeserialize */ DOMPoint_Binding::Deserialize,
49 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
50 },
51 {
52 /* mTag */ SCTAG_DOM_DOMPOINTREADONLY,
53 /* mDeserialize */ DOMPointReadOnly_Binding::Deserialize,
54 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
55 },
56 {
57 /* mTag */ SCTAG_DOM_DOMQUAD,
58 /* mDeserialize */ DOMQuad_Binding::Deserialize,
59 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
60 },
61 {
62 /* mTag */ SCTAG_DOM_DOMRECT,
63 /* mDeserialize */ DOMRect_Binding::Deserialize,
64 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
65 },
66 {
67 /* mTag */ SCTAG_DOM_DOMRECTREADONLY,
68 /* mDeserialize */ DOMRectReadOnly_Binding::Deserialize,
69 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
70 },
71 {
72 /* mTag */ SCTAG_DOM_FILESYSTEMDIRECTORYHANDLE,
73 /* mDeserialize */ FileSystemDirectoryHandle_Binding::Deserialize,
74 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
75 },
76 {
77 /* mTag */ SCTAG_DOM_FILESYSTEMFILEHANDLE,
78 /* mDeserialize */ FileSystemFileHandle_Binding::Deserialize,
79 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
80 },
81 {
82 /* mTag */ SCTAG_DOM_FILESYSTEMHANDLE,
83 /* mDeserialize */ FileSystemHandle_Binding::Deserialize,
84 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
85 },
86 {
87 /* mTag */ SCTAG_DOM_IMAGEDATA,
88 /* mDeserialize */ ImageData_Binding::Deserialize,
89 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
90 },
91 {
92 /* mTag */ SCTAG_DOM_QUOTAEXCEEDEDERROR,
93 /* mDeserialize */ QuotaExceededError_Binding::Deserialize,
94 /* mExposedGlobals */ GlobalNames::AudioWorkletGlobalScope | GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::PaintWorkletGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window | GlobalNames::WorkerDebuggerGlobalScope,
95 },
96 {
97 /* mTag */ SCTAG_DOM_RTCCERTIFICATE,
98 /* mDeserialize */ RTCCertificate_Binding::Deserialize,
99 /* mExposedGlobals */ GlobalNames::Window,
100 },
101 {
102 /* mTag */ SCTAG_DOM_STRUCTUREDCLONETESTER,
103 /* mDeserialize */ StructuredCloneTester_Binding::Deserialize,
104 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
105 },
106 {
107 /* mTag */ SCTAG_DOM_WEBTRANSPORTERROR,
108 /* mDeserialize */ WebTransportError_Binding::Deserialize,
109 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
110 }
111};
112
113Maybe<std::pair<uint16_t, WebIDLDeserializer>> LookupDeserializer(StructuredCloneTags aTag) {
114 for (auto& entry : sEntries) {
115 if (entry.mTag == aTag) {
116 return Some(std::pair(entry.mExposedGlobals, entry.mDeserialize));
117 }
118 }
119 return Nothing();
120}
121} // namespace mozilla::dom
122