[Lldb-commits] [lldb] r222186 - Fix override/virtual warnings.

+lldb-dev

I’m actually ok just migrating towards override slowly (i.e. when you touch a class that overrides some methods, add the override keyword), but if people think it should be all or nothing (and if nobody else volunteers to help with the “all” part), then I guess I’ll do it.

Eric, or anyone else: Is there a compiler flag that will warn or error if a virtual method in a derived class overrides one in a base class but does not use the override keyword? Otherwise it’s going to be difficult to find all the places that require changing.

+lldb-dev

I’m actually ok just migrating towards override slowly (i.e. when you touch a class that overrides some methods, add the override keyword), but if people think it should be all or nothing (and if nobody else volunteers to help with the “all” part), then I guess I’ll do it.

Eric, or anyone else: Is there a compiler flag that will warn or error if a virtual method in a derived class overrides one in a base class but does not use the override keyword? Otherwise it’s going to be difficult to find all the places that require changing.

Not sure, it’s not my specialty :slight_smile:

Dave?

-eric

+lldb-dev

I'm actually ok just migrating towards override slowly (i.e. when you
touch a class that overrides some methods, add the override keyword), but
if people think it should be all or nothing (and if nobody else volunteers
to help with the "all" part), then I guess I'll do it.

Eric, or anyone else: Is there a compiler flag that will warn or error if
a virtual method in a derived class overrides one in a base class but does
not use the override keyword? Otherwise it's going to be difficult to find
all the places that require changing.

Not sure, it's not my specialty :slight_smile:

Dave?

No warning for all cases of override. There's a clang-tidy warning for it
or a clang warning for "you have at least one use of 'override' in this
class, and there are other places in the class you could be using it"

So if you've got a cmake build, you can use that to generate the necessary
compilation database to integrate with tooling to run clang-tidy over and
automatically apply all the fixes. (not sure if it goes and removes virtual
too, while you're there - maybe there's a separate clang-tidy diagnostic
for that you can use)

- David

Maybe the simplest thing to do is find the code for the “you have at least one use of override”, change 1 to 0, and then use that version of clang :slight_smile: