gecko-dev/mfbt/tests
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
..
gtest Bug 1405582 - Span: delete implicit constructors for char* and char16_t*. r=froydnj,hsivonen 2017-09-20 00:38:07 -07:00
TestArray.cpp
TestArrayUtils.cpp
TestAtomics.cpp
TestBinarySearch.cpp
TestBloomFilter.cpp
TestBufferList.cpp
TestCasting.cpp
TestCeilingFloor.cpp
TestCheckedInt.cpp
TestCountPopulation.cpp
TestCountZeroes.cpp
TestDefineEnum.cpp Bug 1371771 - Add a MOZ_DEFINE_ENUM macro and variants to MFBT. r=froydnj 2017-06-30 19:58:11 -04:00
TestDoublyLinkedList.cpp Bug 1396723 - Simplify the trait users of DoublyLinkedList need to define. r=froydnj 2017-09-02 08:09:58 +09:00
TestEndian.cpp
TestEnumSet.cpp
TestEnumTypeTraits.cpp
TestEnumeratedArray.cpp
TestFastBernoulliTrial.cpp
TestFloatingPoint.cpp
TestIntegerPrintfMacros.cpp Bug 1349957 Change reference (in disabled code) to new/correct member r=froydnj 2017-03-23 10:27:25 -05:00
TestIntegerRange.cpp
TestJSONWriter.cpp
TestLinkedList.cpp
TestMacroArgs.cpp Bug 1369622 - Fix MOZ_FOR_EACH with an empty list. r=froydnj 2017-06-02 14:53:54 +09:00
TestMacroForEach.cpp Bug 1369622 - Fix MOZ_FOR_EACH with an empty list. r=froydnj 2017-06-02 14:53:54 +09:00
TestMathAlgorithms.cpp
TestMaybe.cpp
TestNotNull.cpp
TestPair.cpp
TestPoisonArea.cpp Bug 1158445 - posix_madvise() should be used instead of madvise on Solaris. r=froydnj, r=jandem 2017-06-09 00:59:32 -07:00
TestRange.cpp
TestRefPtr.cpp
TestResult.cpp Bug 1325073 - Rename mozilla::MakeGenericErrorResult to mozilla::Err. r=Waldo 2017-03-08 13:33:07 +00:00
TestRollingMean.cpp
TestSHA1.cpp
TestSaturate.cpp
TestScopeExit.cpp
TestSegmentedVector.cpp Bug 1358761 - dummy handling for return values in test, r=bustage 2017-05-05 10:43:37 +03:00
TestSmallPointerArray.cpp Bug 1397056 - Add Contains and a return parameter to Remove for SmallPointerArray. r=froydnj 2017-09-12 14:11:47 -04:00
TestSplayTree.cpp
TestTemplateLib.cpp
TestTuple.cpp
TestTypeTraits.cpp
TestTypedEnum.cpp
TestUniquePtr.cpp
TestVariant.cpp Bug 1338389 - Tests for Variant's detail::Nth and detail::SelectVariantType - r=froydnj 2017-06-06 16:59:00 +12:00
TestVector.cpp Bug 1329019 - Allow specifying capacity to Vector::replaceRawBuffer (r=froydnj) 2017-09-22 10:34:24 -05:00
TestWeakPtr.cpp
TestXorShift128PlusRNG.cpp
moz.build Bug 1386876 - Replace all uses of DISABLE_STL_WRAPPING with a template, remove DISABLE_STL_WRAPPING. r=glandium 2017-09-11 11:33:26 -07:00