Modified: trunk/Tools/ChangeLog (173173 => 173174)
--- trunk/Tools/ChangeLog 2014-09-02 16:00:14 UTC (rev 173173)
+++ trunk/Tools/ChangeLog 2014-09-02 16:03:41 UTC (rev 173174)
@@ -1,3 +1,17 @@
+2014-09-02 Renato Nagy <[email protected]>
+
+ check-webkit-style should complain about C++ comments in Platform.h
+ https://bugs.webkit.org/show_bug.cgi?id=133802
+
+ Reviewed by Csaba Osztrogonác.
+
+ * Scripts/webkitpy/style/checkers/cpp.py:
+ (check_platformh_comments):
+ (_process_lines):
+ (CppChecker):
+ * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+ (CppStyleTest.test_platformh_comment):
+
2014-09-02 Brendan Long <[email protected]>
[Gtk] Make install-dependencies work on Arch Linux
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (173173 => 173174)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2014-09-02 16:00:14 UTC (rev 173173)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2014-09-02 16:03:41 UTC (rev 173174)
@@ -3683,6 +3683,13 @@
'Add #include ' + required_header_unstripped + ' for ' + template)
+def check_platformh_comments(lines, error):
+ for line_number, line in enumerate(lines):
+ if line_number not in (0, len(lines) - 1):
+ if line.find("//") != -1:
+ error(line_number, 'build/cpp_comment', 5, 'CPP comments are not allowed in Platform.h, '
+ 'please use C comments /* ... */')
+
def process_line(filename, file_extension,
clean_lines, line, include_state, function_state,
class_state, file_state, enum_state, asm_state, error):
@@ -3765,6 +3772,8 @@
if file_extension == 'h':
check_for_header_guard(filename, lines, error)
+ if filename == 'Source/WTF/wtf/Platform.h':
+ check_platformh_comments(lines, error)
remove_multi_line_comments(lines, error)
clean_lines = CleansedLines(lines)
@@ -3811,6 +3820,7 @@
'build/storage_class',
'build/using_std',
'build/using_namespace',
+ 'build/cpp_comment',
'legal/copyright',
'readability/braces',
'readability/casting',
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (173173 => 173174)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2014-09-02 16:00:14 UTC (rev 173173)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2014-09-02 16:03:41 UTC (rev 173174)
@@ -1141,6 +1141,44 @@
2, # One per line.
error_collector.result_list().count(multiline_string_error_message))
+ def test_platformh_comments(self):
+ check_platformh_message = (
+ 'CPP comments are not allowed in Platform.h, '
+ 'please use C comments /* ... */ [build/cpp_comment] [5]')
+
+ platformh_file_path = 'Source/WTF/wtf/Platform.h'
+
+ # CPP comment are not allowed in Platform.h header file.
+ error_collector = ErrorCollector(self.assertTrue)
+ self.process_file_data(platformh_file_path, 'h',
+ ['// This is a cpp comment.'],
+ error_collector)
+ self.assertEqual(
+ 1,
+ error_collector.result_list().count(check_platformh_message))
+
+ # C comments are allowed in Platform.h
+ error_collector = ErrorCollector(self.assertTrue)
+ self.process_file_data(platformh_file_path, 'h',
+ ['/* This is a C comment.*/'],
+ error_collector)
+ self.assertEqual(
+ 0,
+ error_collector.result_list().count(check_platformh_message))
+
+ platformh_file_path = 'Source/WTF/wtf/platform.h'
+
+ # CPP comment are allowed in other header files.
+ error_collector = ErrorCollector(self.assertTrue)
+ self.process_file_data(platformh_file_path, 'h',
+ ['// This is a cpp comment.'
+ '// The filepath is not'
+ '// Source/WTF/wtf/Platform.h'],
+ error_collector)
+ self.assertEqual(
+ 0,
+ error_collector.result_list().count(check_platformh_message))
+
# Test non-explicit single-argument constructors
def test_explicit_single_argument_constructors(self):
# missing explicit is bad