<?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>171486</bug_id>
          
          <creation_ts>2017-04-30 14:46:52 -0700</creation_ts>
          <short_desc>[Cocoa] Have check-webkit-style advise against use of [get…Class() alloc]</short_desc>
          <delta_ts>2017-05-01 14:32:54 -0700</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>WebKit Local Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>
          
          <blocked>171493</blocked>
    
    <blocked>171514</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter>mitz</reporter>
          <assigned_to>mitz</assigned_to>
          <cc>ap</cc>
    
    <cc>buildbot</cc>
    
    <cc>dbates</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>ggaren</cc>
    
    <cc>glenn</cc>
    
    <cc>lforschler</cc>
    
    <cc>sam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1303149</commentid>
    <comment_count>0</comment_count>
    <who name="">mitz</who>
    <bug_when>2017-04-30 14:46:52 -0700</bug_when>
    <thetext>It’s safer to use alloc…Instance() so the style checker could suggest that.

Patch forthcoming.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1303150</commentid>
    <comment_count>1</comment_count>
      <attachid>308701</attachid>
    <who name="">mitz</who>
    <bug_when>2017-04-30 14:49:57 -0700</bug_when>
    <thetext>Created attachment 308701
Add style check</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1303159</commentid>
    <comment_count>2</comment_count>
    <who name="">mitz</who>
    <bug_when>2017-04-30 16:40:04 -0700</bug_when>
    <thetext>Committed &lt;https://trac.webkit.org/r216000&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1303160</commentid>
    <comment_count>3</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2017-04-30 17:11:22 -0700</bug_when>
    <thetext>Can we add a unit test for this change? Notice that we have unit tests in &lt;https://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&gt;. To run the unit tests, run Tools/Scripts/test-webkitpy.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1303219</commentid>
    <comment_count>4</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2017-05-01 06:11:28 -0700</bug_when>
    <thetext>The webkitpy unit test started to fail with this change:

[1068/1576] webkitpy.style.checkers.cpp_unittest.CppStyleTest.test_spacing_before_brackets failed:                      
  Traceback (most recent call last):
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&quot;, line 1885, in test_spacing_before_brackets
      self.assert_lint(&apos;        return [get_##framework##_##className##Class() alloc]; \\&apos;, &apos;&apos;)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&quot;, line 317, in assert_lint
      self.assertEqual(expected_message, self.perform_single_line_lint(code, file_name))
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&quot;, line 270, in perform_single_line_lint
      return self.perform_lint(code, filename, basic_error_rules)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&quot;, line 259, in perform_lint
      self.process_file_data(filename, extension, lines, error_collector, unit_test_config)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&quot;, line 253, in process_file_data
      checker.check(lines)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp.py&quot;, line 3986, in check
      self.handle_style_error, self.min_confidence)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp.py&quot;, line 3846, in _process_lines
      enum_state, asm_state, error)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp.py&quot;, line 3791, in process_line
      check_style(clean_lines, line, file_extension, class_state, file_state, enum_state, error)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp.py&quot;, line 2842, in check_style
      check_soft_link_class_alloc(clean_lines, line_number, error)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp.py&quot;, line 2746, in check_soft_link_class_alloc
      &apos;Using +alloc with a soft-linked class. Use alloc%sInstance() instead.&apos; % matched.group(1))
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&quot;, line 69, in __call__
      &apos; which is not in CppChecker.categories&apos; % (message, category))
  AssertionError: Message &quot;Using +alloc with a soft-linked class. Use alloc_##framework##_##className##Instance() instead.&quot; has category &quot;runtime/soft-linked-alloc&quot;, which is not in CppChecker.categories
  
Ran 1576 tests in 5.895s                                                                                                
FAILED (failures=1, errors=0)

And fixing that results in a false-positive match for the macro:

[1056/1576] webkitpy.style.checkers.cpp_unittest.CppStyleTest.test_spacing_before_brackets failed:                      
  Traceback (most recent call last):
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&quot;, line 1885, in test_spacing_before_brackets
      self.assert_lint(&apos;        return [get_##framework##_##className##Class() alloc]; \\&apos;, &apos;&apos;)
    File &quot;./Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py&quot;, line 317, in assert_lint
      self.assertEqual(expected_message, self.perform_single_line_lint(code, file_name))
  AssertionError: &apos;&apos; != &apos;Using +alloc with a soft-linked class. Use alloc_##framework##_##className##Instance() instead.  [runtime/soft-linked-alloc] [4]&apos;
  
Ran 1576 tests in 5.756s                                                                                                
FAILED (failures=1, errors=0)

Fixed in r216013:  &lt;https://trac.webkit.org/r216013&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1303221</commentid>
    <comment_count>5</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2017-05-01 06:26:46 -0700</bug_when>
    <thetext>And FWIW, TestWebKitAPI has a few hits left:

$ ./Tools/Scripts/check-webkit-style --filter=-,+runtime/soft-linked-alloc Tools/TestWebKitAPI
ERROR: Tools/TestWebKitAPI/Tests/WebKit/ios/AudioSessionCategoryIOS.mm:69:  Using +alloc with a soft-linked class. Use allocUIWindowInstance() instead.  [runtime/soft-linked-alloc] [4]
ERROR: Tools/TestWebKitAPI/Tests/WebKit/ios/AudioSessionCategoryIOS.mm:70:  Using +alloc with a soft-linked class. Use allocUIWebViewInstance() instead.  [runtime/soft-linked-alloc] [4]
ERROR: Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RequiresUserActionForPlayback.mm:76:  Using +alloc with a soft-linked class. Use allocUIWindowInstance() instead.  [runtime/soft-linked-alloc] [4]
Total errors found: 3 in 755 files

Filed: Bug 171493: [Cocoa] Replace uses of [get…Class() alloc] with alloc…Instance() in TestWebKitAPI
&lt;https://bugs.webkit.org/show_bug.cgi?id=171493&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1303409</commentid>
    <comment_count>6</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2017-05-01 14:32:54 -0700</bug_when>
    <thetext>And Source/WebCore has a couple left, too:

$ ./Tools/Scripts/check-webkit-style --filter=-,+runtime/soft-linked-alloc Source/WebCore
ERROR: Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm:447:  Using +alloc with a soft-linked class. Use allocWebAVPictureInPicturePlayerLayerViewInstance() instead.  [runtime/soft-linked-alloc] [4]
ERROR: Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm:616:  Using +alloc with a soft-linked class. Use allocWebAVPlayerLayerViewInstance() instead.  [runtime/soft-linked-alloc] [4]
Total errors found: 2 in 8492 files

Filed: Bug 171514: [Cocoa] Replace uses of [get…Class() alloc] in Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>308701</attachid>
            <date>2017-04-30 14:49:57 -0700</date>
            <delta_ts>2017-04-30 15:17:23 -0700</delta_ts>
            <desc>Add style check</desc>
            <filename>bug-171486-20170430144956.patch</filename>
            <type>text/plain</type>
            <size>2339</size>
            <attacher>mitz</attacher>
            
              <data encoding="base64">SW5kZXg6IFRvb2xzL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBUb29scy9DaGFuZ2VMb2cJKHJl
dmlzaW9uIDIxNTk5OSkKKysrIFRvb2xzL0NoYW5nZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwz
ICsxLDE1IEBACisyMDE3LTA0LTMwICBEYW4gQmVybnN0ZWluICA8bWl0ekBhcHBsZS5jb20+CisK
KyAgICAgICAgW0NvY29hXSBIYXZlIGNoZWNrLXdlYmtpdC1zdHlsZSBhZHZpc2UgYWdhaW5zdCB1
c2Ugb2YgW2dldOKApkNsYXNzKCkgYWxsb2NdCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQu
b3JnL3Nob3dfYnVnLmNnaT9pZD0xNzE0ODYKKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkg
KE9PUFMhKS4KKworICAgICAgICAqIFNjcmlwdHMvd2Via2l0cHkvc3R5bGUvY2hlY2tlcnMvY3Bw
LnB5OgorICAgICAgICAoY2hlY2tfc29mdF9saW5rX2NsYXNzX2FsbG9jKTogQWRkZWQuIExvb2tz
IGZvciBbZ2V04oCmQ2xhc3MoKSBhbGxvY10gYW5kIHN1Z2dlc3RzCisgICAgICAgICAgYWxsb2Pi
gKZJbnN0YW5jZSgpIGlu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YXRpb25fYW1vdW50KGNsZWFuX2xpbmVzLCBsaW5lX251bWJlciwgZXJyb3IpCiAgICAgY2hlY2tf
ZW51bV9jYXNpbmcoY2xlYW5fbGluZXMsIGxpbmVfbnVtYmVyLCBlbnVtX3N0YXRlLCBlcnJvcikK
IAo=
</data>
<flag name="review"
          id="329838"
          type_id="1"
          status="+"
          setter="sam"
    />
          </attachment>
      

    </bug>

</bugzilla>