[cfe-dev] Check C++ Bad Override

章磊 ioripolo at gmail.com
Fri Oct 7 07:12:02 PDT 2011


Hi Clang,

The attached patch adds a C++ Checker to clang, it checks whether
there are mistakes in override.

The mistake mean things like this:

class base {
  virtual void foo() const {/*...*/}
};

class child: public base {
  /* child::foo is probably meant to override base::foo but type
signatures don't match
  perfectly */
  void foo() {}
};

and this:

class base {
  void foo() const {}
};

class child: public base {
  /* child::foo is probably meant to override base::foo but
 that function is not virtual. */
  void foo() const {}
};

I implement this as a static analysis checker, because i think it's
not too visible and not too fast.

I will appreciate it if there are any advice about this patch.

-- 
Best regards!

Lei Zhang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OverrideChecker.patch
Type: text/x-patch
Size: 6145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111007/1b411cc9/attachment.bin>


More information about the cfe-dev mailing list