Skip to content

"Wasteful virtuals" "virtuals with no overrides" has false positives with multiple levels of inheritance #14

Description

@dmachaj

Describe the bug
I was using the "wasteful virtuals" heuristic to try and optimize a large binary. The "virtuals with no overrides" list specifically is easy gains. However, one of the methods flagged does have overrides and removing the virtual keyword introduced a build break.

On closer inspection the problem seems to be that the virtual method and the override has at least one other derived class in the middle.

The heirarchy is roughly as follows:

class A
{
public:
   virtual void DoStuff() { }
};

class B : public A
{ };

class C : public B
{
public:
    void DoStuff() override { }
};

In this case A::DoStuff is considered a wasteful virtual even though C::DoStuff overrides it. Removing the virtual keyword will introduce a build break.

Expected behavior
This method should not be considered wasteful.

Screenshots
N/A

Environment Details
OS is Windows 11.
SizeBench is latest version from the Store at this time (on a different device so I don't have the exact version handy).

Additional context
N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions