Commit Graph
197 Commits
Author SHA1 Message Date
serge-sans-paille 03b0f2574c Bug 2040876 - Activate modernize-use-bool-literals clang-tidy check r=emilio,webrtc-reviewers,cookie-reviewers,places-reviewers,layout-reviewers,mak,bwc
Differential Revision: https://phabricator.services.mozilla.com/D301473
2026-05-25 21:13:49 +00:00
serge-sans-paille f81328e365 Bug 2023519 - Make our codebase modernize-use-equals-default + modernize-use-equals-delete -safe wrt. clang-tidy r=sylvestre,necko-reviewers,media-playback-reviewers,profiler-reviewers,dom-storage-reviewers,layout-reviewers,dom-worker-reviewers,valentin,jesup,padenot,edenchuang,emilio
The changeset has been generated automatically through:

    ./mach static-analysis check --output ./clang-tidy-bugprone.json --format json --fix

followed by manual adjustment when needed or when the auto-fixer bailed out.

This paves the way for Bug 2023527

Differential Revision: https://phabricator.services.mozilla.com/D287941
2026-03-22 08:35:47 +00:00
Alexandru Marc 04e5f74151 Revert "Bug 2023519 - Make our codebase modernize-use-equals-default + modernize-use-equals-delete -safe wrt. clang-tidy r=sylvestre,necko-reviewers,media-playback-reviewers,profiler-reviewers,dom-storage-reviewers,layout-reviewers,dom-worker-reviewers,valentin,jesup,padenot,edenchuang,emilio"
This reverts commit a64dec2665.
2026-03-19 17:29:58 +00:00
serge-sans-paille a64dec2665 Bug 2023519 - Make our codebase modernize-use-equals-default + modernize-use-equals-delete -safe wrt. clang-tidy r=sylvestre,necko-reviewers,media-playback-reviewers,profiler-reviewers,dom-storage-reviewers,layout-reviewers,dom-worker-reviewers,valentin,jesup,padenot,edenchuang,emilio
The changeset has been generated automatically through:

    ./mach static-analysis check --output ./clang-tidy-bugprone.json --format json --fix

followed by manual adjustment when needed or when the auto-fixer bailed out.

This paves the way for Bug 2023527

Differential Revision: https://phabricator.services.mozilla.com/D287941
2026-03-18 17:25:01 +00:00
Sylvestre Ledru f7691d9032 Bug 2023419 - Remove Emacs/Vim modelines from memory/ r=emilio
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287854
2026-03-17 12:05:51 +00:00
serge-sans-paille 9dece22663 Bug 1991455 - Harmonize __builin_(add|sub|mul)_overflow usage r=emilio,nbp,profiler-reviewers,canaltinova
We used to have __builtin_(...) wrapped as MOZ_ADD_OVERFLOW, SafeAdd or
used directly. Get rid of MOZ_ADD_OVERFLOW, promotes SafeAdd et cie to
mfbt and use the mfbt version everywhere.

Differential Revision: https://phabricator.services.mozilla.com/D266685
2025-10-02 05:14:07 +00:00
serge-sans-paille 77667f23c9 Bug 1990262 - Obsolete mozilla::MulOverflowMask r=emilio,profiler-reviewers,canaltinova
Promote usage of __builtin_mul_overflow instead, which is supported by
all the compilers we support.

Differential Revision: https://phabricator.services.mozilla.com/D265839
2025-09-25 21:13:23 +00:00
serge-sans-paille aeee883896 Bug 1986593 - Obsolete mfbt/TemplateLib.h r=emilio,webrtc-reviewers,profiler-reviewers,layout-reviewers,canaltinova
The content of TemplateLib can be obsoleted in favor of constexpr
functions already available in mfbt/MathAlgorithms.h

- tl::Max -> std::max(x, y) or std::max({x, y, z})
- tl::Min -> std::min(x, y) or std::min({x, y, z})
- tl::FloorLog2<X>::value -> mozilla::FloorLog2(X)
- tl::CeilLog2<X>::value -> mozilla::CeilLog2(X)
- tl::RoundUpPow2<X>::value -> mozilla::RoundUpPow2(X)
- tl::BitSize<X>::value -> std::numeric_limits<X>::digits (for unsigned integral types)
- tl::MulOverflowMask<X>::value -> mozilla::MulOverflowMask(X)

the latter has been moved to mfbt/MulOverflowMask.h because it's used in
mozalloc.h and is required to have few dependencies.

also drop Windows specific code as we always build windows target with
clang-cl or mingw

Please note that the implementation of tl::CeilLog2 was incorrect for
very large numbers (typically 2**64 - 1), which impacted MulOverflowMask for those values.

This patch fixes that behavior and test it.

Differential Revision: https://phabricator.services.mozilla.com/D263523
2025-09-05 06:08:21 +00:00
Atila Butkovits 3fcad999e4 Revert "Bug 1986593 - Obsolete mfbt/TemplateLib.h r=emilio,webrtc-reviewers,profiler-reviewers,layout-reviewers,canaltinova" for causing bustages at FuzzingTraits.
This reverts commit 1a8ee563a7.
2025-09-05 00:31:46 +00:00
serge-sans-paille 1a8ee563a7 Bug 1986593 - Obsolete mfbt/TemplateLib.h r=emilio,webrtc-reviewers,profiler-reviewers,layout-reviewers,canaltinova
The content of TemplateLib can be obsoleted in favor of constexpr
functions already available in mfbt/MathAlgorithms.h

- tl::Max -> std::max(x, y) or std::max({x, y, z})
- tl::Min -> std::min(x, y) or std::min({x, y, z})
- tl::FloorLog2<X>::value -> mozilla::FloorLog2(X)
- tl::CeilLog2<X>::value -> mozilla::CeilLog2(X)
- tl::RoundUpPow2<X>::value -> mozilla::RoundUpPow2(X)
- tl::BitSize<X>::value -> std::numeric_limits<X>::digits (for unsigned integral types)
- tl::MulOverflowMask<X>::value -> mozilla::MulOverflowMask(X)

the latter has been moved to mfbt/MulOverflowMask.h because it's used in
mozalloc.h and is required to have few dependencies.

also drop Windows specific code as we always build windows target with
clang-cl or mingw

Please note that the implementation of tl::CeilLog2 was incorrect for
very large numbers (typically 2**64 - 1), which impacted MulOverflowMask for those values.

This patch fixes that behavior and test it.

Differential Revision: https://phabricator.services.mozilla.com/D263523
2025-09-04 23:34:17 +00:00
Sandor Molnar cf2854bd7e Revert "Bug 1986593 - Obsolete mfbt/TemplateLib.h r=emilio,webrtc-reviewers,profiler-reviewers,layout-reviewers,canaltinova" for causing build bustages
This reverts commit 05a72e4b10.
2025-09-04 07:47:30 +00:00
serge-sans-paille 05a72e4b10 Bug 1986593 - Obsolete mfbt/TemplateLib.h r=emilio,webrtc-reviewers,profiler-reviewers,layout-reviewers,canaltinova
The content of TemplateLib can be obsoleted in favor of constexpr
functions already available in mfbt/MathAlgorithms.h

- tl::Max -> std::max(x, y) or std::max({x, y, z})
- tl::Min -> std::min(x, y) or std::min({x, y, z})
- tl::FloorLog2<X>::value -> mozilla::FloorLog2(X)
- tl::CeilLog2<X>::value -> mozilla::CeilLog2(X)
- tl::RoundUpPow2<X>::value -> mozilla::RoundUpPow2(X)
- tl::BitSize<X>::value -> std::numeric_limits<X>::digits (for unsigned integral types)
- tl::MulOverflowMask<X>::value -> mozilla::MulOverflowMask(X)

the latter has been moved to mfbt/MulOverflowMask.h because it's used in
mozalloc.h and is required to have few dependencies.

also drop Windows specific code as we always build windows target with
clang-cl or mingw

Please note that the implementation of tl::CeilLog2 was incorrect for
very large numbers (typically 2**64 - 1), which impacted MulOverflowMask for those values.

This patch fixes that behavior and test it.

Differential Revision: https://phabricator.services.mozilla.com/D263523
2025-09-04 05:43:25 +00:00
Sylvestre Ledru e19d8da8b9 Bug 1856795 - ride along: use = default; on some recently modified files r=emilio
More on:
https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html

Command:
L=$(hg export -r tip|grep +++|cut -d/ -f2-)
./mach static-analysis check --checks="-*, modernize-use-equals-default" --fix $L

Differential Revision: https://phabricator.services.mozilla.com/D191016
2023-10-15 15:29:03 +00:00
Sylvestre Ledru b0fe72dee5 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-15 15:29:02 +00:00
Cristina Horotan 7388749830 Backed out 2 changesets (bug 1856795) for causing build bustage at BasicEvents.h CLOSED TREE
Backed out changeset 1d98b028923a (bug 1856795)
Backed out changeset eae2ac93e17c (bug 1856795)
2023-10-14 21:42:14 +03:00
Sylvestre Ledru ba5da021b1 Bug 1856795 - ride along: use = default; on some recently modified files r=emilio
More on:
https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html

Command:
L=$(hg export -r tip|grep +++|cut -d/ -f2-)
./mach static-analysis check --checks="-*, modernize-use-equals-default" --fix $L

Differential Revision: https://phabricator.services.mozilla.com/D191016
2023-10-14 17:34:27 +00:00
Sylvestre Ledru 4a97019e39 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-14 17:34:26 +00:00
Nazım Can Altınova cadadfed6c Bug 1779257 - Fix the stack walking for linux markers by calling getcontext in a valid stack frame r=mstange
See my comment on here for more context of my investigation:
https://bugzilla.mozilla.org/show_bug.cgi?id=1779257#c9

The saved context is invalid once the function that called `getcontext`
returns. We need to call the `getcontext` while the frame where we called it is
still on the stack. That's why this patch is moving the call to `getcontext` to
parent function by inlining the SyncPopulate content by using a macro instead.
This has to be a macro instead of a function because stack pointer address will
be invalid once the `Registers::SyncPopulate` returns. I tried to change this
method to inline but that didn't help either.

Differential Revision: https://phabricator.services.mozilla.com/D170133
2023-02-22 19:57:08 +00:00
Robert Longson b37d689021 Bug 1799630 - replace sprintf by snprintf or SprintfLiteral r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D161573
2022-11-10 07:01:11 +00:00
Csoregi Natalia 239cc57e22 Backed out changeset 53c18b7903db (bug 1799630) for causing hybrid bustages on CocoaGamepad.cpp. CLOSED TREE 2022-11-10 01:27:08 +02:00
Robert Longson 2a14a5c47e Bug 1799630 - replace sprintf by snprintf or SprintfLiteral r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D161573
2022-11-09 20:00:18 +00:00
Mike Hommey 9ea85c709a Bug 1730030 - Replace some assembly with corresponding compiler builtins. r=gerald
This has the side-effect of adding the missing arm64 mac support for PHC.

Differential Revision: https://phabricator.services.mozilla.com/D125139
2021-09-10 00:58:34 +00:00
Mike Hommey 16a6780390 Bug 1515229 - Make MozStackWalk/MozWalkTheStack frame skipping more reliable. r=gerald,nika,bobowen,jld
Differential Revision: https://phabricator.services.mozilla.com/D110899
2021-04-16 04:06:02 +00:00
Butkovits Atila eef3398681 Backed out changeset 5c6b15fcea71 (bug 1515229) for causing GTest failures. CLOSED TREE 2021-04-15 13:37:29 +03:00
Mike Hommey 4cb614c7fd Bug 1515229 - Make MozStackWalk/MozWalkTheStack frame skipping more reliable. r=gerald,nika,bobowen,jld
Differential Revision: https://phabricator.services.mozilla.com/D110899
2021-04-14 22:31:36 +00:00
smolnar 5677d60f99 Backed out changeset f7b0cdc3aeb0 (bug 1515229) for causing xpc failures in test_feature_stackwalking. CLOSED TREE 2021-04-14 12:25:37 +03:00
Mike Hommey 97611636d9 Bug 1515229 - Make MozStackWalk/MozWalkTheStack frame skipping more reliable. r=gerald,nika,bobowen,jld
Differential Revision: https://phabricator.services.mozilla.com/D110899
2021-04-14 04:47:09 +00:00
Mike Hommey 9f5237e990 Bug 1699321 - Avoid DMD crashes on Windows debug builds. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D109425
2021-03-22 22:50:25 +00:00
Mike Hommey 3d672d3126 Bug 1698719 - Remove aSkipFrames argument to both FramePointerStackWalk and MozStackWalkThread. r=gsvelto,gerald
In the case of FramePointerStackwalk, the caller gives a pointer to the
top-most frame to walk from. There isn't really a reason to give a
number of frames to skip, as the right frame pointer could be given in
the first place if that was really necessary. And in practice, it's
hasn't been used so far.

In the case of MozStackWalkThread, the caller presumably doesn't know
what the thread the stack is being walked for is doing, and it would be
a guesswork to pass a valid number of frames to skip. In practice, it's
also not used.

The aSkipFrames is already a footgun on MozStackWalk (and we're going to
change that in bug 1515229), we don't need to keep a footgun on these
other stack walking methods.

Differential Revision: https://phabricator.services.mozilla.com/D108563
2021-03-17 00:21:39 +00:00
Gerald Squelart 6f1a2b86ca Bug 1657033 - Use Span<const char> in JSONWriter - r=froydnj
In most situations, JSONWriter users already know string lengths (either directly, or through `nsCString` and friends), so we should keep this information through JSONWriter and not recompute it again.
This also allows using JSONWriter with sub-strings (e.g., from a bigger buffer), without having to create null-terminated strings.

Public JSONWriter functions have overloads that accept literal strings.

Differential Revision: https://phabricator.services.mozilla.com/D86192
2020-09-14 02:33:20 +00:00
Sylvestre Ledru 566b0a40a9 Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D88713
2020-08-31 09:23:02 +00:00
Mihai Alexandru Michis 6a428d0e94 Backed out changeset d0f173a90792 (bug 1519636) for causing bustages.
CLOSED TREE
2020-08-31 10:14:58 +03:00
Sylvestre Ledru 2d72566921 Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D88713
2020-08-31 06:51:21 +00:00
Nathan Froyd 53b2fb596a Bug 1658424 - add support for grabbing fp on arm64 macOS in DMD; r=mccr8
This code just cribs from the profiler's code and has not been tested.

Differential Revision: https://phabricator.services.mozilla.com/D86647
2020-08-11 14:09:28 +00:00
Sylvestre Ledru 7ce0fa396d Bug 1649071 - Replace the DISALLOW_COPY_AND_ASSIGN & DISALLOW_EVIL_CONSTRUCTORS macros with = delete; r=froydnj
Generated with:
./mach static-analysis check --checks="-*, modernize-replace-disallow-copy-and-assign-macro" --fix -j 10 <file>
and
./mach clang-format -p <file>
(as clang-apply-replacement doesn't reformat the change)

(with ~/.mozbuild/clang-tools/clang-tidy/bin/clang-tidy pointing to clang-tidy 11)

Differential Revision: https://phabricator.services.mozilla.com/D81489
2020-06-29 14:37:56 +00:00
Cameron McCormack 150ec1ea8e Bug 1053379 - Simplify CodeAddressService so non-DMD users can rely on defaults. r=njn
None of the StringTable implementations were freeing their strdup'd
strings, either.

Differential Revision: https://phabricator.services.mozilla.com/D40757
2019-08-06 21:58:12 +00:00
Nicholas Nethercote eb80622e74 Bug 1533240 - Replace DMD's custom TLS code with use of mozilla/ThreadLocal.h. r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D22448
2019-03-22 20:07:30 +00:00
Gurzau Raul 9411dbf44f Backed out changeset 46f6705f9c0c (bug 1533240) for xpcshell failures at /test/test_dmd.js on a CLOSED TREE. 2019-03-14 07:03:38 +02:00
Nicholas Nethercote e1cf97e010 Bug 1533240 - Replace DMD's custom TLS code with use of mozilla/ThreadLocal.h. r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D22448
2019-03-14 01:05:15 +00:00
Ryan Hunt 399e0bbe0e Bug 1523969 part 16 - Move method definition inline comments to new line in 'memory/'. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D21117
2019-02-25 16:10:15 -06:00
Nicholas Nethercote 7d4a7f57fe Bug 1531027 - Add an explicit copy constructor to StackTrace. r=ehsan
This only copies the first `mLength` elements in `mPcs`.

Differential Revision: https://phabricator.services.mozilla.com/D21488
2019-02-28 11:00:14 +11:00
Ehsan Akhgari caf8292488 Bug 1531027 - Make InfallibleAllocPolicy::new_ accept its argument as a reference; r=njn
Differential Revision: https://phabricator.services.mozilla.com/D21486
2019-02-28 06:41:09 +00:00
Nicholas Nethercote 5945f22a43 Bug 1529452 - Fix a silly bug. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D20772
2019-02-22 10:52:03 +00:00
Nicholas Nethercote 1e7693acff Bug 1529452 - Avoid a multiplication that could overflow. r=glandium
Also add a comment about another multiplication.

Differential Revision: https://phabricator.services.mozilla.com/D20617
2019-02-21 04:28:15 +00:00
Masatoshi Kimura 88805f267f Bug 1528651 - Fix some trivial warnings and re-enable warnings-as-errors on Windows in some directories. r=dmajor 2019-02-19 20:42:11 +09:00
Ehsan Akhgari 498e2df734 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
# ignore-this-changeset
2019-01-18 10:16:18 +01:00
Sylvestre Ledru e5a134f73a Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset
2018-11-30 11:46:48 +01:00
Noemi Erli 1190b84a56 Backed out changeset bee1c344cb47 (bug 1491909) for failures in browser/components/extensions/test/xpcshell/test_ext_geckoProfiler_control.js 2018-10-24 04:23:13 +03:00
Denis Palmeiro ebd8dc794c Bug 1491909 - Add an AllocPolicy to mozilla::JSONWriter r=jwalden,mstange
JSONWriter currently calls new and delete indirectly through mozilla::MakeUnique to allocate a buffer.  Becuase of this, the methods of this class cannot be invoked within Spidermonkey due to https://searchfox.org/mozilla-central/source/config/check_vanilla_allocations.py#6-14.  Therefore, JSONWriter needs an AllocPolicy template parameter so that the allocation and deallocation routines can be changed to match the JS AllocPolicy when invoked within SpiderMonkey.

Differential Revision: https://phabricator.services.mozilla.com/D7279
2018-10-23 20:46:31 +00:00
Nicholas Nethercote 439d31614d Bug 1481998 - Make mozilla::Hash{Map,Set}'s entry storage allocation lazy. r=luke,sfink
Entry storage allocation now occurs on the first lookupForAdd()/put()/putNew().
This removes the need for init() and initialized(), and matches how
PLDHashTable/nsTHashtable work. It also removes the need for init() functions
in a lot of types that are built on top of mozilla::Hash{Map,Set}.

Pros:

- No need for init() calls and subsequent checks.

- No memory allocated for empty tables, which are not that uncommon.

Cons:

- An extra branch in lookup() and lookupForAdd(), but not in put()/putNew(),
  because the existing checkOverloaded() can handle it.

Specifics:

- Construction now can take a length parameter.

- init() is removed. Explicit length-setting, when necessary, now occurs in the
  constructors.

- initialized() is removed.

- capacity() now returns zero when the entry storage is absent.

- lookupForAdd() is no longer `const`, because it can instantiate the storage,
  which requires modifications.

- lookupForAdd() can now return an invalid AddPtr in two cases:

  - old: hashing failure (due to OOM in the hasher)

  - new: OOM while instantiating entry storage

  The existing failure handling paths for the old case work for the new case.

- clear(), finish(), and clearAndShrink() are replaced by clear(), compact(),
  and reserve(). The old compactIfUnderloaded() is also removed.

- Capacity computation code is now in its own functions, bestCapacity() and
  hashShift(). setTableSizeLog2() is removed.

- uint32_t is used throughout for capacities, instead of size_t, for
  consistency with other similar values.

- changeTableSize() now takes a capacity instead of a deltaLog2, and it can now
  handle !mTable.

Measurements:

- Total source code size is reduced by over 900 lines. Also, lots of existing
  lines got shorter (i.e. two checks were reduced to one).

- Executable size barely changed, down by 2 KiB on Linux64. The extra branches
  are compensated for by the lack of init() calls.

- Speed changed negligibly. The instruction count for Bench_Cpp_MozHash
  increased from 2.84 billion to 2.89 billion but any execution time change was
  well below noise.
2018-08-10 18:00:29 +10:00