Bug 48242 - check-webkit-style: false positive reported for #if macro
Summary: check-webkit-style: false positive reported for #if macro
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-25 08:42 PDT by David Kilzer (:ddkilzer)
Modified: 2010-12-03 00:33 PST (History)
6 users (show)

See Also:


Attachments
Patch (2.56 KB, patch)
2010-12-02 17:20 PST, David Levin
no flags Details | Formatted Diff | Diff
Patch (2.79 KB, patch)
2010-12-02 19:04 PST, David Levin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2010-10-25 08:42:14 PDT
Attachment 71742 [details] patch on Bug 46096, Comment #8 had a false-positive on an #if macro definition:

Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1
JavaScriptCore/assembler/MacroAssemblerARM.cpp:59:  More than one command on the same line in if  [whitespace/parens] [4]
Total errors found: 1 in 2 files

I believe the check-webkit-style script though this was a standard if() statement, not an #if macro.
Comment 1 David Levin 2010-12-02 17:20:14 PST
Created attachment 75440 [details]
Patch
Comment 2 Eric Seidel (no email) 2010-12-02 17:24:39 PST
Comment on attachment 75440 [details]
Patch

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

Otherwise seems fine.

> WebKitTools/Scripts/webkitpy/style/checkers/cpp.py:1461
> +            in_preprocessor_directive = match(r'\s*#', line)

Seems you want a ^ in that regexp to lock it to the front of the string.

char* my_invalid_style = "You're #1\n"'; would trigger that regexp even though it shouldn't.
Comment 3 David Levin 2010-12-02 18:28:22 PST
(In reply to comment #2)
> (From update of attachment 75440 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=75440&action=review
> 
> Otherwise seems fine.
> 
> > WebKitTools/Scripts/webkitpy/style/checkers/cpp.py:1461
> > +            in_preprocessor_directive = match(r'\s*#', line)
> 
> Seems you want a ^ in that regexp to lock it to the front of the string.
> 
> char* my_invalid_style = "You're #1\n"'; would trigger that regexp even though it shouldn't.
Good call.
fwiw, re.match has an implicit ^ (http://docs.python.org/library/re.html#re.match).
re.search would need the ^

I wish there was only re.search (why have another function just to mean "^" + regex_given?) but match exists, so I guess it makes sense to use it.
Comment 4 David Levin 2010-12-02 18:32:14 PST
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 75440 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=75440&action=review
> > 
> > Otherwise seems fine.
> > 
> > > WebKitTools/Scripts/webkitpy/style/checkers/cpp.py:1461
> > > +            in_preprocessor_directive = match(r'\s*#', line)
> > 
> > Seems you want a ^ in that regexp to lock it to the front of the string.
> > 
> > char* my_invalid_style = "You're #1\n"'; would trigger that regexp even though it shouldn't.
> Good call.
> fwiw, re.match has an implicit ^ (http://docs.python.org/library/re.html#re.match).
> re.search would need the ^
> 
> I wish there was only re.search (why have another function just to mean "^" + regex_given?) but match exists, so I guess it makes sense to use it.

But I'll add test for this though.
Comment 5 David Levin 2010-12-02 19:04:47 PST
Created attachment 75451 [details]
Patch
Comment 6 Shinichiro Hamaji 2010-12-02 19:20:46 PST
Comment on attachment 75451 [details]
Patch

looks good
Comment 7 WebKit Commit Bot 2010-12-03 00:33:14 PST
Comment on attachment 75451 [details]
Patch

Clearing flags on attachment: 75451

Committed r73248: <http://trac.webkit.org/changeset/73248>
Comment 8 WebKit Commit Bot 2010-12-03 00:33:20 PST
All reviewed patches have been landed.  Closing bug.