Title: [207559] trunk/Tools
Revision
207559
Author
commit-qu...@webkit.org
Date
2016-10-19 12:50:40 -0700 (Wed, 19 Oct 2016)

Log Message

check-webkit-style: fix false-positive warnings about using #pragma once header guard
https://bugs.webkit.org/show_bug.cgi?id=163575

Patch by Joseph Pecoraro <pecor...@apple.com> on 2016-10-19
Reviewed by Brady Eidson.

There were some false positive warnings about header guards
for ObjC headers that don't need guards. This changes the
style checker to no longer warn if there is no #pragma once.
It only warns if there are #ifndef that should be #pragma once.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_for_header_guard):
Change when we output an error.

* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTest.test_build_header_guard):
Update tests.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (207558 => 207559)


--- trunk/Tools/ChangeLog	2016-10-19 19:45:49 UTC (rev 207558)
+++ trunk/Tools/ChangeLog	2016-10-19 19:50:40 UTC (rev 207559)
@@ -1,3 +1,23 @@
+2016-10-19  Joseph Pecoraro  <pecor...@apple.com>
+
+        check-webkit-style: fix false-positive warnings about using #pragma once header guard
+        https://bugs.webkit.org/show_bug.cgi?id=163575
+
+        Reviewed by Brady Eidson.
+
+        There were some false positive warnings about header guards
+        for ObjC headers that don't need guards. This changes the
+        style checker to no longer warn if there is no #pragma once.
+        It only warns if there are #ifndef that should be #pragma once.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_for_header_guard):
+        Change when we output an error.
+
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (CppStyleTest.test_build_header_guard):
+        Update tests.
+
 2016-10-19  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [macOS] [iOS] Disable variation fonts on macOS El Capitan and iOS 9

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2016-10-19 19:45:49 UTC (rev 207558)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2016-10-19 19:50:40 UTC (rev 207559)
@@ -899,8 +899,8 @@
 def check_for_header_guard(lines, error):
     """Checks that the file contains a header guard.
 
-    Logs an error if no #pragma once header guard is present
-    of if there was an #ifndef guard that was modified.
+    Logs an error if there was an #ifndef guard in a header
+    that should be a #pragma once guard.
 
     Args:
       lines: An array of strings, each representing a line of the file.
@@ -921,10 +921,7 @@
                     'Use #pragma once instead of #ifndef for header guard.')
                 return
 
-    error(0, 'build/header_guard', 5,
-        'Use #pragma once header guard.')
 
-
 def check_for_unicode_replacement_characters(lines, error):
     """Logs an error for each line containing Unicode replacement characters.
 

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2016-10-19 19:45:49 UTC (rev 207558)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2016-10-19 19:50:40 UTC (rev 207559)
@@ -2427,16 +2427,14 @@
     def test_build_header_guard(self):
         rules = ('-', '+build/header_guard')
 
-        # No header guard.
-        self.assert_header_guard('',
-            'Use #pragma once header guard.'
-            '  [build/header_guard] [5]')
-
         # Old header guard.
         self.assert_header_guard('#ifndef Foo_h',
             'Use #pragma once instead of #ifndef for header guard.'
             '  [build/header_guard] [5]')
 
+        # No header guard. Okay, since this could be an ObjC header.
+        self.assert_header_guard('', '')
+
         # Valid header guard.
         self.assert_header_guard('#pragma once', '')
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to