[webkit-dev] WebKit style for switch statement

Darin Adler darin at apple.com
Wed Jan 20 14:23:14 PST 2010


On Jan 20, 2010, at 2:19 PM, Yong Li wrote:

> As everyone may know, current webkit style (at least for most source code) for a switch statement is like this:
>  
> switch (var) {
> case valueFirst:
>   ...
>   break;
> ...
> case valueLast:
>   ...
>   break;
> default:
>   ASSERT_NOT_REACHED()
> }

That’s not the preferred style. The preferred style (not counting indenting, which was only recently standardized) can be seen in functions like Node::isContainer. To take advantage of the warning GCC provides to help you make sure you cover all values of an enum, we leave out the default whenever possible.

Could you give a specific example in today’s WebKit code where a particular compiler is emitting a “not reached” warning?

    -- Darin



More information about the webkit-dev mailing list