Bug 123406

Summary: check-webkit-style should support C++11 rvalue references
Product: WebKit Reporter: Sergio Villar Senin <svillar>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, bfulgham, cjerdonek, commit-queue, glenn, gustavo, llango.u-szeged, ossy, rniwa, sam, svillar, zan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Sergio Villar Senin 2013-10-28 08:54:49 PDT
The script currently considers:

T&&

as a mistake due to the missing whitespace before the two ampersands.
Comment 1 László Langó 2013-11-20 01:11:46 PST
Created attachment 217405 [details]
Patch
Comment 2 Zan Dobersek 2013-11-20 03:37:29 PST
Comment on attachment 217405 [details]
Patch

This looks OK, but a small test case should be included.
Comment 3 László Langó 2013-11-20 03:45:03 PST
(In reply to comment #2)
> (From update of attachment 217405 [details])
> This looks OK, but a small test case should be included.

Ok, i'm on it.
Comment 4 László Langó 2013-11-20 04:48:41 PST
Created attachment 217418 [details]
Patch
Comment 5 Brent Fulgham 2013-11-20 09:29:51 PST
Comment on attachment 217418 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=217418&action=review

A good start, but I think your logic in the "check_style" change is flawed. I think you allow rvalue references now at the cost of ignoring boolean expressions crossing multiple lines.  Please add a test for the multiple-line case and fix the logic for identifying rvalue references.

> Tools/Scripts/webkitpy/style/checkers/cpp.py:2626
> +    if cleansed_line.strip().endswith('||') or cleansed_line.strip().endswith(' &&'):

Won't strip() remove all the whitespace?  Will we ever match ' &&'?

> Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:629
> +        self.assert_lint('T&&', '')

We also need a test that shows that we catch instances of boolean expressions spanning multiple lines.  I believe that your change will break that style check. You can prove me wrong by including a test case!  :-)
Comment 6 László Langó 2013-11-20 23:05:32 PST
(In reply to comment #5)
> (From update of attachment 217418 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=217418&action=review
> 
> A good start, but I think your logic in the "check_style" change is flawed. I think you allow rvalue references now at the cost of ignoring boolean expressions crossing multiple lines.  Please add a test for the multiple-line case and fix the logic for identifying rvalue references.
> 
> > Tools/Scripts/webkitpy/style/checkers/cpp.py:2626
> > +    if cleansed_line.strip().endswith('||') or cleansed_line.strip().endswith(' &&'):
> 
> Won't strip() remove all the whitespace?  Will we ever match ' &&'?
> 
> > Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:629
> > +        self.assert_lint('T&&', '')
> 
> We also need a test that shows that we catch instances of boolean expressions spanning multiple lines.  I believe that your change will break that style check. You can prove me wrong by including a test case!  :-)

stip() method only remove the leading end trailing whitespaces. It won't remove the whitespace before '&&'. Just to be sure a i checked it before i uploaded the patch. End already exists a test that check the multiline conditions (last assert in 'test_brace_at_begin_of_line').
Comment 7 Brent Fulgham 2013-11-20 23:19:48 PST
Comment on attachment 217418 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=217418&action=review

R=me

>>> Tools/Scripts/webkitpy/style/checkers/cpp.py:2626
>>> +    if cleansed_line.strip().endswith('||') or cleansed_line.strip().endswith(' &&'):
>> 
>> Won't strip() remove all the whitespace?  Will we ever match ' &&'?
> 
> stip() method only remove the leading end trailing whitespaces. It won't remove the whitespace before '&&'. Just to be sure a i checked it before i uploaded the patch. End already exists a test that check the multiline conditions (last assert in 'test_brace_at_begin_of_line').

Great! Thanks for confirming.
Comment 8 WebKit Commit Bot 2013-11-20 23:43:49 PST
Comment on attachment 217418 [details]
Patch

Clearing flags on attachment: 217418

Committed r159612: <http://trac.webkit.org/changeset/159612>
Comment 9 WebKit Commit Bot 2013-11-20 23:43:51 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 László Langó 2014-03-21 05:58:36 PDT
*** Bug 73395 has been marked as a duplicate of this bug. ***