Enable ClangTidy flag modernize-use-override.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-override.html

Adds override (introduced in C++11) to overridden virtual functions and
removes virtual from those functions as it is not required.

virtual on non base class implementations was used to help indicate to
the user that a function was virtual. C++ compilers did not use the
presence of this to signify an overridden function.

Change-Id: If66d8919358f72a4035190caf8d7569268037a9a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310160
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
John Stiles 2020-08-13 22:58:04 -04:00 committed by Skia Commit-Bot
parent c184cf3609
commit 1cf2c8d6ec
43 changed files with 88 additions and 86 deletions

View File

@ -1,4 +1,20 @@
Checks: '-*,bugprone-use-after-move,bugprone-unused-raii,bugprone-undelegated-constructor,bugprone-argument-comment,bugprone-bool-pointer-implicit-conversion,performance-unnecessary-copy-initialization,performance-for-range-copy,readability-redundant-preprocessor,misc-definitions-in-headers,modernize-make-unique,llvm-namespace-comment,readability-static-accessed-through-instance,readability-const-return-type,google-build-namespaces'
Checks: >
-*,
bugprone-argument-comment,
bugprone-bool-pointer-implicit-conversion,
bugprone-undelegated-constructor,
bugprone-unused-raii,
bugprone-use-after-move,
google-build-namespaces,
llvm-namespace-comment,
misc-definitions-in-headers,
modernize-make-unique,
modernize-use-override,
performance-for-range-copy,
performance-unnecessary-copy-initialization,
readability-const-return-type,
readability-redundant-preprocessor,
readability-static-accessed-through-instance
CheckOptions:
- key: llvm-namespace-comment.SpacesBeforeComments
value: 2

View File

@ -104,8 +104,7 @@ public:
}
protected:
virtual void handlePath(SkCanvas* canvas, const SkPath& path,
const SkPaint& paint, int N) override {
void handlePath(SkCanvas* canvas, const SkPath& path, const SkPaint& paint, int N) override {
SkPoint pts[2];
if (!path.isLine(pts) || pts[0].fY != pts[1].fY) {
this->INHERITED::handlePath(canvas, path, paint, N);

View File

@ -129,7 +129,7 @@ public:
path->transform(rotateMatrix);
}
virtual void setupPaint(SkPaint* paint) override {
void setupPaint(SkPaint* paint) override {
PathBench::setupPaint(paint);
paint->setAntiAlias(fAA);
}

View File

@ -35,7 +35,7 @@ constexpr SkRect kSrcImageClip{75, 75, 275, 275};
*/
class CroppedRectsGM : public GM {
private:
SkString onShortName() override final { return SkString("croppedrects"); }
SkString onShortName() final { return SkString("croppedrects"); }
SkISize onISize() override { return SkISize::Make(500, 500); }
void onOnceBeforeDraw() override {

View File

@ -29,7 +29,7 @@ class ClippedCubicGM : public skiagm::GM {
SkISize onISize() override { return {1240, 390}; }
virtual void onDraw(SkCanvas* canvas) override {
void onDraw(SkCanvas* canvas) override {
SkPath path;
path.moveTo(0, 0);
path.cubicTo(140, 150, 40, 10, 170, 150);
@ -259,7 +259,7 @@ class CubicClosePathGM : public skiagm::GM {
canvas->restore();
}
virtual void onDraw(SkCanvas* canvas) override {
void onDraw(SkCanvas* canvas) override {
struct FillAndName {
SkPathFillType fFill;
const char* fName;

View File

@ -52,7 +52,7 @@ protected:
return SkISize::Make(1024, 768);
}
virtual void onDraw(SkCanvas* inputCanvas) override {
void onDraw(SkCanvas* inputCanvas) override {
SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f };
SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f };

View File

@ -88,7 +88,7 @@ namespace skiagm {
return SkString("hairmodes");
}
virtual SkISize onISize() override { return SkISize::Make(640, 480); }
SkISize onISize() override { return SkISize::Make(640, 480); }
void onOnceBeforeDraw() override {
fBGPaint.setShader(make_bg_shader());

View File

@ -36,7 +36,7 @@ protected:
}
}
SkString onShortName() override final { return fName; }
SkString onShortName() final { return fName; }
SkISize onISize() override { return SkISize::Make(500, 500); }
void onOnceBeforeDraw() override {

View File

@ -21,7 +21,7 @@ class TinyBitmapGM : public skiagm::GM {
SkString onShortName() override { return SkString("tinybitmap"); }
virtual SkISize onISize() override { return SkISize::Make(100, 100); }
SkISize onISize() override { return SkISize::Make(100, 100); }
void onDraw(SkCanvas* canvas) override {
SkBitmap bm;

View File

@ -33,7 +33,7 @@ protected:
void didTranslate(SkScalar, SkScalar) override;
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
void onDrawPaint(const SkPaint&) override;

View File

@ -38,11 +38,10 @@ protected:
void didTranslate(SkScalar, SkScalar) override;
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode,
const SkPaint& paint) override;
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint) override;
void onDrawPaint(const SkPaint&) override;
void onDrawBehind(const SkPaint&) override;

View File

@ -55,7 +55,7 @@ struct Keyframe {
class KeyframeAnimator : public Animator {
public:
virtual ~KeyframeAnimator() override;
~KeyframeAnimator() override;
bool isConstant() const {
SkASSERT(!fKFs.empty());

View File

@ -76,7 +76,7 @@ DEF_TEST(Skottie_AudioLayer, r) {
private:
sk_sp<ExternalTrackAsset> loadAudioAsset(const char path[],
const char name[],
const char id[]) {
const char id[]) override {
REPORTER_ASSERT(fReporter, !strcmp(path, "assets/"));
REPORTER_ASSERT(fReporter, !strcmp(name, "audio.mp3"));
REPORTER_ASSERT(fReporter, !strcmp(id , "audio_0"));

View File

@ -1519,7 +1519,7 @@ public:
return -1;
}
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
SkPoint pt = {x, y};
int ptHit = hittest_pt(pt);
if (ptHit >= 0) {

View File

@ -108,8 +108,7 @@ protected:
}
}
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y,
skui::ModifierKey modi) override {
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
lua_State* L = this->ensureLua();
lua_getglobal(L, gClickName);
if (lua_isfunction(L, -1)) {

View File

@ -71,7 +71,7 @@ protected:
}
}
virtual Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) override {
Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) override {
return fRect.contains(SkScalarRoundToInt(x),
SkScalarRoundToInt(y)) ? new Click() : nullptr;
}

View File

@ -714,8 +714,7 @@ protected:
MyClick(int index) : fIndex(index) {}
};
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y,
skui::ModifierKey modi) override {
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); ++i) {
if (hittest(fPts[i], x, y)) {
return new MyClick((int)i);

View File

@ -324,8 +324,7 @@ protected:
}
}
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y,
skui::ModifierKey modi) override {
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
return fRect.contains(SkScalarRoundToInt(x),
SkScalarRoundToInt(y)) ? new Click() : nullptr;
}

View File

@ -38,8 +38,7 @@ protected:
this->INHERITED::begin(uvBounds, dst);
}
virtual void next(const SkPoint& loc, int u, int v,
SkPath* dst) const override {
void next(const SkPoint& loc, int u, int v, SkPath* dst) const override {
if (fPts) {
*fPts->append() = loc;
}
@ -78,8 +77,7 @@ sk_sp<SkFlattenable> Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) {
class InverseFillPE : public SkPathEffect {
public:
InverseFillPE() {}
virtual bool onFilterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override {
bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override {
*dst = src;
dst->setFillType(SkPathFillType::kInverseWinding);
return true;

View File

@ -1217,8 +1217,8 @@ public:
fLastY = y + height - 1;
}
virtual void blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha) override {
void blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha) override {
this->recordMinY(y);
this->checkForYGap(y);
fBuilder->addAntiRectRun(x, y, width, height, leftAlpha, rightAlpha);
@ -1238,8 +1238,8 @@ public:
fBuilder->addRun(x, y, 0xFF, width);
}
virtual void blitAntiH(int x, int y, const SkAlpha alpha[],
const int16_t runs[]) override {
void blitAntiH(int x, int y, const SkAlpha alpha[],
const int16_t runs[]) override {
this->recordMinY(y);
this->checkForYGap(y);
for (;;) {

View File

@ -189,8 +189,8 @@ public:
void blitAntiH(int x, int y, const SkAlpha[], const int16_t runs[]) override;
void blitV(int x, int y, int height, SkAlpha alpha) override;
void blitRect(int x, int y, int width, int height) override;
virtual void blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha) override;
void blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha) override;
void blitMask(const SkMask&, const SkIRect& clip) override;
const SkPixmap* justAnOpaqueColor(uint32_t* value) override;

View File

@ -89,7 +89,7 @@ public:
}
}
virtual void add(std::function<void(void)> work) override {
void add(std::function<void(void)> work) override {
// Add some work to our pile of work to do.
{
SkAutoMutexExclusive lock(fWorkLock);
@ -99,7 +99,7 @@ public:
fWorkAvailable.signal(1);
}
virtual void borrow() override {
void borrow() override {
// If there is work waiting and we're allowed to borrow work, do it.
if (fAllowBorrowing && fWorkAvailable.try_wait()) {
SkAssertResult(this->do_work());

View File

@ -131,8 +131,8 @@ public:
protected:
// overrides
virtual void incPtr(void*) override ;
virtual void decPtr(void*) override ;
void incPtr(void*) override;
void decPtr(void*) override;
};
class SkFactorySet : public SkTPtrSet<SkFlattenable::Factory> {};

View File

@ -44,8 +44,7 @@ public:
const SkIRect& clipBounds, bool isInverse);
/// Must be explicitly defined on subclasses.
virtual void blitAntiH(int x, int y, const SkAlpha antialias[],
const int16_t runs[]) override {
void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override {
SkDEBUGFAIL("How did I get here?");
}
/// May not be called on BaseSuperBlitter because it blits out of order.

View File

@ -135,8 +135,7 @@ public:
return fy - SK_Fixed1/2;
}
virtual SkFixed drawLine(int x, int stopx, SkFixed fy,
SkFixed slope) override {
SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed slope) override {
SkASSERT(x < stopx);
int count = stopx - x;
fy += SK_Fixed1/2;

View File

@ -43,8 +43,8 @@ public:
SkRect computeFastBounds(const SkRect& src) const override;
virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const override;
SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const override;
SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const override;

View File

@ -28,12 +28,11 @@ public:
const SkMatrix& viewMatrix() const { return fViewMatrix; }
const SkMatrix& localMatrix() const { return fLocalMatrix; }
virtual void getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override;
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
virtual bool isPathRendering() const override { return true; }
bool isPathRendering() const override { return true; }
private:
GrPathProcessor(const SkPMColor4f&, const SkMatrix& viewMatrix, const SkMatrix& localMatrix);

View File

@ -150,7 +150,7 @@ class GLCircularRRectEffect : public GrGLSLFragmentProcessor {
public:
GLCircularRRectEffect() = default;
virtual void emitCode(EmitArgs&) override;
void emitCode(EmitArgs&) override;
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);

View File

@ -52,7 +52,7 @@ public:
sk_sp<SkImage> onReinterpretColorSpace(sk_sp<SkColorSpace>) const final;
virtual bool isYUVA() const override { return true; }
bool isYUVA() const override { return true; }
bool setupMipmapsForPlanes(GrRecordingContext*) const;

View File

@ -82,7 +82,7 @@ public:
return SkStream::MakeFromFile(fPathName.c_str());
}
virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const override {
void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const override {
SkASSERT(desc);
SkASSERT(serialize);
desc->setFamilyName(fFamilyName.c_str());
@ -134,8 +134,7 @@ public:
, fData(std::move(data))
{ }
virtual void onGetFontDescriptor(SkFontDescriptor* desc,
bool* serialize) const override {
void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const override {
SkASSERT(desc);
SkASSERT(serialize);
desc->setFamilyName(fFamilyName.c_str());
@ -353,14 +352,14 @@ protected:
return nullptr;
}
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
const SkFontStyle& style) const override {
SkTypeface* onMatchFamilyStyle(const char familyName[],
const SkFontStyle& style) const override {
sk_sp<SkFontStyleSet> sset(this->matchFamily(familyName));
return sset->matchStyle(style);
}
virtual SkTypeface* onMatchFaceStyle(const SkTypeface* typeface,
const SkFontStyle& style) const override {
SkTypeface* onMatchFaceStyle(const SkTypeface* typeface,
const SkFontStyle& style) const override {
for (int i = 0; i < fStyleSets.count(); ++i) {
for (int j = 0; j < fStyleSets[i]->fStyles.count(); ++j) {
if (fStyleSets[i]->fStyles[j].get() == typeface) {
@ -403,12 +402,11 @@ protected:
return nullptr;
}
virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[],
const SkFontStyle& style,
const char* bcp47[],
int bcp47Count,
SkUnichar character) const override
{
SkTypeface* onMatchFamilyStyleCharacter(const char familyName[],
const SkFontStyle& style,
const char* bcp47[],
int bcp47Count,
SkUnichar character) const override {
// The variant 'elegant' is 'not squashed', 'compact' is 'stays in ascent/descent'.
// The variant 'default' means 'compact and elegant'.
// As a result, it is not possible to know the variant context from the font alone.

View File

@ -760,8 +760,7 @@ private:
return new GrGLPerlinNoise;
}
virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GrGLPerlinNoise::GenKey(*this, caps, b);
}

View File

@ -1589,18 +1589,18 @@ public:
, fType(type)
, fPrecision(precision) {}
virtual SpvId getPointer() override {
SpvId getPointer() override {
return fPointer;
}
virtual SpvId load(OutputStream& out) override {
SpvId load(OutputStream& out) override {
SpvId result = fGen.nextId();
fGen.writeInstruction(SpvOpLoad, fType, result, fPointer, out);
fGen.writePrecisionModifier(fPrecision, result);
return result;
}
virtual void store(SpvId value, OutputStream& out) override {
void store(SpvId value, OutputStream& out) override {
fGen.writeInstruction(SpvOpStore, fPointer, value, out);
}
@ -1623,11 +1623,11 @@ public:
, fSwizzleType(swizzleType)
, fPrecision(precision) {}
virtual SpvId getPointer() override {
SpvId getPointer() override {
return 0;
}
virtual SpvId load(OutputStream& out) override {
SpvId load(OutputStream& out) override {
SpvId base = fGen.nextId();
fGen.writeInstruction(SpvOpLoad, fGen.getType(fBaseType), base, fVecPointer, out);
fGen.writePrecisionModifier(fPrecision, base);
@ -1644,7 +1644,7 @@ public:
return result;
}
virtual void store(SpvId value, OutputStream& out) override {
void store(SpvId value, OutputStream& out) override {
// use OpVectorShuffle to mix and match the vector components. We effectively create
// a virtual vector out of the concatenation of the left and right vectors, and then
// select components from this virtual vector to make the result vector. For

View File

@ -27,7 +27,7 @@ struct Field : public Symbol {
, fOwner(owner)
, fFieldIndex(fieldIndex) {}
virtual String description() const override {
String description() const override {
return fOwner.description() + "." + fOwner.fType.fields()[fFieldIndex].fName;
}

View File

@ -20,7 +20,7 @@ struct Nop : public Statement {
Nop()
: INHERITED(-1, kNop_Kind) {}
virtual bool isEmpty() const override {
bool isEmpty() const override {
return true;
}

View File

@ -30,7 +30,7 @@ struct Symbol : public IRNode {
, fKind(kind)
, fName(name) {}
virtual ~Symbol() override {}
~Symbol() override {}
Kind fKind;
StringFragment fName;

View File

@ -48,7 +48,7 @@ struct Variable : public Symbol {
SkASSERT(!fReadCount && !fWriteCount);
}
virtual String description() const override {
String description() const override {
return fModifiers.description() + fType.fName + " " + fName;
}

View File

@ -98,7 +98,7 @@ public:
return fTokenTracker.nextDrawToken();
}
virtual GrDeferredUploadToken addASAPUpload(GrDeferredTextureUploadFn&& upload) final {
GrDeferredUploadToken addASAPUpload(GrDeferredTextureUploadFn&& upload) final {
return fTokenTracker.nextTokenToFlush();
}

View File

@ -661,7 +661,7 @@ struct CountingBBH : public SkBBoxHierarchy {
}
void insert(const SkRect[], int) override {}
virtual size_t bytesUsed() const override { return 0; }
size_t bytesUsed() const override { return 0; }
};
class SpoonFedBBHFactory : public SkBBHFactory {

View File

@ -123,7 +123,7 @@ private:
this->cloneAndRegisterAllChildProcessors(that);
}
virtual GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
class TestGLSLFP : public GrGLSLFragmentProcessor {
public:
TestGLSLFP() {}

View File

@ -78,8 +78,7 @@ public:
private:
BigKeyProcessor() : INHERITED(kBigKeyProcessor_ClassID, kNone_OptimizationFlags) { }
virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLBigKeyProcessor::GenKey(*this, caps, b);
}
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }

View File

@ -21,7 +21,7 @@ class GLTestContext : public TestContext {
public:
~GLTestContext() override;
virtual GrBackendApi backend() override { return GrBackendApi::kOpenGL; }
GrBackendApi backend() override { return GrBackendApi::kOpenGL; }
/** Does this represent a successfully created GL context? */
bool isValid() const;

View File

@ -19,7 +19,7 @@ public:
MockTestContext() {}
~MockTestContext() override {}
virtual GrBackendApi backend() override { return GrBackendApi::kMock; }
GrBackendApi backend() override { return GrBackendApi::kMock; }
void testAbandon() override {}
void finish() override {}

View File

@ -20,7 +20,7 @@ class GrVkExtensions;
namespace sk_gpu_test {
class VkTestContext : public TestContext {
public:
virtual GrBackendApi backend() override { return GrBackendApi::kVulkan; }
GrBackendApi backend() override { return GrBackendApi::kVulkan; }
const GrVkBackendContext& getVkBackendContext() const {
return fVk;