roll clang 131935:132017

clang recently added a warning that warns when invoking 'delete' on a polymorphic non-final class without a virtual destructor. This finds real bugs – see the bug referenced below for a few examples.

However, one common pattern where it fires is this case:

class SomeInterface {
public:
virtual void interfaceMethod() {} // or = 0;
protected:
~SomeInterface() {}
}

class WorkerClass : public SomeInterface {
public:
// many non-virtual functions, but also:
virtual void interfaceMethod() override { /* do actual work */ }
};

void f() {
scoped_ptr<WorkerClass> c(new WorkerClass); // simplified example
}

(See the 2nd half of http://www.gotw.ca/publications/mill18.htm for an explanation of this pattern.)

It is arguably correct to fire the warning here, since someone might make a subclass of WorkerClass and replace |new WorkerClass| with |new WorkerClassSubclass|. This would be broken since WorkerClass doesn't have a virtual destructor.

The solution that the clang folks recommend is to mark WorkerClass as |final| (a c++0x keyword that clang supports as an extension in normal c++ mode – like override). But chrome's base/OWNERS deemed that as too complicated and we decided to make virtual the destructors of leaf classes that implement these interfaces and that are deleted dynamically. All of the changes in this CL are to shut up the warning, not because of real problems (I fixed these in separate CLs).

(For the gtk files, this is necessary because the CHROMEGTK_CALLBACK_ macros add virtual functions.)

BUG=84424
TEST=none

Review URL: http://codereview.chromium.org/7087028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88270 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 35343fe733e22eb1a7fcb99a9d077d0b668c28ea
1 file changed
tree: 4a4076dfe52e48b5faac7919deb01c27d3db59b5
  1. base/
  2. build/
  3. ipc/
  4. testing/
  5. third_party/