Title: [272064] trunk
Revision
272064
Author
[email protected]
Date
2021-01-29 10:11:46 -0800 (Fri, 29 Jan 2021)

Log Message

check-webkit-style: warn about WTF::BlockPtr use in _javascript_Core until ARC is enabled
<https://webkit.org/b/221108>
<rdar://problem/73726640>

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

* API/JSVirtualMachine.mm:
* inspector/remote/RemoteConnectionToTarget.h:
- Remove or replace unused <wtf/BlockPtr.h> headers.

Tools:

* Scripts/webkitpy/style/checkers/cpp.py:
(_is_javascriptcore_file): Add.
- Extract code to reuse from
  check_identifier_name_in_declaration().
(check_include_line):
(check_language):
- Add check for use of WTF::BlockPtr.
(check_identifier_name_in_declaration):
- Use _is_javascriptcore_file().
(CppChecker):
- Add 'security/_javascript_core_wtf_blockptr' to list of
  checkers.
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTestBase.perform_language_rules_check):
- Add 'security/_javascript_core_wtf_blockptr' to list of
  checkers for testing header includes.
(OrderOfIncludesTest.test_check_wtf_blockptr_usage_in_javascriptcore):
- Add test to detect use of WTF::BlockPtr in _javascript_Core.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSVirtualMachine.mm (272063 => 272064)


--- trunk/Source/_javascript_Core/API/JSVirtualMachine.mm	2021-01-29 17:34:56 UTC (rev 272063)
+++ trunk/Source/_javascript_Core/API/JSVirtualMachine.mm	2021-01-29 18:11:46 UTC (rev 272064)
@@ -38,7 +38,6 @@
 #import "SigillCrashAnalyzer.h"
 #import "SlotVisitorInlines.h"
 #import <mutex>
-#import <wtf/BlockPtr.h>
 #import <wtf/Lock.h>
 #import <wtf/RetainPtr.h>
 

Modified: trunk/Source/_javascript_Core/ChangeLog (272063 => 272064)


--- trunk/Source/_javascript_Core/ChangeLog	2021-01-29 17:34:56 UTC (rev 272063)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-01-29 18:11:46 UTC (rev 272064)
@@ -1,3 +1,15 @@
+2021-01-29  David Kilzer  <[email protected]>
+
+        check-webkit-style: warn about WTF::BlockPtr use in _javascript_Core until ARC is enabled
+        <https://webkit.org/b/221108>
+        <rdar://problem/73726640>
+
+        Reviewed by Joseph Pecoraro.
+
+        * API/JSVirtualMachine.mm:
+        * inspector/remote/RemoteConnectionToTarget.h:
+        - Remove or replace unused <wtf/BlockPtr.h> headers.
+
 2021-01-28  Yusuke Suzuki  <[email protected]>
 
         [JSC] Add JSPromise::rejectedPromise

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.h (272063 => 272064)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.h	2021-01-29 17:34:56 UTC (rev 272063)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.h	2021-01-29 18:11:46 UTC (rev 272064)
@@ -33,7 +33,7 @@
 #include <wtf/ThreadSafeRefCounted.h>
 
 #if PLATFORM(COCOA)
-#include <wtf/BlockPtr.h>
+#include <wtf/Function.h>
 #include <wtf/RetainPtr.h>
 
 OBJC_CLASS NSString;

Modified: trunk/Tools/ChangeLog (272063 => 272064)


--- trunk/Tools/ChangeLog	2021-01-29 17:34:56 UTC (rev 272063)
+++ trunk/Tools/ChangeLog	2021-01-29 18:11:46 UTC (rev 272064)
@@ -1,3 +1,30 @@
+2021-01-29  David Kilzer  <[email protected]>
+
+        check-webkit-style: warn about WTF::BlockPtr use in _javascript_Core until ARC is enabled
+        <https://webkit.org/b/221108>
+        <rdar://problem/73726640>
+
+        Reviewed by Joseph Pecoraro.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (_is_javascriptcore_file): Add.
+        - Extract code to reuse from
+          check_identifier_name_in_declaration().
+        (check_include_line):
+        (check_language):
+        - Add check for use of WTF::BlockPtr.
+        (check_identifier_name_in_declaration):
+        - Use _is_javascriptcore_file().
+        (CppChecker):
+        - Add 'security/_javascript_core_wtf_blockptr' to list of
+          checkers.
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (CppStyleTestBase.perform_language_rules_check):
+        - Add 'security/_javascript_core_wtf_blockptr' to list of
+          checkers for testing header includes.
+        (OrderOfIncludesTest.test_check_wtf_blockptr_usage_in_javascriptcore):
+        - Add test to detect use of WTF::BlockPtr in _javascript_Core.
+
 2021-01-29  Angelos Oikonomopoulos  <[email protected]>
 
         [JSC] Implement --artifact-exec-wrapper

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (272063 => 272064)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2021-01-29 17:34:56 UTC (rev 272063)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2021-01-29 18:11:46 UTC (rev 272064)
@@ -3487,6 +3487,10 @@
     return os.path.isfile(primary_header)
 
 
+def _is_javascriptcore_file(filename):
+    return filename.startswith('Source/_javascript_Core/')
+
+
 def check_include_line(filename, file_extension, clean_lines, line_number, include_state, error):
     """Check rules that are applicable to #include lines.
 
@@ -3517,6 +3521,12 @@
     include = matched.group(2)
     is_system = (matched.group(1) == '<')
 
+    # FIXME: Remove once _javascript_Core builds with ARC enabled (Bug 221117).
+    if _is_javascriptcore_file(filename) and include == 'wtf/BlockPtr.h':
+        error(line_number, 'security/_javascript_core_wtf_blockptr', 5,
+              'Replace WTF::BlockPtr with WTF::Function. '
+              'WTF::BlockPtr is not safe to use until _javascript_Core builds with ARC enabled.')
+
     # Look for any of the stream classes that are part of standard C++.
     if match(r'(f|ind|io|i|o|parse|pf|stdio|str|)?stream$', include):
         error(line_number, 'readability/streams', 3,
@@ -3720,6 +3730,12 @@
                 'Please replace ASSERT_WITH_SECURITY_IMPLICATION() with '
                 'RELEASE_ASSERT_WITH_SECURITY_IMPLICATION().')
 
+    # FIXME: Remove once _javascript_Core builds with ARC enabled (Bug 221117).
+    if _is_javascriptcore_file(filename) and search(r'\b(WTF::)?BlockPtr\s*<', line):
+        error(line_number, 'security/_javascript_core_wtf_blockptr', 5,
+              'Replace WTF::BlockPtr with WTF::Function. '
+              'WTF::BlockPtr is not safe to use until _javascript_Core builds with ARC enabled.')
+
     # Check if some verboten C functions are being used.
     if search(r'\bsprintf\b', line):
         error(line_number, 'security/printf', 5,
@@ -4010,7 +4026,7 @@
         modified_identifier = sub(r'(^|(?<=::))[ms]_', '', identifier)
         if not file_state.is_objective_c_or_objective_cpp() and modified_identifier.find('_') >= 0:
             # Various exceptions to the rule: _javascript_ op codes functions, const_iterator.
-            if (not (filename.find('_javascript_Core') >= 0 and (modified_identifier.find('op_') >= 0 or modified_identifier.find('intrinsic_') >= 0))
+            if (not (_is_javascriptcore_file(filename) and (modified_identifier.find('op_') >= 0 or modified_identifier.find('intrinsic_') >= 0))
                 and not (('gtk' in filename or 'glib' in filename or 'wpe' in filename or 'atk' in filename) and modified_identifier.startswith('webkit_'))
                 and not ('glib' in filename and modified_identifier.startswith('jsc_'))
                 and not modified_identifier.startswith('tst_')
@@ -4561,6 +4577,7 @@
         'runtime/wtf_move',
         'runtime/wtf_never_destroyed',
         'security/assertion',
+        'security/_javascript_core_wtf_blockptr',
         'security/missing_warn_unused_return',
         'security/printf',
         'security/temp_file',

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (272063 => 272064)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2021-01-29 17:34:56 UTC (rev 272063)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2021-01-29 18:11:46 UTC (rev 272064)
@@ -287,7 +287,8 @@
                              '+build/include',
                              '+build/include_order',
                              '+build/namespaces',
-                             '+runtime/rtti')
+                             '+runtime/rtti',
+                             '+security/_javascript_core_wtf_blockptr')
         return self.perform_lint(code, filename, basic_error_rules, lines_to_check=lines_to_check)
 
     # Only keep function length errors.
@@ -3233,6 +3234,59 @@
                                          '#include "b.h"\n',
                                          'Alphabetical sorting problem.  [build/include_order] [4]')
 
+    def test_check_wtf_blockptr_usage_in_javascriptcore(self):
+        # FIXME: Remove once _javascript_Core builds with ARC enabled (Bug 221117).
+        self.assert_language_rules_check(
+            'Source/_javascript_Core/foo.h',
+            '#include <wtf/BlockPtr.h>\n',
+            'Replace WTF::BlockPtr with WTF::Function.'
+            ' WTF::BlockPtr is not safe to use until _javascript_Core builds with ARC enabled.'
+            '  [security/_javascript_core_wtf_blockptr] [5]')
+
+        self.assert_language_rules_check(
+            'Source/_javascript_Core/foo.mm',
+            '#include <wtf/BlockPtr.h>\n',
+            'Replace WTF::BlockPtr with WTF::Function.'
+            ' WTF::BlockPtr is not safe to use until _javascript_Core builds with ARC enabled.'
+            '  [security/_javascript_core_wtf_blockptr] [5]')
+
+        self.assert_language_rules_check('Source/_javascript_Core/foo.h',
+                                         '#include <wtf/Function.h>\n',
+                                         '')
+
+        self.assert_language_rules_check('Source/WebCore/foo.h',
+                                         '#include <wtf/BlockPtr.h>\n',
+                                         '')
+
+        self.assert_lint(
+            'typedef Vector<BlockPtr<void ()>> RemoteTargetQueue;\n',
+            'Replace WTF::BlockPtr with WTF::Function.'
+            ' WTF::BlockPtr is not safe to use until _javascript_Core builds with ARC enabled.'
+            '  [security/_javascript_core_wtf_blockptr] [5]',
+            file_name='Source/_javascript_Core/foo.h')
+
+        self.assert_lint(
+            'BlockPtr<void(WebItemProviderFileCallback)> _callback;\n',
+            'Replace WTF::BlockPtr with WTF::Function.'
+            ' WTF::BlockPtr is not safe to use until _javascript_Core builds with ARC enabled.'
+            '  [security/_javascript_core_wtf_blockptr] [5]',
+            file_name='Source/_javascript_Core/foo.mm')
+
+        self.assert_lint(
+            'typedef Vector<Function<void ()>> RemoteTargetQueue;\n',
+            '',
+            file_name='Source/_javascript_Core/foo.h')
+
+        self.assert_lint(
+            'typedef Vector<BlockPtr<void ()>> RemoteTargetQueue;\n',
+            '',
+            file_name='Source/WebCore/foo.h')
+
+        self.assert_lint(
+            'BlockPtr<void(WebItemProviderFileCallback)> _callback;\n',
+            '',
+            file_name='Source/WebCore/foo.mm')
+
     def test_check_line_break_after_own_header(self):
         self.assert_language_rules_check('foo.cpp',
                                          '#include "config.h"\n'
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to