Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/extensions/spellcheck/hunspell/src/./../../../../../extensions/spellcheck/hunspell/src/affixmgr.hxx
Warning:line 93, column 7
Excessive padding in 'class AffixMgr' (42 padding bytes, where 2 is optimal). Optimal fields order: alldic, pHMgr, csconv, iconvtable, oconvtable, phone, pfxappnd, sfxappnd, derived, sfx, pfx, maptable, breaktable, checkcpdtable, defcpdtable, cpdvowels_utf16, wordchars_utf16, ignorechars_utf16, keystring, trystring, encoding, cpdvowels, cpdsyllablenum, wordchars, ignorechars, version, lang, pStart, sStart, pFlag, sFlag, utf8, complexprefixes, compoundmoresuffixes, checkcompounddup, checkcompoundrep, checkcompoundcase, checkcompoundtriple, simplifiedtriple, cpdmin, simplifiedcpd, maxngramsugs, maxcpdsugs, maxdiff, onlymaxdiff, nosplitsugs, sugswithdots, cpdwordmax, cpdmaxsyllable, sfxextra, checknum, langnum, forbidwarn, checksharps, fullstrip, havecontclass, compoundflag, compoundbegin, compoundmiddle, compoundend, compoundroot, compoundforbidflag, compoundpermitflag, forbiddenword, nosuggest, nongramsuggest, needaffix, sfxflag, lemma_present, circumfix, onlyincompound, keepcase, forceucase, warn, substandard, parsedmaptable, parsedbreaktable, parsedcheckcpd, parseddefcpd, contclasses, 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 Unified_cpp_hunspell_src0.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/extensions/spellcheck/hunspell/src -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/extensions/spellcheck/hunspell/src -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 -include hunspell_alloc_hooks.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 HUNSPELL_STATIC -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/extensions/spellcheck/hunspell/src -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/extensions/spellcheck/hunspell/src -I /root/firefox-clang/extensions/spellcheck/hunspell/glue -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/toolkit/components/telemetry -I /root/firefox-clang/xpcom/base -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 -Wno-implicit-fallthrough -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-09-01-224014-2642839-1 -x c++ Unified_cpp_hunspell_src0.cpp
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * Copyright (C) 2002-2022 Németh László
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks.
17 *
18 * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno,
19 * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád,
20 * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter,
21 * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls,
22 * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37/*
38 * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada
39 * And Contributors. All rights reserved.
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 *
45 * 1. Redistributions of source code must retain the above copyright
46 * notice, this list of conditions and the following disclaimer.
47 *
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 *
52 * 3. All modifications to the source code must be clearly marked as
53 * such. Binary redistributions based on modified source code
54 * must be clearly marked as modified versions in the documentation
55 * and/or other materials provided with the distribution.
56 *
57 * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS
58 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
59 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
60 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
61 * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
62 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
63 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE.
69 */
70
71#ifndef AFFIXMGR_HXX_
72#define AFFIXMGR_HXX_
73
74#include <cstdio>
75
76#include <memory>
77#include <string>
78#include <vector>
79
80#include "atypes.hxx"
81#include "baseaffix.hxx"
82#include "hashmgr.hxx"
83#include "phonet.hxx"
84#include "replist.hxx"
85
86// check flag duplication
87#define dupSFX(1 << 0) (1 << 0)
88#define dupPFX(1 << 1) (1 << 1)
89
90class PfxEntry;
91class SfxEntry;
92
93class AffixMgr {
Excessive padding in 'class AffixMgr' (42 padding bytes, where 2 is optimal). Optimal fields order: alldic, pHMgr, csconv, iconvtable, oconvtable, phone, pfxappnd, sfxappnd, derived, sfx, pfx, maptable, breaktable, checkcpdtable, defcpdtable, cpdvowels_utf16, wordchars_utf16, ignorechars_utf16, keystring, trystring, encoding, cpdvowels, cpdsyllablenum, wordchars, ignorechars, version, lang, pStart, sStart, pFlag, sFlag, utf8, complexprefixes, compoundmoresuffixes, checkcompounddup, checkcompoundrep, checkcompoundcase, checkcompoundtriple, simplifiedtriple, cpdmin, simplifiedcpd, maxngramsugs, maxcpdsugs, maxdiff, onlymaxdiff, nosplitsugs, sugswithdots, cpdwordmax, cpdmaxsyllable, sfxextra, checknum, langnum, forbidwarn, checksharps, fullstrip, havecontclass, compoundflag, compoundbegin, compoundmiddle, compoundend, compoundroot, compoundforbidflag, compoundpermitflag, forbiddenword, nosuggest, nongramsuggest, needaffix, sfxflag, lemma_present, circumfix, onlyincompound, keepcase, forceucase, warn, substandard, parsedmaptable, parsedbreaktable, parsedcheckcpd, parseddefcpd, contclasses, consider reordering the fields or adding explicit padding members
94 PfxEntry* pStart[SETSIZE256];
95 SfxEntry* sStart[SETSIZE256];
96 PfxEntry* pFlag[SETSIZE256];
97 SfxEntry* sFlag[SETSIZE256];
98 const std::vector<std::unique_ptr<HashMgr>>& alldic;
99 const HashMgr* pHMgr;
100 std::string keystring;
101 std::string trystring;
102 std::string encoding;
103 const struct cs_info* csconv;
104 int utf8;
105 int complexprefixes;
106 FLAGunsigned short compoundflag;
107 FLAGunsigned short compoundbegin;
108 FLAGunsigned short compoundmiddle;
109 FLAGunsigned short compoundend;
110 FLAGunsigned short compoundroot;
111 FLAGunsigned short compoundforbidflag;
112 FLAGunsigned short compoundpermitflag;
113 int compoundmoresuffixes;
114 int checkcompounddup;
115 int checkcompoundrep;
116 int checkcompoundcase;
117 int checkcompoundtriple;
118 int simplifiedtriple;
119 FLAGunsigned short forbiddenword;
120 FLAGunsigned short nosuggest;
121 FLAGunsigned short nongramsuggest;
122 FLAGunsigned short needaffix;
123 int cpdmin;
124 RepList* iconvtable;
125 RepList* oconvtable;
126 bool parsedmaptable;
127 std::vector<mapentry> maptable;
128 bool parsedbreaktable;
129 std::vector<std::string> breaktable;
130 bool parsedcheckcpd;
131 std::vector<patentry> checkcpdtable;
132 int simplifiedcpd;
133 bool parseddefcpd;
134 std::vector<flagentry> defcpdtable;
135 phonetable* phone;
136 int maxngramsugs;
137 int maxcpdsugs;
138 int maxdiff;
139 int onlymaxdiff;
140 int nosplitsugs;
141 int sugswithdots;
142 int cpdwordmax;
143 int cpdmaxsyllable;
144 std::string cpdvowels; // vowels (for calculating of Hungarian compounding limit,
145 std::vector<w_char> cpdvowels_utf16; //vowels for UTF-8 encoding
146 std::string cpdsyllablenum; // syllable count incrementing flag
147 const char* pfxappnd; // BUG: not stateless
148 const char* sfxappnd; // BUG: not stateless
149 int sfxextra; // BUG: not stateless
150 FLAGunsigned short sfxflag; // BUG: not stateless
151 char* derived; // BUG: not stateless
152 SfxEntry* sfx; // BUG: not stateless
153 PfxEntry* pfx; // BUG: not stateless
154 int checknum;
155 std::string wordchars; // letters + spec. word characters
156 std::vector<w_char> wordchars_utf16;
157 std::string ignorechars; // letters + spec. word characters
158 std::vector<w_char> ignorechars_utf16;
159 std::string version; // affix and dictionary file version string
160 std::string lang; // language
161 int langnum;
162 FLAGunsigned short lemma_present;
163 FLAGunsigned short circumfix;
164 FLAGunsigned short onlyincompound;
165 FLAGunsigned short keepcase;
166 FLAGunsigned short forceucase;
167 FLAGunsigned short warn;
168 int forbidwarn;
169 FLAGunsigned short substandard;
170 int checksharps;
171 int fullstrip;
172
173 int havecontclass; // boolean variable
174 char contclasses[CONTSIZE65536]; // flags of possible continuing classes (twofold
175 // affix)
176
177 public:
178 AffixMgr(const char* affpath, const std::vector<std::unique_ptr<HashMgr>>& ptr, const char* key = nullptr);
179 ~AffixMgr();
180 struct hentry* affix_check(const std::string& word,
181 int start,
182 int len,
183 const unsigned short needflag = (unsigned short)0,
184 char in_compound = IN_CPD_NOT0);
185 struct hentry* prefix_check(const std::string& word,
186 int start,
187 int len,
188 char in_compound,
189 const FLAGunsigned short needflag = FLAG_NULL0x00);
190 inline int isSubset(const char* s1, const char* s2);
191 struct hentry* prefix_check_twosfx(const std::string& word,
192 int start,
193 int len,
194 char in_compound,
195 const FLAGunsigned short needflag = FLAG_NULL0x00);
196 inline int isRevSubset(const char* s1, const char* end_of_s2, int len);
197 struct hentry* suffix_check(const std::string& word,
198 int start,
199 int len,
200 int sfxopts,
201 PfxEntry* ppfx,
202 const FLAGunsigned short cclass = FLAG_NULL0x00,
203 const FLAGunsigned short needflag = FLAG_NULL0x00,
204 char in_compound = IN_CPD_NOT0);
205 struct hentry* suffix_check_twosfx(const std::string& word,
206 int start,
207 int len,
208 int sfxopts,
209 PfxEntry* ppfx,
210 const FLAGunsigned short needflag = FLAG_NULL0x00);
211
212 std::string affix_check_morph(const std::string& word,
213 int start,
214 int len,
215 const FLAGunsigned short needflag = FLAG_NULL0x00,
216 char in_compound = IN_CPD_NOT0);
217 std::string prefix_check_morph(const std::string& word,
218 int start,
219 int len,
220 char in_compound,
221 const FLAGunsigned short needflag = FLAG_NULL0x00);
222 std::string suffix_check_morph(const std::string& word,
223 int start,
224 int len,
225 int sfxopts,
226 PfxEntry* ppfx,
227 const FLAGunsigned short cclass = FLAG_NULL0x00,
228 const FLAGunsigned short needflag = FLAG_NULL0x00,
229 char in_compound = IN_CPD_NOT0);
230
231 std::string prefix_check_twosfx_morph(const std::string& word,
232 int start,
233 int len,
234 char in_compound,
235 const FLAGunsigned short needflag = FLAG_NULL0x00);
236 std::string suffix_check_twosfx_morph(const std::string& word,
237 int start,
238 int len,
239 int sfxopts,
240 PfxEntry* ppfx,
241 const FLAGunsigned short needflag = FLAG_NULL0x00);
242
243 std::string morphgen(const char* ts,
244 int wl,
245 const unsigned short* ap,
246 unsigned short al,
247 const char* morph,
248 const char* targetmorph,
249 int level);
250
251 int expand_rootword(struct guessword* wlst,
252 int maxn,
253 const char* ts,
254 int wl,
255 const unsigned short* ap,
256 unsigned short al,
257 const char* bad,
258 int,
259 const char*);
260
261 short get_syllable(const std::string& word);
262 int cpdrep_check(const std::string& word, int len);
263 int cpdwordpair_check(const std::string& word, int len);
264 int cpdpat_check(const std::string& word,
265 size_t len,
266 hentry* r1,
267 hentry* r2,
268 const char affixed);
269 int defcpd_check(hentry*** words,
270 short wnum,
271 short maxwordnum,
272 hentry* rv,
273 hentry** rwords,
274 char all);
275 int cpdcase_check(const std::string& word, int len);
276 inline int candidate_check(const std::string& word);
277 void setcminmax(size_t* cmin, size_t* cmax, const char* word, size_t len);
278 struct hentry* compound_check(const std::string& word,
279 short wordnum,
280 short numsyllable,
281 short maxwordnum,
282 short wnum,
283 hentry** words,
284 hentry** rwords,
285 char hu_mov_rule,
286 char is_sug,
287 int* info);
288
289 int compound_check_morph(const std::string& word,
290 short wordnum,
291 short numsyllable,
292 short maxwordnum,
293 short wnum,
294 hentry** words,
295 hentry** rwords,
296 char hu_mov_rule,
297 std::string& result,
298 const std::string* partresult);
299
300 std::vector<std::string> get_suffix_words(short unsigned* suff,
301 int len,
302 const std::string& root_word);
303
304 struct hentry* lookup(const char* word, size_t len);
305 const std::vector<replentry>& get_reptable() const;
306 RepList* get_iconvtable() const;
307 RepList* get_oconvtable() const;
308 struct phonetable* get_phonetable() const;
309 const std::vector<mapentry>& get_maptable() const;
310 const std::vector<std::string>& get_breaktable() const;
311 const std::string& get_encoding();
312 int get_langnum() const;
313 const std::string& get_key_string();
314 const std::string& get_try_string() const;
315 const std::string& get_wordchars() const;
316 const std::vector<w_char>& get_wordchars_utf16() const;
317 const char* get_ignore() const;
318 const std::vector<w_char>& get_ignore_utf16() const;
319 int get_compound() const;
320 FLAGunsigned short get_compoundflag() const;
321 FLAGunsigned short get_forbiddenword() const;
322 FLAGunsigned short get_nosuggest() const;
323 FLAGunsigned short get_nongramsuggest() const;
324 FLAGunsigned short get_substandard() const;
325 FLAGunsigned short get_needaffix() const;
326 FLAGunsigned short get_onlyincompound() const;
327 const char* get_derived() const;
328 const std::string& get_version() const;
329 int have_contclass() const;
330 int get_utf8() const;
331 int get_complexprefixes() const;
332 char* get_suffixed(char) const;
333 int get_maxngramsugs() const;
334 int get_maxcpdsugs() const;
335 int get_maxdiff() const;
336 int get_onlymaxdiff() const;
337 int get_nosplitsugs() const;
338 int get_sugswithdots() const;
339 FLAGunsigned short get_keepcase() const;
340 FLAGunsigned short get_forceucase() const;
341 FLAGunsigned short get_warn() const;
342 int get_forbidwarn() const;
343 int get_checksharps() const;
344 std::string encode_flag(unsigned short aflag) const;
345 int get_fullstrip() const;
346
347 private:
348 int parse_file(const char* affpath, const char* key);
349 bool parse_flag(const std::string& line, unsigned short* out, FileMgr* af);
350 bool parse_num(const std::string& line, int* out, FileMgr* af);
351 bool parse_cpdsyllable(const std::string& line, FileMgr* af);
352 bool parse_convtable(const std::string& line,
353 FileMgr* af,
354 RepList** rl,
355 const std::string& keyword);
356 bool parse_phonetable(const std::string& line, FileMgr* af);
357 bool parse_maptable(const std::string& line, FileMgr* af);
358 bool parse_breaktable(const std::string& line, FileMgr* af);
359 bool parse_checkcpdtable(const std::string& line, FileMgr* af);
360 bool parse_defcpdtable(const std::string& line, FileMgr* af);
361 bool parse_affix(const std::string& line, const char at, FileMgr* af, char* dupflags);
362
363 void reverse_condition(std::string&);
364 std::string& debugflag(std::string& result, unsigned short flag);
365 int condlen(const std::string& s);
366 int encodeit(AffEntry& entry, const std::string& cs);
367 int build_pfxtree(PfxEntry* pfxptr);
368 int build_sfxtree(SfxEntry* sfxptr);
369 int process_pfx_order();
370 int process_sfx_order();
371 PfxEntry* process_pfx_in_order(PfxEntry* ptr, PfxEntry* nptr);
372 SfxEntry* process_sfx_in_order(SfxEntry* ptr, SfxEntry* nptr);
373 int process_pfx_tree_to_list();
374 int process_sfx_tree_to_list();
375 int redundant_condition(char, const std::string& strip, const std::string& cond, int);
376 void finishFileMgr(FileMgr* afflst);
377};
378
379#endif