<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>51695</bug_id>
          
          <creation_ts>2010-12-28 19:10:06 -0800</creation_ts>
          <short_desc>check-webkit-style treated some macros with parentheses after #elif as function calls</short_desc>
          <delta_ts>2011-01-04 23:33:24 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Koan-Sin Tan">koansin.tan</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>levin</cc>
    
    <cc>mrobinson</cc>
    
    <cc>mrowe</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>327468</commentid>
    <comment_count>0</comment_count>
    <who name="Koan-Sin Tan">koansin.tan</who>
    <bug_when>2010-12-28 19:10:06 -0800</bug_when>
    <thetext>I ran into this problem when I tried
    #elif (OS(LINUX) &amp;&amp; PLATFORM(CHROMIUM)) || (OS(DARWIN) &amp;&amp; !PLATFORM(CF))
The message is like:
   WebCore/platform/UUID.cpp:46:  Extra space before ( in function call  [whitespace/parens] [4]

I tried a bit and found that simply
   #elif (OS(LINUX))
will have the problem. As David Levin pointed out in comments 26 of bug 50867,  the issue is in the regex below from Tools/Scripts/webkitpy/style/checkers/cpp.py 

1340            if (search(r&apos;\w\s+\(&apos;, function_call)
1341                and not search(r&apos;#\s*define|typedef&apos;, function_call)):
1342                error(line_number, &apos;whitespace/parens&apos;, 4,
1343                      &apos;Extra space before ( in function call&apos;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>327538</commentid>
    <comment_count>1</comment_count>
    <who name="Koan-Sin Tan">koansin.tan</who>
    <bug_when>2010-12-29 05:03:00 -0800</bug_when>
    <thetext>
a stupid hack like this will avoid the issue, but this doesn&apos;t really look right


Index: Tools/Scripts/webkitpy/style/checkers/cpp.py
===================================================================
--- Tools/Scripts/webkitpy/style/checkers/cpp.py	(revision 74733)
+++ Tools/Scripts/webkitpy/style/checkers/cpp.py	(working copy)
@@ -1327,6 +1327,8 @@
     # they&apos;ll never need to wrap.
     if (  # Ignore control structures.
         not search(r&apos;\b(if|for|foreach|while|switch|return|new|delete)\b&apos;, function_call)
+        # Ignore (()) right after &apos;#elif &apos;.
+        and not search(r&apos;\A#elif&apos;, function_call)
         # Ignore pointers/references to functions.
         and not search(r&apos; \([^)]+\)\([^)]*(\)|,$)&apos;, function_call)
         # Ignore pointers/references to arrays.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>328180</commentid>
    <comment_count>2</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2010-12-31 09:05:58 -0800</bug_when>
    <thetext>(In reply to comment #1)
&gt; a stupid hack like this will avoid the issue, but this doesn&apos;t really look right
&gt; 
&gt; 
&gt; Index: Tools/Scripts/webkitpy/style/checkers/cpp.py
&gt; ===================================================================
&gt; --- Tools/Scripts/webkitpy/style/checkers/cpp.py    (revision 74733)
&gt; +++ Tools/Scripts/webkitpy/style/checkers/cpp.py    (working copy)
&gt; @@ -1327,6 +1327,8 @@
&gt;      # they&apos;ll never need to wrap.
&gt;      if (  # Ignore control structures.
&gt;          not search(r&apos;\b(if|for|foreach|while|switch|return|new|delete)\b&apos;, function_call)
&gt; +        # Ignore (()) right after &apos;#elif &apos;.
&gt; +        and not search(r&apos;\A#elif&apos;, function_call)
&gt;          # Ignore pointers/references to functions.
&gt;          and not search(r&apos; \([^)]+\)\([^)]*(\)|,$)&apos;, function_call)
&gt;          # Ignore pointers/references to arrays.

I  think you could simply change line 1341 to
1341                and not match(r&apos;\s*(#|typedef)&apos;, function_call)):

Which will allow match any preprocessor directive or a typedef. (I switch from search to match because match only matches from the beginning of the line, which is why I added the \s*.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>328445</commentid>
    <comment_count>3</comment_count>
    <who name="Koan-Sin Tan">koansin.tan</who>
    <bug_when>2011-01-02 16:51:26 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; &gt; Index: Tools/Scripts/webkitpy/style/checkers/cpp.py
&gt; &gt; &gt; 
&gt; I  think you could simply change line 1341 to
&gt; 1341                and not match(r&apos;\s*(#|typedef)&apos;, function_call)):
&gt; 
&gt; Which will allow match any preprocessor directive or a typedef. (I switch from search to match because match only matches from the beginning of the line, which is why I added the \s*.)

it looks better than my stupid hack. Maybe I should mention that
   #if (OS(LINUX) &amp;&amp; PLATFORM(CHROMIUM)) || (OS(DARWIN) &amp;&amp; !PLATFORM(CF))
would not run into #elif problem, so I think maybe there is a way to avoid calling check_spacing_for_function_call</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>328469</commentid>
    <comment_count>4</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2011-01-02 19:33:20 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; &gt; Index: Tools/Scripts/webkitpy/style/checkers/cpp.py
&gt; &gt; &gt; &gt; 
&gt; &gt; I  think you could simply change line 1341 to
&gt; &gt; 1341                and not match(r&apos;\s*(#|typedef)&apos;, function_call)):
&gt; &gt; 
&gt; &gt; Which will allow match any preprocessor directive or a typedef. (I switch from search to match because match only matches from the beginning of the line, which is why I added the \s*.)
&gt; 
&gt; it looks better than my stupid hack. Maybe I should mention that
&gt;    #if (OS(LINUX) &amp;&amp; PLATFORM(CHROMIUM)) || (OS(DARWIN) &amp;&amp; !PLATFORM(CF))
&gt; would not run into #elif problem, so I think maybe there is a way to avoid calling check_spacing_for_function_call

The reason that &quot;#if&quot; doesn&apos;t trigger the warning is just plain luck. The line
         not search(r&apos;\b(if|for|foreach|while|switch|return|new|delete)\b&apos;, function_call)
excludes it but it is thereto detect the &quot;if&quot; statement. It just also happens to work for the #if preprocessor directive.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>329297</commentid>
    <comment_count>5</comment_count>
    <who name="Koan-Sin Tan">koansin.tan</who>
    <bug_when>2011-01-04 16:39:22 -0800</bug_when>
    <thetext>(In reply to comment #4)
&gt;
&gt; The reason that &quot;#if&quot; doesn&apos;t trigger the warning is just plain luck. The line
&gt;          not search(r&apos;\b(if|for|foreach|while|switch|return|new|delete)\b&apos;, function_call)
&gt; excludes it but it is thereto detect the &quot;if&quot; statement. It just also happens to work for the #if preprocessor directive.

Ah ha. Got it. So I&apos;ll submit a patch based on your comment</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>329308</commentid>
    <comment_count>6</comment_count>
      <attachid>77947</attachid>
    <who name="Koan-Sin Tan">koansin.tan</who>
    <bug_when>2011-01-04 17:14:51 -0800</bug_when>
    <thetext>Created attachment 77947
proposed patch

proposed patch as suggested by David Levin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>329319</commentid>
    <comment_count>7</comment_count>
      <attachid>77947</attachid>
    <who name="David Levin">levin</who>
    <bug_when>2011-01-04 17:26:20 -0800</bug_when>
    <thetext>Comment on attachment 77947
proposed patch

Really close!

It looks good but it needs a simple test to verify it. See cpp_unittest.py. Look for the error &quot;Extra space before (&quot; to see where similar tests are and add one which verifies that you don&apos;t get the error for the false positive (#elif if I remember correctly).

Run the test using &quot;test-webkitpy&quot; to verify that your test passes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>329368</commentid>
    <comment_count>8</comment_count>
      <attachid>77959</attachid>
    <who name="Koan-Sin Tan">koansin.tan</who>
    <bug_when>2011-01-04 18:31:31 -0800</bug_when>
    <thetext>Created attachment 77959
proposed patch

add two unit test cases</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>329450</commentid>
    <comment_count>9</comment_count>
      <attachid>77959</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2011-01-04 23:33:18 -0800</bug_when>
    <thetext>Comment on attachment 77959
proposed patch

Clearing flags on attachment: 77959

Committed r75050: &lt;http://trac.webkit.org/changeset/75050&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>329451</commentid>
    <comment_count>10</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2011-01-04 23:33:24 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>77947</attachid>
            <date>2011-01-04 17:14:51 -0800</date>
            <delta_ts>2011-01-04 18:31:31 -0800</delta_ts>
            <desc>proposed patch</desc>
            <filename>elif.diff</filename>
            <type>text/plain</type>
            <size>1579</size>
            <attacher name="Koan-Sin Tan">koansin.tan</attacher>
            
              <data encoding="base64">SW5kZXg6IFRvb2xzL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBUb29scy9DaGFuZ2VMb2cJKHJl
dmlzaW9uIDc1MDI4KQorKysgVG9vbHMvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMg
KzEsMTYgQEAKKzIwMTEtMDEtMDQgIEtvYW4tU2luIFRhbiAgPGtvYW5zaW4udGFuQGdtYWlsLmNv
bT4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBjaGVj
ay13ZWJraXQtc3R5bGUgdHJlYXR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VtYmVyLCAn
d2hpdGVzcGFjZS9wYXJlbnMnLCAyLAogICAgICAgICAgICAgICAgICAgJ0V4dHJhIHNwYWNlIGFm
dGVyICgnKQogICAgICAgICBpZiAoc2VhcmNoKHInXHdccytcKCcsIGZ1bmN0aW9uX2NhbGwpCi0g
ICAgICAgICAgICBhbmQgbm90IHNlYXJjaChyJyNccypkZWZpbmV8dHlwZWRlZicsIGZ1bmN0aW9u
X2NhbGwpKToKKyAgICAgICAgICAgIGFuZCBub3QgbWF0Y2gocidccyooI3x0eXBlZGVmKScsIGZ1
bmN0aW9uX2NhbGwpKToKICAgICAgICAgICAgIGVycm9yKGxpbmVfbnVtYmVyLCAnd2hpdGVzcGFj
ZS9wYXJlbnMnLCA0LAogICAgICAgICAgICAgICAgICAgJ0V4dHJhIHNwYWNlIGJlZm9yZSAoIGlu
IGZ1bmN0aW9uIGNhbGwnKQogICAgICAgICAjIElmIHRoZSApIGlzIGZvbGxvd2VkIG9ubHkgYnkg
YSBuZXdsaW5lIG9yIGEgeyArIG5ld2xpbmUsIGFzc3VtZSBpdCdzCg==
</data>
<flag name="review"
          id="69193"
          type_id="1"
          status="-"
          setter="levin"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>77959</attachid>
            <date>2011-01-04 18:31:31 -0800</date>
            <delta_ts>2011-01-04 23:33:18 -0800</delta_ts>
            <desc>proposed patch</desc>
            <filename>elif.diff</filename>
            <type>text/plain</type>
            <size>2496</size>
            <attacher name="Koan-Sin Tan">koansin.tan</attacher>
            
              <data encoding="base64">SW5kZXg6IFRvb2xzL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBUb29scy9DaGFuZ2VMb2cJKHJl
dmlzaW9uIDc1MDM5KQorKysgVG9vbHMvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMg
KzEs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HRzL3dlYmtpdHB5L3N0eWxlL2NoZWNrZXJzL2NwcF91bml0dGVzdC5weQkocmV2
aXNpb24gNzUwMzkpCisrKyBUb29scy9TY3JpcHRzL3dlYmtpdHB5L3N0eWxlL2NoZWNrZXJzL2Nw
cF91bml0dGVzdC5weQkod29ya2luZyBjb3B5KQpAQCAtMTQzNSw2ICsxNDM1LDggQEAgY2xhc3Mg
Q3BwU3R5bGVUZXN0KENwcFN0eWxlVGVzdEJhc2UpOgogICAgICAgICBzZWxmLmFzc2VydF9saW50
KCcoKGErYikpJywgJycpCiAgICAgICAgIHNlbGYuYXNzZXJ0X2xpbnQoJ2ZvbyAoZm9vKScsICdF
eHRyYSBzcGFjZSBiZWZvcmUgKCBpbiBmdW5jdGlvbiBjYWxsJwogICAgICAgICAgICAgICAgICAg
ICAgICAgICcgIFt3aGl0ZXNwYWNlL3BhcmVuc10gWzRdJykKKyAgICAgICAgc2VsZi5hc3NlcnRf
bGludCgnI2VsaWYgKGZvbyhiYXIpKScsICcnKQorICAgICAgICBzZWxmLmFzc2VydF9saW50KCcj
ZWxpZiAoZm9vKGJhcikgJiYgZm9vKGJheikpJywgJycpCiAgICAgICAgIHNlbGYuYXNzZXJ0X2xp
bnQoJ3R5cGVkZWYgZm9vICgqZm9vKShmb28pJywgJycpCiAgICAgICAgIHNlbGYuYXNzZXJ0X2xp
bnQoJ3R5cGVkZWYgZm9vICgqZm9vMTJiYXJfKShmb28pJywgJycpCiAgICAgICAgIHNlbGYuYXNz
ZXJ0X2xpbnQoJ3R5cGVkZWYgZm9vIChGb286OipiYXIpKGZvbyknLCAnJykK
</data>

          </attachment>
      

    </bug>

</bugzilla>