[cfe-dev] Check C++ Bad Override

章磊 ioripolo at gmail.com
Fri Oct 7 19:06:54 PDT 2011


2011/10/7, Nico Weber <thakis at chromium.org>:
> 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?

Yes, it is caught by -Woverloaded-virtual. So it seems no need to
implement it as a static analysis checker. I will remove relevant code
from my patch.

>
>> 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).

thanks, i will see test my patch on some open source code. And also
read hans's patch to see what i can do in static analysis.

>
> 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
>>
>>
>


-- 
Best regards!

Lei Zhang




More information about the cfe-dev mailing list