diff --git a/bench/ColorPrivBench.cpp b/bench/ColorPrivBench.cpp index 23cc48f3cc..a19dc5e2a3 100644 --- a/bench/ColorPrivBench.cpp +++ b/bench/ColorPrivBench.cpp @@ -41,7 +41,7 @@ public: void onDraw(int loops, SkCanvas*) override { // We xor results of FourByteInterp into junk to make sure the function runs. - SK_MAYBE_UNUSED volatile SkPMColor junk = 0; + [[maybe_unused]] volatile SkPMColor junk = 0; for (int loop = 0; loop < loops; loop++) { for (int i = 0; i < kInputs; i++) { diff --git a/bench/ControlBench.cpp b/bench/ControlBench.cpp index 19696934ab..5794bfe3e3 100644 --- a/bench/ControlBench.cpp +++ b/bench/ControlBench.cpp @@ -16,7 +16,7 @@ struct ControlBench : public Benchmark { void onDraw(int loops, SkCanvas*) override { // Nothing terribly useful: force a memory read, a memory write, and some math. - SK_MAYBE_UNUSED volatile uint32_t rand = 0; + [[maybe_unused]] volatile uint32_t rand = 0; for (int i = 0; i < 1000*loops; i++) { rand *= 1664525; rand += 1013904223; diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp index 07683ead7e..b19daa4a8a 100644 --- a/bench/MatrixBench.cpp +++ b/bench/MatrixBench.cpp @@ -53,7 +53,7 @@ protected: m2.reset(); // xor into a volatile prevents these comparisons from being optimized away. - SK_MAYBE_UNUSED volatile bool junk = false; + [[maybe_unused]] volatile bool junk = false; junk ^= (m0 == m1); junk ^= (m1 == m2); junk ^= (m2 == m0); @@ -116,7 +116,7 @@ protected: fArray[3], fArray[4], fArray[5], fArray[6], fArray[7], fArray[8]); // xoring into a volatile prevents the compiler from optimizing these away - SK_MAYBE_UNUSED volatile int junk = 0; + [[maybe_unused]] volatile int junk = 0; junk ^= (fMatrix.getType()); fMatrix.dirtyMatrixTypeCache(); junk ^= (fMatrix.getType()); diff --git a/bench/ScalarBench.cpp b/bench/ScalarBench.cpp index e47fc63aee..80e96afb2d 100644 --- a/bench/ScalarBench.cpp +++ b/bench/ScalarBench.cpp @@ -59,7 +59,7 @@ protected: int mulLoopCount() const override { return 4; } void performTest() override { // xoring into a volatile prevents the compiler from optimizing these checks away. - SK_MAYBE_UNUSED volatile bool junk = false; + [[maybe_unused]] volatile bool junk = false; junk ^= (fArray[6] != 0.0f || fArray[7] != 0.0f || fArray[8] != 1.0f); junk ^= (fArray[2] != 0.0f || fArray[5] != 0.0f); } @@ -78,7 +78,7 @@ protected: int mulLoopCount() const override { return 4; } void performTest() override { // xoring into a volatile prevents the compiler from optimizing these checks away. - SK_MAYBE_UNUSED volatile int32_t junk = 0; + [[maybe_unused]] volatile int32_t junk = 0; junk ^= (SkScalarAs2sCompliment(fArray[6]) | SkScalarAs2sCompliment(fArray[7]) | (SkScalarAs2sCompliment(fArray[8]) - kPersp1Int)); diff --git a/bench/TessellateBench.cpp b/bench/TessellateBench.cpp index 21cd6fec9b..9dd2524591 100644 --- a/bench/TessellateBench.cpp +++ b/bench/TessellateBench.cpp @@ -63,7 +63,7 @@ static SkPath make_conic_path() { return path; } -SK_MAYBE_UNUSED static SkPath make_quad_path(int maxPow2) { +[[maybe_unused]] static SkPath make_quad_path(int maxPow2) { SkRandom rand; SkPath path; for (int i = 0; i < kNumCubicsInChalkboard; ++i) { @@ -73,7 +73,7 @@ SK_MAYBE_UNUSED static SkPath make_quad_path(int maxPow2) { return path; } -SK_MAYBE_UNUSED static SkPath make_line_path(int maxPow2) { +[[maybe_unused]] static SkPath make_line_path(int maxPow2) { SkRandom rand; SkPath path; for (int i = 0; i < kNumCubicsInChalkboard; ++i) { diff --git a/gm/rasterhandleallocator.cpp b/gm/rasterhandleallocator.cpp index fa4488bb3a..e2e889a486 100644 --- a/gm/rasterhandleallocator.cpp +++ b/gm/rasterhandleallocator.cpp @@ -255,7 +255,7 @@ public: RECT clip_bounds_RECT = toRECT(clip_bounds); HRGN hrgn = CreateRectRgnIndirect(&clip_bounds_RECT); - SK_MAYBE_UNUSED int result = SelectClipRgn(hdc, hrgn); + [[maybe_unused]] int result = SelectClipRgn(hdc, hrgn); SkASSERT(result != ERROR); result = DeleteObject(hrgn); SkASSERT(result != 0); diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index 8adaf3ac09..47274c5106 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -340,14 +340,6 @@ # endif #endif -#if !defined(SK_MAYBE_UNUSED) -# if defined(__clang__) || defined(__GNUC__) -# define SK_MAYBE_UNUSED [[maybe_unused]] -# else -# define SK_MAYBE_UNUSED -# endif -#endif - /** * If your judgment is better than the compiler's (i.e. you've profiled it), * you can use SK_ALWAYS_INLINE to force inlining. E.g. diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index 20fc62f699..f8895345d6 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -36,37 +36,37 @@ private: * basic bitfield. */ #define GR_MAKE_BITFIELD_CLASS_OPS(X) \ - SK_MAYBE_UNUSED constexpr GrTFlagsMask operator~(X a) { \ + [[maybe_unused]] constexpr GrTFlagsMask operator~(X a) { \ return GrTFlagsMask(~static_cast(a)); \ } \ - SK_MAYBE_UNUSED constexpr X operator|(X a, X b) { \ + [[maybe_unused]] constexpr X operator|(X a, X b) { \ return static_cast(static_cast(a) | static_cast(b)); \ } \ - SK_MAYBE_UNUSED inline X& operator|=(X& a, X b) { \ + [[maybe_unused]] inline X& operator|=(X& a, X b) { \ return (a = a | b); \ } \ - SK_MAYBE_UNUSED constexpr bool operator&(X a, X b) { \ + [[maybe_unused]] constexpr bool operator&(X a, X b) { \ return SkToBool(static_cast(a) & static_cast(b)); \ } \ - SK_MAYBE_UNUSED constexpr GrTFlagsMask operator|(GrTFlagsMask a, GrTFlagsMask b) { \ + [[maybe_unused]] constexpr GrTFlagsMask operator|(GrTFlagsMask a, GrTFlagsMask b) { \ return GrTFlagsMask(a.value() | b.value()); \ } \ - SK_MAYBE_UNUSED constexpr GrTFlagsMask operator|(GrTFlagsMask a, X b) { \ + [[maybe_unused]] constexpr GrTFlagsMask operator|(GrTFlagsMask a, X b) { \ return GrTFlagsMask(a.value() | static_cast(b)); \ } \ - SK_MAYBE_UNUSED constexpr GrTFlagsMask operator|(X a, GrTFlagsMask b) { \ + [[maybe_unused]] constexpr GrTFlagsMask operator|(X a, GrTFlagsMask b) { \ return GrTFlagsMask(static_cast(a) | b.value()); \ } \ - SK_MAYBE_UNUSED constexpr X operator&(GrTFlagsMask a, GrTFlagsMask b) { \ + [[maybe_unused]] constexpr X operator&(GrTFlagsMask a, GrTFlagsMask b) { \ return static_cast(a.value() & b.value()); \ } \ - SK_MAYBE_UNUSED constexpr X operator&(GrTFlagsMask a, X b) { \ + [[maybe_unused]] constexpr X operator&(GrTFlagsMask a, X b) { \ return static_cast(a.value() & static_cast(b)); \ } \ - SK_MAYBE_UNUSED constexpr X operator&(X a, GrTFlagsMask b) { \ + [[maybe_unused]] constexpr X operator&(X a, GrTFlagsMask b) { \ return static_cast(static_cast(a) & b.value()); \ } \ - SK_MAYBE_UNUSED inline X& operator&=(X& a, GrTFlagsMask b) { \ + [[maybe_unused]] inline X& operator&=(X& a, GrTFlagsMask b) { \ return (a = a & b); \ } \ diff --git a/src/core/SkEnumBitMask.h b/src/core/SkEnumBitMask.h index 3fe3bd5c8e..a04f6cd0b8 100644 --- a/src/core/SkEnumBitMask.h +++ b/src/core/SkEnumBitMask.h @@ -65,16 +65,16 @@ private: * Defines functions that make it possible to use bitwise operators on an enum. */ #define SK_MAKE_BITMASK_OPS(E) \ - SK_MAYBE_UNUSED constexpr SkEnumBitMask operator|(E a, E b) { \ + [[maybe_unused]] constexpr SkEnumBitMask operator|(E a, E b) { \ return SkEnumBitMask(a) | b; \ } \ - SK_MAYBE_UNUSED constexpr SkEnumBitMask operator&(E a, E b) { \ + [[maybe_unused]] constexpr SkEnumBitMask operator&(E a, E b) { \ return SkEnumBitMask(a) & b; \ } \ - SK_MAYBE_UNUSED constexpr SkEnumBitMask operator^(E a, E b) { \ + [[maybe_unused]] constexpr SkEnumBitMask operator^(E a, E b) { \ return SkEnumBitMask(a) ^ b; \ } \ - SK_MAYBE_UNUSED constexpr SkEnumBitMask operator~(E e) { \ + [[maybe_unused]] constexpr SkEnumBitMask operator~(E e) { \ return ~SkEnumBitMask(e); \ } \ diff --git a/src/gpu/BufferWriter.h b/src/gpu/BufferWriter.h index b93273e97a..35ad787c3f 100644 --- a/src/gpu/BufferWriter.h +++ b/src/gpu/BufferWriter.h @@ -304,7 +304,7 @@ inline VertexWriter& operator<<(VertexWriter& w, const VertexWriter::RepeatDesc< } template <> -SK_MAYBE_UNUSED inline VertexWriter& operator<<(VertexWriter& w, const skvx::float4& vector) { +[[maybe_unused]] inline VertexWriter& operator<<(VertexWriter& w, const skvx::float4& vector) { w.validate(sizeof(vector)); vector.store(w.fPtr); w = w.makeOffset(sizeof(vector)); @@ -354,7 +354,7 @@ private: }; template <> -SK_MAYBE_UNUSED inline VertexWriter& operator<<(VertexWriter& w, const VertexColor& color) { +[[maybe_unused]] inline VertexWriter& operator<<(VertexWriter& w, const VertexColor& color) { w << color.fColor[0]; if (color.fWideColor) { w << color.fColor[1] diff --git a/src/gpu/tessellate/Tessellation.h b/src/gpu/tessellate/Tessellation.h index 8cb33d5b68..494622bcea 100644 --- a/src/gpu/tessellate/Tessellation.h +++ b/src/gpu/tessellate/Tessellation.h @@ -87,9 +87,9 @@ GR_MAKE_BITFIELD_CLASS_OPS(PatchAttribs) // When PatchAttribs::kExplicitCurveType is set, these are the values that tell the GPU what type of // curve is being drawn. -constexpr static float kCubicCurveType SK_MAYBE_UNUSED = 0; -constexpr static float kConicCurveType SK_MAYBE_UNUSED = 1; -constexpr static float kTriangularConicCurveType SK_MAYBE_UNUSED = 2; // Conic curve with w=Inf. +constexpr static float kCubicCurveType [[maybe_unused]] = 0; +constexpr static float kConicCurveType [[maybe_unused]] = 1; +constexpr static float kTriangularConicCurveType [[maybe_unused]] = 2; // Conic curve with w=Inf. // Returns the packed size in bytes of the attribs portion of tessellation patches (or instances) in // GPU buffers. diff --git a/src/gpu/tessellate/WangsFormula.h b/src/gpu/tessellate/WangsFormula.h index b8637b0f3f..73bdbff5a6 100644 --- a/src/gpu/tessellate/WangsFormula.h +++ b/src/gpu/tessellate/WangsFormula.h @@ -15,7 +15,7 @@ #include "include/private/SkVx.h" #include "src/gpu/tessellate/Tessellation.h" -#define AI SK_MAYBE_UNUSED SK_ALWAYS_INLINE +#define AI [[maybe_unused]] SK_ALWAYS_INLINE // Wang's formula gives the minimum number of evenly spaced (in the parametric sense) line segments // that a bezier curve must be chopped into in order to guarantee all lines stay within a distance diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index 49f9800c0c..fc9487ec2e 100755 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -79,7 +79,7 @@ static SkTileMode optimize(SkTileMode tm, int dimension) { // TODO: currently this only *always* used in asFragmentProcessor(), which is excluded on no-gpu // builds. No-gpu builds only use needs_subset() in asserts, so release+no-gpu doesn't use it, which // can cause builds to fail if unused warnings are treated as errors. -SK_MAYBE_UNUSED static bool needs_subset(SkImage* img, const SkRect& subset) { +[[maybe_unused]] static bool needs_subset(SkImage* img, const SkRect& subset) { return subset != SkRect::Make(img->dimensions()); }