Commit Graph

54 Commits

Author SHA1 Message Date
Simon Giesecke
dd80614fa0 Bug 1678062 - Remove unnecessary includes. r=andi
Differential Revision: https://phabricator.services.mozilla.com/D97467

Depends on D96561
2020-11-23 16:12:02 +00:00
Gerald Squelart
89b62c22de Bug 1657033 - Make MakeStringSpan constexpr - r=froydnj
MakeStringSpan("...") will be able to construct spans from string literals at compile time.

Differential Revision: https://phabricator.services.mozilla.com/D86190
2020-09-14 01:44:39 +00:00
Simon Giesecke
1a9da56b94 Bug 1653335 - Get rid of MakeSpan functions. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D83818
2020-08-07 07:50:04 +00:00
Simon Giesecke
48dd75b228 Bug 1653335 - Add/fix constructors and deduction guides for Span. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D83813
2020-08-07 07:42:52 +00:00
Simon Giesecke
273b5b9fd1 Bug 1649704 - Improve consistency of Span's span_iterator comparison. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D81827
2020-07-02 13:46:01 +00:00
Sylvestre Ledru
63be8d152d Bug 1519636 - Reformat recent changes to the Google coding style r=necko-reviewers,dragana
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D77580
2020-05-30 09:55:27 +00:00
Nathan Froyd
5416a2fae6 Bug 1635359 - remove bounds checks on trivial span_iterator construction; r=sg
There's no need to provide the compiler a bunch of stuff that it's
trivially going to optimize away anyway, and we'd rather the release
assert not mess with the optimizer's view of the code.

Differential Revision: https://phabricator.services.mozilla.com/D77124
2020-05-28 11:17:42 +00:00
Nathan Froyd
9dcf479947 Bug 1635359 - provide a private constructor for span_iterator to bypass bounds checks; r=sg
The compiler is not always able to remove these (always-successful)
checks, so we might as well help it along.

Depends on D77122

Differential Revision: https://phabricator.services.mozilla.com/D77123
2020-05-28 10:05:38 +00:00
Nathan Froyd
1dc3de3520 Bug 1635359 - rename Span type parameter for span_iterator; r=sg
We're going to introduce some friend declarations in the next patch, and
this change makes doing so easier.  It's also slightly less confusing.

Depends on D77121

Differential Revision: https://phabricator.services.mozilla.com/D77122
2020-05-28 10:03:06 +00:00
Nathan Froyd
f747ca618f Bug 1635359 - remove release asserts for span_iterator {de,in}crement; r=sg
These are redundant with the checks that we already have for dereferencing.

Depends on D77120

Differential Revision: https://phabricator.services.mozilla.com/D77121
2020-05-28 09:56:06 +00:00
Nathan Froyd
9c05dc1217 Bug 1635359 - eliminate release assert in const span_iterator construction; r=sg
Differential Revision: https://phabricator.services.mozilla.com/D77120
2020-05-28 09:54:37 +00:00
Simon Giesecke
f07c441f41 Bug 1636114 - Add Span::AsConst method. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D74232
2020-05-11 09:27:40 +00:00
Simon Giesecke
74b75d282b Bug 1634023 - Add deduction guides for Span. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D73040
2020-04-29 16:04:56 +00:00
Simon Giesecke
8f5212cd79 Bug 1634014 - Allow Span to be created from two Span iterators. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D73039
2020-04-29 15:20:50 +00:00
Simon Giesecke
46314aa8d2 Bug 1633350 - Add SplitAt method to mozilla::Span. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D72605
2020-04-27 11:16:30 +00:00
Simon Giesecke
e8a20bbe1c Bug 1633350 - Add deduction guide for constructing Span from a plain array. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D72604
2020-04-27 16:46:57 +00:00
André Bargull
14ca007916 Bug 1625138 - Part 41: Remove no longer needed includes for mozilla/TypeTraits. r=froydnj
Also adds missing includes in some files, these were previously only transivitely
included through mozilla/TypeTraits.h.

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

--HG--
extra : moz-landing-system : lando
2020-03-28 16:00:09 +00:00
André Bargull
5992327185 Bug 1625138 - Part 36: Replace mozilla::IsSame with std::is_same in mfbt/. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68555

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:20 +00:00
André Bargull
2712714d84 Bug 1625138 - Part 35: Replace mozilla::TrueType with std::true_type. r=froydnj,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D68554

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:20 +00:00
André Bargull
f8eb4c162e Bug 1625138 - Part 34: Replace mozilla::FalseType with std::false_type. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68553

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:20 +00:00
André Bargull
9de017ffb8 Bug 1625138 - Part 33: Replace mozilla::IntegralConstant with std::integral_constant. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68552

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:19 +00:00
André Bargull
32cb16fc45 Bug 1625138 - Part 32: Replace mozilla::RemoveConst with std::remove_const. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68551

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:19 +00:00
André Bargull
cf0b1e89e9 Bug 1625138 - Part 30: Replace mozilla::RemoveCV with std::remove_cv. r=froydnj,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D68547

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:18 +00:00
André Bargull
42d4ebbda9 Bug 1625138 - Part 27: Replace mozilla::DeclVal with std::declval. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68545

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:18 +00:00
André Bargull
cae4e1fdbc Bug 1606962: Replace mozilla::EnableIf with std::enable_if. r=froydnj,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D68401

--HG--
extra : moz-landing-system : lando
2020-03-28 13:35:31 +00:00
André Bargull
1be056677a Bug 1625138 - Part 26: Replace mozilla::Conditional with std::conditional. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68381

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:18 +00:00
André Bargull
08a8c3fc78 Bug 1625138 - Part 24: Replace mozilla::IsConvertible with std::is_convertible. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68379

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:17 +00:00
André Bargull
b2e7397c33 Bug 1625138 - Part 18: Replace mozilla::AddPointer with std::add_pointer. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68373

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:16 +00:00
André Bargull
907be0b57b Bug 1625138 - Part 11: Replace mozilla::IsConst with std::is_const. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68365

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:14 +00:00
Simon Giesecke
ad6c02c994 Bug 1613985 - Use default for equivalent-to-default constructors/destructors in mfbt. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D62542

--HG--
extra : moz-landing-system : lando
2020-02-13 11:20:27 +00:00
Mihai Alexandru Michis
395eb2050d Backed out changeset f3d9fbb2daf1 (bug 1613985) for causing hazard bustages on Linux.
CLOSED TREE
2020-02-12 16:43:30 +02:00
Simon Giesecke
066ea869b7 Bug 1613985 - Use default for equivalent-to-default constructors/destructors in mfbt. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D62542

--HG--
extra : moz-landing-system : lando
2020-02-12 11:13:24 +00:00
Emilio Cobos Álvarez
256c124f94 Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:

This was done by applying:

```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
         from subprocess import Popen, PIPE, check_output, CalledProcessError

         diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
-        args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+        args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']

         if not output_file:
             args.append("-i")
```

Then running `./mach clang-format -c <commit-hash>`

Then undoing that patch.

Then running check_spidermonkey_style.py --fixup

Then running `./mach clang-format`

I had to fix four things:

 * I needed to move <utility> back down in GuardObjects.h because I was hitting
   obscure problems with our system include wrappers like this:

0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94              ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94     MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94                                ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)

   Which I really didn't feel like digging into.

 * I had to restore the order of TrustOverrideUtils.h and related files in nss
   because the .inc files depend on TrustOverrideUtils.h being included earlier.

 * I had to add a missing include to RollingNumber.h

 * Also had to partially restore include order in JsepSessionImpl.cpp to avoid
   some -WError issues due to some static inline functions being defined in a
   header but not used in the rest of the compilation unit.

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

--HG--
extra : moz-landing-system : lando
2020-01-20 16:19:48 +00:00
Emilio Cobos Álvarez
aa3a695712 Bug 1609996 - Remove mozilla/Move.h. r=froydnj
rg -l 'mozilla/Move.h' | xargs sed -i 's/#include "mozilla\/Move.h"/#include <utility>/g'

Further manual fixups and cleanups to the include order incoming.

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

--HG--
extra : moz-landing-system : lando
2020-01-20 16:18:20 +00:00
Emilio Cobos Álvarez
278b36aafb Bug 1607816 - Replace mozilla::{Max, Min}Value with std::numeric_limits. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D59153

--HG--
extra : moz-landing-system : lando
2020-01-08 16:30:40 +00:00
Manish Goregaokar
52a09d5497 Bug 1602105: Mention default value of Span<T, Extent>'s extent; r=perry
MozReview-Commit-ID: 5h8zGik856o

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

--HG--
extra : moz-landing-system : lando
2019-12-06 21:02:28 +00:00
Adrian Wielgosik
c763074930 Bug 1583953 - avoid assert-heavy iterators in Span comparisons. r=jwalden
This lets us avoid pointlessly checking release assertions in a safe comparison loop.
In particular, for Span<char>, this lets the compiler use memcmp, speeding up comparisons by over an order of magnitude.

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

--HG--
extra : moz-landing-system : lando
2019-10-04 02:08:11 +00:00
Henri Sivonen
95fecf7af4 Bug 1577700 - Add a function for obtaining a Span of char from a Span of uint8_t. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D44124

--HG--
extra : moz-landing-system : lando
2019-08-30 13:16:19 +00:00
Sylvestre Ledru
645f2d5773 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2019-08-13 07:15:25 +00:00
Nathan Froyd
8a524a8529 Bug 1567944 - remove MSVC-specific warning goo from {Vector,Span}.h; r=dmajor
We don't support MSVC anymore, and clang-cl just ignores these pragmas.

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

--HG--
extra : moz-landing-system : lando
2019-07-23 09:24:28 +00:00
Ehsan Akhgari
e5e885ae31 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
# ignore-this-changeset

--HG--
extra : amend_source : 7221c8d15a765df71171099468e7c7faa648f37c
extra : histedit_source : a0cce6015636202bff09e35a13f72e03257a7695
2019-01-18 10:16:18 +01:00
Sylvestre Ledru
265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Ehsan Akhgari
ca162bee20 Bug 1508472 - Part 4: Fourth batch of comment fix-ups in preparation for the tree reformat r=sylvestre
This is a best effort attempt at ensuring that the adverse impact of
reformatting the entire tree over the comments would be minimal.  I've used a
combination of strategies including disabling of formatting, some manual
formatting and some changes to formatting to work around some clang-format
limitations.

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

--HG--
extra : moz-landing-system : lando
2018-11-28 09:16:55 +00:00
Henri Sivonen
c3fcb6ab2c Bug 1466475 - Make mozilla::Span produce aligned bogus pointers per new Rust rules. r=froydnj
MozReview-Commit-ID: JFVSRu53Geh

--HG--
extra : rebase_source : a9436aef554b6e892195324744f135d2b65086d5
2018-06-04 12:59:46 +03:00
Emilio Cobos Álvarez
1e9c395548 Bug 1466168: Remove mozilla::Forward in favor of std::forward. r=froydnj
Same approach as the other bug, mostly replacing automatically by removing
'using mozilla::Forward;' and then:

  s/mozilla::Forward/std::forward/
  s/Forward</std::forward</

The only file that required manual fixup was TestTreeTraversal.cpp, which had
a class called TestNodeForward with template parameters :)

MozReview-Commit-ID: A88qFG5AccP
2018-06-02 09:33:26 +02:00
Masatoshi Kimura
caada858fb Bug 1451722 - Constexpr-ify mozilla::Span more. r=hsivonen
MozReview-Commit-ID: B7sxH5BAdp6

--HG--
extra : rebase_source : 3e7bf5424478cdff6dfd1c25b9808a41cfb6e0d3
2018-04-05 21:55:00 +09:00
Henri Sivonen
5f81ea7f50 Bug 1448591 - Make MakeStringSpan(nullptr) return an empty span. r=froydnj.
MozReview-Commit-ID: EyuLeWjEL7w

--HG--
extra : rebase_source : a40b671692db0e7faa7772654cb4b1ae75bd30a2
2018-03-24 21:36:00 +02:00
Masatoshi Kimura
456098425e Bug 1424103 - constexpr-ify mozilla::Span. r=hsivonen
MozReview-Commit-ID: 4e98Aer9V1k

--HG--
extra : rebase_source : 44f87677a4918aea4abaf2721895e48045267c7b
2017-12-08 23:20:56 +09:00
Chris Peterson
7bbe4a40e6 Bug 1405582 - Span: avoid repeated calls to size(). r=hsivonen
MozReview-Commit-ID: BKFrbvEt57l

--HG--
extra : rebase_source : 9aeb6fd018da5b8623f14ab927bd786c29ae56ae
extra : source : c5bedfde8b9dc2929fc14cfc2dc816e5f08b4ad8
2017-09-19 13:18:38 -07:00
Chris Peterson
a48326552c Bug 1405582 - Span: delete implicit constructors for char* and char16_t*. r=froydnj,hsivonen
Delete Span's implicit constructors for char* and char16_t* pointers to avoid accidental construction in cases where a pointer does not point to a zero-terminated string. Use the MakeStringSpan() function instead.

I deleted both the const and non-const char* and char16_t* constructors, in the name of cross-compiler consistency. If we only delete the const char* and char16_t* constructors, for some reason, MSVC complains that `Span<char> s(charArray)` uses a deleted constructor while clang nor gcc permit it. I don't know if this is a compiler bug in MSVC or clang and gcc.

Also, do not permit MakeSpan() for string literals (const char and char16_t arrays) because the Span length would include the zero terminator, which may surprise callers. Use MakeStringSpan() to create a Span whose length that excludes the string literal's zero terminator or use the MakeSpan() overload that accepts a pointer and length and specify the string literal's full length.

The following Span usages are prevented:

  Span<const char> span("literal"); // error
  Span<char> span(charArray); // error

  Span<const char> span;
  span = "literal"; // error
  span = charArray; // error

  MakeSpan("literal"); // error

The following Span usages are still permitted:

  assert(MakeStringSpan("literal") == 8); // OK: span length is calculated with strlen() and excludes the zero terminator
  MakeStringSpan(charArray); // OK: span length is calculated with strlen() and excludes the zero terminator
  MakeSpan(charArray); // OK: span length is the char array size including any zero terminator

MozReview-Commit-ID: Et71CpjsiyI

--HG--
extra : rebase_source : f6f8bdb28726f0f2368fdfdd039fb1d7dcf2914e
extra : source : 0547d8924ffc7713d6cf32cc06eeeaf00e0d69a3
2017-09-20 00:38:07 -07:00