Backed out 4 changesets (bug 1538081) for causing BaseElf.cpp bustages CLOSED TREE

Backed out changeset ced61a86c74c (bug 1538081)
Backed out changeset d6d331abbf0e (bug 1538081)
Backed out changeset 26df801e44db (bug 1538081)
Backed out changeset 113ac188a69e (bug 1538081)
This commit is contained in:
Ciure Andrei 2019-03-30 03:02:15 +02:00
parent 3357fd0d3a
commit 615006146b
10 changed files with 0 additions and 406 deletions

View File

@ -14,7 +14,6 @@
#include "mozilla/Move.h"
#include "mozilla/ReverseIterator.h"
#include <ostream>
#include <stddef.h>
namespace mozilla {
@ -89,13 +88,6 @@ class Array<T, 0> {
}
};
// MOZ_DBG support
template <typename T, size_t Length>
std::ostream& operator<<(std::ostream& aOut, const Array<T, Length>& aArray) {
return aOut << MakeSpan(aArray);
}
} /* namespace mozilla */
#endif /* mozilla_Array_h */

View File

@ -1,177 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_DbgMacro_h
#define mozilla_DbgMacro_h
/* a MOZ_DBG macro that outputs a wrapped value to stderr then returns it */
#include "mozilla/MacroForEach.h"
#include "mozilla/Span.h"
#include <stdio.h>
#include <sstream>
namespace mozilla {
namespace detail {
// Predicate to check whether T can be dereferenced and then inserted into an
// ostream.
template <typename T, typename = decltype(std::declval<std::ostream&>()
<< *std::declval<T>())>
std::true_type supports_os_deref_test(const T&);
std::false_type supports_os_deref_test(...);
template <typename T>
using supports_os_deref = decltype(supports_os_deref_test(std::declval<T>()));
} // namespace detail
// Helper function to write a value to an ostream.
//
// This handles pointer values where the type being pointed to supports
// operator<<, and we write out the value being pointed to in addition to the
// pointer value.
template <typename T>
auto DebugValue(std::ostream& aOut, T&& aValue) -> std::enable_if_t<
std::is_pointer<typename std::remove_reference<T>::type>::value &&
mozilla::detail::supports_os_deref<T>::value,
std::ostream&> {
if (aValue) {
aOut << *aValue << " @ " << aValue;
} else {
aOut << "null";
}
return aOut;
}
// Helper function to write a value to an ostream.
//
// This handles all other types by calling into operator<<.
template <typename T>
auto DebugValue(std::ostream& aOut, T&& aValue) -> std::enable_if_t<
!(std::is_pointer<typename std::remove_reference<T>::type>::value &&
mozilla::detail::supports_os_deref<T>::value),
std::ostream&> {
return aOut << aValue;
}
namespace detail {
// Helper function template for MOZ_DBG.
template <typename T>
auto&& MozDbg(const char* aFile, int aLine, const char* aExpression,
T&& aValue) {
std::ostringstream s;
s << '[' << aFile << ':' << aLine << "] " << aExpression << " = ";
mozilla::DebugValue(s, std::forward<T>(aValue));
s << '\n';
fputs(s.str().c_str(), stderr);
return std::forward<T>(aValue);
}
} // namespace detail
} // namespace mozilla
template <class ElementType, size_t Extent>
std::ostream& operator<<(std::ostream& aOut,
const mozilla::Span<ElementType, Extent>& aSpan) {
aOut << '[';
if (!aSpan.IsEmpty()) {
aOut << aSpan[0];
for (size_t i = 1; i < aSpan.Length(); ++i) {
aOut << ", " << aSpan[i];
}
}
return aOut << ']';
}
// Don't define this for char[], since operator<<(ostream&, char*) is already
// defined.
template <typename T, size_t N,
typename = std::enable_if_t<!std::is_same<T, char>::value>>
std::ostream& operator<<(std::ostream& aOut, const T (&aArray)[N]) {
return aOut << mozilla::MakeSpan(aArray);
// return aOut << mozilla::Span(aArray);
}
// MOZ_DBG is a macro like the Rust dbg!() macro -- it will print out the
// expression passed to it to stderr and then return the value. It is available
// only in MOZILLA_OFFICIAL builds, so you shouldn't land any uses of it in the
// tree.
//
// It should work for any type T that has an operator<<(std::ostream&, const T&)
// defined for it.
//
// Note 1: Using MOZ_DBG may cause copies to be made of temporary values:
//
// struct A {
// A(int);
// A(const A&);
//
// int x;
// };
//
// void f(A);
//
// f(A{1}); // may (and, in C++17, will) elide the creation of a temporary
// // for A{1} and instead initialize the function argument
// // directly using the A(int) constructor
//
// f(MOZ_DBG(A{1})); // will create and return a temporary for A{1}, which
// // then will be passed to the A(const A&) copy
// // constructor to initialize f's argument
//
// Note 2: MOZ_DBG cannot be used to wrap a prvalue that is being used to
// initialize an object if its type has no move constructor:
//
// struct B {
// B() = default;
// B(B&&) = delete;
// };
//
// B b1 = B(); // fine, initializes b1 directly
//
// B b2 = MOZ_DBG(B()); // compile error: MOZ_DBG needs to materialize a
// // temporary for B() so it can be passed to
// // operator<<, but that temporary is returned from
// // MOZ_DBG as an rvalue reference and so wants to
// // invoke B's move constructor to initialize b2
#ifndef MOZILLA_OFFICIAL
# define MOZ_DBG(expression_...) \
mozilla::detail::MozDbg(__FILE__, __LINE__, #expression_, expression_)
#endif
// Helper macro for MOZ_DEFINE_DBG.
#define MOZ_DBG_FIELD(name_) << #name_ << " = " << aValue.name_
// Macro to define an operator<<(ostream&) for a struct or class that displays
// the type name and the values of the specified member variables. Must be
// called inside the struct or class.
//
// For example:
//
// struct Point {
// float x;
// float y;
//
// MOZ_DEFINE_DBG(Point, x, y)
// };
//
// generates an operator<< that outputs strings like
// "Point { x = 1.0, y = 2.0 }".
#define MOZ_DEFINE_DBG(type_, members_...) \
friend std::ostream& operator<<(std::ostream& aOut, const type_& aValue) { \
return aOut << #type_ \
<< (MOZ_ARG_COUNT(members_) == 0 ? "{ " : "") \
MOZ_FOR_EACH_SEPARATED(MOZ_DBG_FIELD, (<< ", "), (), \
(members_)) \
<< (MOZ_ARG_COUNT(members_) == 0 ? " }" : ""); \
}
#endif // mozilla_DbgMacro_h

View File

@ -10,7 +10,6 @@
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/DbgMacro.h"
/*****************************************************************************/
@ -524,13 +523,6 @@ inline bool operator!=(decltype(nullptr), const RefPtr<T>& aRhs) {
return nullptr != aRhs.get();
}
// MOZ_DBG support
template <class T>
std::ostream& operator<<(std::ostream& aOut, const RefPtr<T>& aObj) {
return mozilla::DebugValue(aOut, aObj.get());
}
/*****************************************************************************/
template <class T>

View File

@ -29,7 +29,6 @@ EXPORTS.mozilla = [
'CheckedInt.h',
'Compiler.h',
'Compression.h',
'DbgMacro.h',
'DebugOnly.h',
'decimal/Decimal.h',
'DefineEnum.h',

View File

@ -1,174 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <iostream>
#include "gtest/gtest.h"
#include "mozilla/DbgMacro.h"
#include "mozilla/Unused.h"
using namespace mozilla;
#define TEST_MOZ_DBG_TYPE_IS(type_, expression_...) \
static_assert(IsSame<type_, decltype(MOZ_DBG(expression_))>::value, \
"MOZ_DBG should return the indicated type")
#define TEST_MOZ_DBG_TYPE_SAME(expression_...) \
static_assert( \
IsSame<decltype((expression_)), decltype(MOZ_DBG(expression_))>::value, \
"MOZ_DBG should return the same type")
struct Number {
explicit Number(int aValue) : mValue(aValue) {}
Number(const Number& aOther) : mValue(aOther.mValue) {}
Number(Number&& aOther) : mValue(aOther.mValue) { aOther.mValue = 0; }
Number& operator=(const Number& aOther) {
mValue = aOther.mValue;
return *this;
}
Number& operator=(Number&& aOther) {
mValue = aOther.mValue;
aOther.mValue = 0;
return *this;
}
~Number() { mValue = -999; }
int mValue;
MOZ_DEFINE_DBG(Number, mValue)
};
struct MoveOnly {
explicit MoveOnly(int aValue) : mValue(aValue) {}
MoveOnly(const MoveOnly& aOther) = delete;
MoveOnly(MoveOnly&& aOther) : mValue(aOther.mValue) { aOther.mValue = 0; }
MoveOnly& operator=(MoveOnly& aOther) {
mValue = aOther.mValue;
return *this;
}
MoveOnly& operator=(MoveOnly&& aOther) {
mValue = aOther.mValue;
aOther.mValue = 0;
return *this;
}
int mValue;
MOZ_DEFINE_DBG(MoveOnly)
};
void StaticAssertions() {
int x = 123;
Number y(123);
Number z(234);
MoveOnly w(456);
// Static assertions.
// lvalues
TEST_MOZ_DBG_TYPE_SAME(x); // int&
TEST_MOZ_DBG_TYPE_SAME(y); // Number&
TEST_MOZ_DBG_TYPE_SAME(x = 234); // int&
TEST_MOZ_DBG_TYPE_SAME(y = z); // Number&
TEST_MOZ_DBG_TYPE_SAME(w); // MoveOnly&
// prvalues (which MOZ_DBG turns into xvalues by creating objects for them)
TEST_MOZ_DBG_TYPE_IS(int&&, 123);
TEST_MOZ_DBG_TYPE_IS(int&&, 1 + 2);
TEST_MOZ_DBG_TYPE_IS(int*&&, &x);
TEST_MOZ_DBG_TYPE_IS(int&&, x++);
TEST_MOZ_DBG_TYPE_IS(Number&&, Number(123));
TEST_MOZ_DBG_TYPE_IS(MoveOnly&&, MoveOnly(123));
// xvalues
TEST_MOZ_DBG_TYPE_SAME(std::move(y)); // int&&
TEST_MOZ_DBG_TYPE_SAME(std::move(y)); // Number&&
TEST_MOZ_DBG_TYPE_SAME(std::move(w)); // MoveOnly&
Unused << x;
Unused << y;
Unused << z;
}
TEST(MozDbg, ObjectValues) {
// Test that moves and assignments all operate correctly with MOZ_DBG wrapped
// around various parts of the expression.
Number a(1);
Number b(4);
ASSERT_EQ(a.mValue, 1);
MOZ_DBG(a.mValue);
ASSERT_EQ(a.mValue, 1);
MOZ_DBG(a.mValue + 1);
ASSERT_EQ(a.mValue, 1);
MOZ_DBG(a.mValue = 2);
ASSERT_EQ(a.mValue, 2);
MOZ_DBG(a).mValue = 3;
ASSERT_EQ(a.mValue, 3);
MOZ_DBG(a = b);
ASSERT_EQ(a.mValue, 4);
ASSERT_EQ(b.mValue, 4);
b.mValue = 5;
MOZ_DBG(a) = b;
ASSERT_EQ(a.mValue, 5);
ASSERT_EQ(b.mValue, 5);
b.mValue = 6;
MOZ_DBG(a = std::move(b));
ASSERT_EQ(a.mValue, 6);
ASSERT_EQ(b.mValue, 0);
b.mValue = 7;
MOZ_DBG(a) = std::move(b);
ASSERT_EQ(a.mValue, 7);
ASSERT_EQ(b.mValue, 0);
b.mValue = 8;
a = std::move(MOZ_DBG(b));
ASSERT_EQ(a.mValue, 8);
ASSERT_EQ(b.mValue, 0);
a = MOZ_DBG(Number(9));
ASSERT_EQ(a.mValue, 9);
MoveOnly c(1);
MoveOnly d(2);
c = std::move(MOZ_DBG(d));
ASSERT_EQ(c.mValue, 2);
ASSERT_EQ(d.mValue, 0);
c.mValue = 3;
d.mValue = 4;
c = MOZ_DBG(std::move(d));
ASSERT_EQ(c.mValue, 4);
ASSERT_EQ(d.mValue, 0);
c.mValue = 5;
d.mValue = 6;
MOZ_DBG(c = std::move(d));
ASSERT_EQ(c.mValue, 6);
ASSERT_EQ(d.mValue, 0);
c = MOZ_DBG(MoveOnly(7));
ASSERT_EQ(c.mValue, 7);
}

View File

@ -10,12 +10,6 @@ UNIFIED_SOURCES += [
'TestSpan.cpp',
]
if not CONFIG['MOZILLA_OFFICIAL']:
UNIFIED_SOURCES += [
# MOZ_DBG is not defined in MOZILLA_OFFICIAL builds.
'TestMozDbg.cpp',
]
#LOCAL_INCLUDES += [
# '../../base',
#]

View File

@ -1476,11 +1476,4 @@ inline already_AddRefed<T> do_AddRef(const nsCOMPtr<T>& aObj) {
return ref.forget();
}
// MOZ_DBG support
template <class T>
std::ostream& operator<<(std::ostream& aOut, const nsCOMPtr<T>& aObj) {
return aOut << aObj.get();
}
#endif // !defined(nsCOMPtr_h___)

View File

@ -12,7 +12,6 @@
#include "nsXPCOM.h"
#include "mozilla/Assertions.h"
#include "mozilla/DbgMacro.h"
#include "mozilla/Likely.h"
#include <stdarg.h>

View File

@ -14,7 +14,6 @@
#include "mozilla/Attributes.h"
#include "mozilla/BinarySearch.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/DbgMacro.h"
#include "mozilla/fallible.h"
#include "mozilla/FunctionTypeTraits.h"
#include "mozilla/MathAlgorithms.h"
@ -37,7 +36,6 @@
#include <functional>
#include <initializer_list>
#include <new>
#include <ostream>
namespace JS {
template <class T>
@ -2649,14 +2647,6 @@ Span<const ElementType> MakeSpan(
} // namespace mozilla
// MOZ_DBG support
template <class E, class Alloc>
std::ostream& operator<<(std::ostream& aOut,
const nsTArray_Impl<E, Alloc>& aTArray) {
return aOut << mozilla::MakeSpan(aTArray);
}
// Assert that AutoTArray doesn't have any extra padding inside.
//
// It's important that the data stored in this auto array takes up a multiple of

View File

@ -7,8 +7,6 @@
#ifndef nsString_h___
#define nsString_h___
#include <ostream>
#include "mozilla/Attributes.h"
#include "nsStringFwd.h"
@ -124,18 +122,6 @@ class NS_ConvertUTF8toUTF16 : public nsAutoString {
NS_ConvertUTF8toUTF16(char16_t) = delete;
};
// MOZ_DBG support
inline std::ostream& operator<<(std::ostream& aOut, const nsACString& aString) {
aOut << '"';
aOut.write(aString.Data(), aString.Length());
return aOut << '"';
}
inline std::ostream& operator<<(std::ostream& aOut, const nsAString& aString) {
return aOut << NS_ConvertUTF16toUTF8(aString);
}
// the following are included/declared for backwards compatibility
#include "nsDependentString.h"
#include "nsLiteralString.h"