Add back deprecated warnings.

Unfortunately in clang 'deprecated' is both a set of warnings (at least
one of which we don't want) and a group of warnings (most of which we do
want). Leave the top level disabled, but re-enable all the warnings in
the group.

Most of the code changes are for the deprecated-copy diagnostic. In
C++11 implementing a copy constructor xor copy assignment operator
the default implementation of the other is still required to be the
default but is deprecated (the compiler can warn against doing this).
The idea is that if there was a need for a non-default copy constructor
or copy assignment operator then both should be implemented explicitly,
since it is unlikely that the default will do what is expected.

Note that the deprecated-copy-dtor has not yet been enabled as there
will need to be a lot more work to enable this diagnostic. Similar to
deprecated-copy, in C++11 when implementing a destructor the copy
constructor and copy assignment operator are still defaulted if not
declared, but this is also deprecated. The idea here is that if some
special handling is needed to destroy the object there is probably some
need to do something non-trivial when copying the object (or copying
should be disallowed).

Also, there are still some deprecated-declarations to clean up on
Android and Mac.

Change-Id: I5fc4b62713220e6f7d3724fd7342b4c8c74a3c67
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278916
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2020-03-23 17:22:24 -04:00 committed by Skia Commit-Bot
parent e29cdaf4c1
commit 833313b21a
11 changed files with 71 additions and 25 deletions

View File

@ -452,6 +452,29 @@ config("warnings") {
"-Wno-direct-ivar-access",
"-Wno-objcc-interface-ivars",
]
# Wno-deprecated turns off the whole group, but also has its own warnings like
# out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated [-Werror,-Wdeprecated]
# but we would like others. Created from clang/include/clang/Basic/DiagnosticGroups.td
cflags += [
"-Wdeprecated-anon-enum-enum-conversion",
"-Wdeprecated-array-compare",
"-Wdeprecated-attributes",
"-Wdeprecated-comma-subscript",
"-Wdeprecated-copy",
#"-Wdeprecated-copy-dtor",
#"-Wdeprecated-declarations",
"-Wdeprecated-dynamic-exception-spec",
"-Wdeprecated-enum-compare",
"-Wdeprecated-enum-compare-conditional",
"-Wdeprecated-enum-enum-conversion",
"-Wdeprecated-enum-float-conversion",
"-Wdeprecated-increment-bool",
"-Wdeprecated-register",
"-Wdeprecated-this-capture",
"-Wdeprecated-volatile",
"-Wdeprecated-writable-str",
]
}
if (!is_win || is_clang) {
cflags += [ "-Wno-implicit-fallthrough" ]

View File

@ -63,7 +63,8 @@ public:
};
SkSurfaceProps(InitType);
SkSurfaceProps(uint32_t flags, InitType);
SkSurfaceProps(const SkSurfaceProps& other);
SkSurfaceProps(const SkSurfaceProps&);
SkSurfaceProps& operator=(const SkSurfaceProps&);
uint32_t flags() const { return fFlags; }
SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }

View File

@ -71,8 +71,8 @@ class SK_API GrBackendFormat {
public:
// Creates an invalid backend format.
GrBackendFormat() {}
GrBackendFormat(const GrBackendFormat& src);
GrBackendFormat(const GrBackendFormat&);
GrBackendFormat& operator=(const GrBackendFormat&);
static GrBackendFormat MakeGL(GrGLenum format, GrGLenum target) {
return GrBackendFormat(format, target);

View File

@ -107,9 +107,8 @@ enum class PlaceholderAlignment {
struct FontFeature {
FontFeature(const SkString name, int value) : fName(name), fValue(value) { }
FontFeature(const FontFeature& other) : fName(other.fName), fValue(other.fValue) { }
bool operator==(const FontFeature& other) const {
return fName == other.fName && fValue == other.fValue;
bool operator==(const FontFeature& that) const {
return fName == that.fName && fValue == that.fValue;
}
SkString fName;
int fValue;
@ -131,7 +130,7 @@ struct PlaceholderStyle {
, fBaseline(baseline)
, fBaselineOffset(offset) {}
bool equals(const PlaceholderStyle& other) const;
bool equals(const PlaceholderStyle&) const;
SkScalar fWidth;
SkScalar fHeight;

View File

@ -125,22 +125,39 @@ void SkConservativeClip::opIRect(const SkIRect& devRect, SkRegion::Op op) {
///////////////////////////////////////////////////////////////////////////////////////////////////
SkRasterClip::SkRasterClip(const SkRasterClip& src) {
AUTO_RASTERCLIP_VALIDATE(src);
SkRasterClip::SkRasterClip(const SkRasterClip& that)
: fIsBW(that.fIsBW), fIsEmpty(that.fIsEmpty), fIsRect(that.fIsRect)
, fClipRestrictionRect(that.fClipRestrictionRect), fShader(that.fShader)
{
AUTO_RASTERCLIP_VALIDATE(that);
fIsBW = src.fIsBW;
if (fIsBW) {
fBW = src.fBW;
fBW = that.fBW;
} else {
fAA = src.fAA;
fAA = that.fAA;
}
fIsEmpty = src.isEmpty();
fIsRect = src.isRect();
fClipRestrictionRect = src.fClipRestrictionRect;
SkDEBUGCODE(this->validate();)
}
SkRasterClip& SkRasterClip::operator=(const SkRasterClip& that) {
AUTO_RASTERCLIP_VALIDATE(that);
fIsBW = that.fIsBW;
if (fIsBW) {
fBW = that.fBW;
} else {
fAA = that.fAA;
}
fIsEmpty = that.isEmpty();
fIsRect = that.isRect();
fClipRestrictionRect = that.fClipRestrictionRect;
fShader = that.fShader;
SkDEBUGCODE(this->validate();)
return *this;
}
SkRasterClip::SkRasterClip(const SkRegion& rgn) : fBW(rgn) {
fIsBW = true;
fIsEmpty = this->computeIsEmpty(); // bounds might be empty, so compute

View File

@ -63,6 +63,7 @@ public:
SkRasterClip(const SkIRect&);
SkRasterClip(const SkRegion&);
SkRasterClip(const SkRasterClip&);
SkRasterClip& operator=(const SkRasterClip&);
~SkRasterClip();
// Only compares the current state. Does not compare isForceConservativeRects(), so that field

View File

@ -187,6 +187,8 @@ public:
static const IterStart kTail_IterStart = INHERITED::kTail_IterStart;
Iter() {}
Iter(const Iter& that) : INHERITED(that) {}
Iter& operator=(const Iter& that) { INHERITED::operator=(that); return *this; }
Iter(const SkTLList& list, IterStart start = kHead_IterStart) {
INHERITED::init(list.fList, start);
@ -202,8 +204,6 @@ public:
T* prev() { return this->nodeToObj(INHERITED::prev()); }
Iter& operator= (const Iter& iter) { INHERITED::operator=(iter); return *this; }
private:
friend class SkTLList;
Node* getNode() { return INHERITED::get(); }

View File

@ -72,6 +72,14 @@ GrBackendFormat::GrBackendFormat(const GrBackendFormat& that)
}
}
GrBackendFormat& GrBackendFormat::operator=(const GrBackendFormat& that) {
if (this != &that) {
this->~GrBackendFormat();
new (this) GrBackendFormat(that);
}
return *this;
}
#ifdef SK_GL
GrBackendFormat::GrBackendFormat(GrGLenum format, GrGLenum target)
: fBackend(GrBackendApi::kOpenGL)

View File

@ -18,10 +18,8 @@ GrColorInfo::GrColorInfo(const SkColorInfo& ci)
ci.alphaType(),
ci.refColorSpace()) {}
GrColorInfo::GrColorInfo(const GrColorInfo& ci)
: GrColorInfo(ci.colorType(),
ci.alphaType(),
ci.refColorSpace()) {}
GrColorInfo::GrColorInfo(const GrColorInfo&) = default;
GrColorInfo& GrColorInfo::operator=(const GrColorInfo&) = default;
GrColorSpaceXform* GrColorInfo::colorSpaceXformFromSRGB() const {
// TODO: Make this atomic if we start accessing this on multiple threads.

View File

@ -20,6 +20,7 @@ class GrColorInfo {
public:
GrColorInfo() = default;
GrColorInfo(const GrColorInfo&);
GrColorInfo& operator=(const GrColorInfo&);
GrColorInfo(GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
/* implicit */ GrColorInfo(const SkColorInfo&);

View File

@ -51,10 +51,8 @@ SkSurfaceProps::SkSurfaceProps(uint32_t flags, SkPixelGeometry pg)
: fFlags(flags), fPixelGeometry(pg)
{}
SkSurfaceProps::SkSurfaceProps(const SkSurfaceProps& other)
: fFlags(other.fFlags)
, fPixelGeometry(other.fPixelGeometry)
{}
SkSurfaceProps::SkSurfaceProps(const SkSurfaceProps&) = default;
SkSurfaceProps& SkSurfaceProps::operator=(const SkSurfaceProps&) = default;
///////////////////////////////////////////////////////////////////////////////