Remove SK_REQUIRE_LOCAL_VAR macro.

The ClangTidy check `bugprone-unused-raii` has been enabled at
review.skia.org/306838; this check provides equivalent protection.

Change-Id: I9f3858bfd2bede107d509a5a206a08293d5f914c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306953
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2020-07-30 21:48:57 -04:00 committed by Skia Commit-Bot
parent 078f875477
commit f8869a24e7
13 changed files with 3 additions and 45 deletions

View File

@ -461,6 +461,7 @@ skia_core_sources = [
"$_include/private/SkFloatingPoint.h",
"$_include/private/SkHalf.h",
"$_include/private/SkIDChangeListener.h",
"$_include/private/SkMacros.h",
"$_include/private/SkMalloc.h",
"$_include/private/SkMutex.h",
"$_include/private/SkNoncopyable.h",

View File

@ -2850,7 +2850,4 @@ private:
SkAutoCanvasRestore& operator=(const SkAutoCanvasRestore&) = delete;
};
// Private
#define SkAutoCanvasRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoCanvasRestore)
#endif

View File

@ -57,6 +57,5 @@ private:
const char* fLabel;
double fNow;
};
#define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
#endif

View File

@ -24,32 +24,6 @@
*/
#define SK_MACRO_APPEND_LINE(name) SK_MACRO_CONCAT(name, __LINE__)
/**
* For some classes, it's almost always an error to instantiate one without a name, e.g.
* {
* SkAutoMutexAcquire(&mutex);
* <some code>
* }
* In this case, the writer meant to hold mutex while the rest of the code in the block runs,
* but instead the mutex is acquired and then immediately released. The correct usage is
* {
* SkAutoMutexAcquire lock(&mutex);
* <some code>
* }
*
* To prevent callers from instantiating your class without a name, use SK_REQUIRE_LOCAL_VAR
* like this:
* class classname {
* <your class>
* };
* #define classname(...) SK_REQUIRE_LOCAL_VAR(classname)
*
* This won't work with templates, and you must inline the class' constructors and destructors.
* Take a look at SkAutoFree and SkAutoMalloc in this file for examples.
*/
#define SK_REQUIRE_LOCAL_VAR(classname) \
static_assert(false, "missing name for " #classname)
////////////////////////////////////////////////////////////////////////////////
// Can be used to bracket data types that must be dense, e.g. hash keys.

View File

@ -47,6 +47,4 @@ private:
SkMutex& fMutex;
};
#define SkAutoMutexExclusive(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexExclusive)
#endif // SkMutex_DEFINED

View File

@ -127,7 +127,6 @@ private:
fInfo_ptr = nullptr;
}
};
#define AutoCleanPng(...) SK_REQUIRE_LOCAL_VAR(AutoCleanPng)
static inline bool is_chunk(const png_byte* chunk, const char* tag) {
return memcmp(chunk + 4, tag, 4) == 0;

View File

@ -54,6 +54,5 @@ private:
SkSTArenaAlloc<kSkBlitterContextSize> fAlloc;
};
#define SkAutoBlitterChoose(...) SK_REQUIRE_LOCAL_VAR(SkAutoBlitterChoose)
#endif

View File

@ -78,7 +78,6 @@ private:
std::unique_ptr<void, WrapFree> fPtr;
size_t fSize; // can be larger than the requested size (see kReuse)
};
#define SkAutoMalloc(...) SK_REQUIRE_LOCAL_VAR(SkAutoMalloc)
/**
* Manage an allocated block of memory. If the requested size is <= kSizeRequested (or slightly

View File

@ -237,7 +237,7 @@ template <> struct SkMask::AlphaIter<SkMask::kLCD16_Format> {
* Stack class used to manage the fImage buffer in a SkMask.
* When this object loses scope, the buffer is freed with SkMask::FreeImage().
*/
using SkAutoMaskFreeImage = std::unique_ptr<uint8_t, SkFunctionWrapper<decltype(SkMask::FreeImage), SkMask::FreeImage>>;
#define SkAutoMaskFreeImage(...) SK_REQUIRE_LOCAL_VAR(SkAutoMaskFreeImage)
using SkAutoMaskFreeImage =
std::unique_ptr<uint8_t, SkFunctionWrapper<decltype(SkMask::FreeImage), SkMask::FreeImage>>;
#endif

View File

@ -77,7 +77,6 @@ private:
SkPath* fPath;
SkPathPriv::FirstDirection fSaved;
};
#define SkAutoDisableDirectionCheck(...) SK_REQUIRE_LOCAL_VAR(SkAutoDisableDirectionCheck)
/* This class's constructor/destructor bracket a path editing operation. It is
used when we know the bounds of the amount we are going to add to the path
@ -121,7 +120,6 @@ private:
bool fDegenerate;
bool fEmpty;
};
#define SkAutoPathBoundsUpdate(...) SK_REQUIRE_LOCAL_VAR(SkAutoPathBoundsUpdate)
////////////////////////////////////////////////////////////////////////////

View File

@ -205,7 +205,6 @@ public:
private:
const SkRasterClip& fRC;
};
#define SkAutoRasterClipValidate(...) SK_REQUIRE_LOCAL_VAR(SkAutoRasterClipValidate)
#ifdef SK_DEBUG
#define AUTO_RASTERCLIP_VALIDATE(rc) SkAutoRasterClipValidate arcv(rc)

View File

@ -83,8 +83,6 @@ private:
SkSharedMutex& fLock;
};
#define SkAutoSharedMutexExclusive(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexExclusive)
class SK_SCOPED_CAPABILITY SkAutoSharedMutexShared {
public:
explicit SkAutoSharedMutexShared(SkSharedMutex& lock) SK_ACQUIRE_SHARED(lock)
@ -101,6 +99,4 @@ private:
SkSharedMutex& fLock;
};
#define SkAutoSharedMutexShared(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexShared)
#endif // SkSharedLock_DEFINED

View File

@ -231,7 +231,6 @@ private:
HFONT fFont;
HFONT fSavefont;
};
#define SkAutoHDC(...) SK_REQUIRE_LOCAL_VAR(SkAutoHDC)
class LogFontTypeface : public SkTypeface {
public: