[cfe-dev] Check C++ Bad Override

Nico Weber thakis at chromium.org
Fri Oct 7 07:33:11 PDT 2011


Hi,

On Fri, Oct 7, 2011 at 7:12 AM, 章磊 <ioripolo at gmail.com> wrote:
> 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() {}
> };

Isn't this caught by -Woverloaded-virtual?

> 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 {}
> };

hans prototyped something like this at
http://llvm.org/bugs/show_bug.cgi?id=10234 , but it seemed to noisy to
be useful. (I haven't read how your patch does this though).

Nico

>
> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>




More information about the cfe-dev mailing list