[webkit-dev] Type cast by using toFoo()

Ravi Kasibhatla kasibhatla.ravi at gmail.com
Tue Oct 1 05:36:20 PDT 2013

I am the original author of style checker patch reported in previous mail
by Gyuyoung.

My logic for checking the error is simple:
- In the patch, I check for any line which contains regex static_cast<Foo*>.
- If line does contain it, I pick the regex part Foo and search for Foo.h
in the codebase.
- In Foo.h, I check for toFoo signature and if it is present, I ask the
user to use it. If the signature is not present, I throw the message of
adding the toFoo() and using it.
- In cases, where Foo.h is not found, I don't report any error (which I
plan to look in future for more refining).

I have raised the bug https://bugs.webkit.org/show_bug.cgi?id=122156 for
tracking this change in WebKit and will soon be porting the patch which got
committed in blink (

Ravi Kasibhatla.

On Tue, Oct 1, 2013 at 11:22 AM, Gyuyoung Kim <gyuyoung.kim at webkit.org>wrote:

> My plan is to show style error when submitted patch doesn't use toFoo()
> though toFoo exists. This idea was originated from blink commit. However,
> it was reverted because of some regression.
> http://src.chromium.org/viewvc/blink?view=revision&revision=158059
> If my understanding is correct, the toFoo() style checker checks if there
> is toFoo() in a class. If uploaded patch uses static_cast<> instead of
> toFoo() though there is toFoo(), style checker will generate style error.
> Anyway, I think I need to investigate the commit and consider the idea
> further.
> Gyuyoung.
> On Tue, Oct 1, 2013 at 3:20 AM, Ryosuke Niwa <rniwa at webkit.org> wrote:
>> On Mon, Sep 30, 2013 at 10:52 AM, Yong Li <yong.li.webkit at outlook.com>wrote:
>>> Bottom line is turning on RTTI in debug build?
>> Style checker analyzes the code statically.  It's nothing to do with
>> runtime assertions.  If that wasn't clear enough, style check happens
>> before WebKit is ever built.
>> - R. Niwa
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20131001/12bd183c/attachment-0001.html>

More information about the webkit-dev mailing list