Title: [199288] trunk/Tools
- Revision
- 199288
- Author
- [email protected]
- Date
- 2016-04-10 17:10:17 -0700 (Sun, 10 Apr 2016)
Log Message
[Tools] correctly check for braces in multiline branches in macro definition
https://bugs.webkit.org/show_bug.cgi?id=156441
Patch by Caitlin Potter <[email protected]> on 2016-04-10
Reviewed by Darin Adler.
Prevents emitting whitespace/braces warning for code like the
following:
```
#define MACRO(x) \
if (x) { \
doTheThing(); \
continue; \
}
```
* Scripts/webkitpy/style/checkers/cpp.py:
(check_braces):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(WebKitStyleTest.test_line_breaking):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (199287 => 199288)
--- trunk/Tools/ChangeLog 2016-04-10 19:04:41 UTC (rev 199287)
+++ trunk/Tools/ChangeLog 2016-04-11 00:10:17 UTC (rev 199288)
@@ -1,3 +1,26 @@
+2016-04-10 Caitlin Potter <[email protected]>
+
+ [Tools] correctly check for braces in multiline branches in macro definition
+ https://bugs.webkit.org/show_bug.cgi?id=156441
+
+ Reviewed by Darin Adler.
+
+ Prevents emitting whitespace/braces warning for code like the
+ following:
+
+ ```
+ #define MACRO(x) \
+ if (x) { \
+ doTheThing(); \
+ continue; \
+ }
+ ```
+
+ * Scripts/webkitpy/style/checkers/cpp.py:
+ (check_braces):
+ * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+ (WebKitStyleTest.test_line_breaking):
+
2016-04-08 Youenn Fablet <[email protected]>
Testharness-based tests that time out should be able to produce a detailed output
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (199287 => 199288)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2016-04-10 19:04:41 UTC (rev 199287)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2016-04-11 00:10:17 UTC (rev 199288)
@@ -2471,9 +2471,10 @@
or search(r'^#\S*', clean_lines.elided[begin_line_number + 1])):
begin_line_number = begin_line_number + 1
begin_line = clean_lines.elided[begin_line_number]
- if search(r'.*{$', begin_line):
- has_braces = True
+ if search(r'.*{(.*?\\)?$', begin_line):
+ has_braces = True
+
next_line = clean_lines.elided[begin_line_number + 1]
after_next_line = clean_lines.elided[begin_line_number + 2]
control_indent = search(r'^(?P<indentation>\s*).*', line).group('indentation')
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (199287 => 199288)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2016-04-10 19:04:41 UTC (rev 199287)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2016-04-11 00:10:17 UTC (rev 199288)
@@ -4244,6 +4244,19 @@
'WTF_MAKE_NONCOPYABLE(ClassName); WTF_MAKE_FAST_ALLOCATED;\n',
'')
self.assert_multi_line_lint(
+ '#define MyMacro(name, status) \\\n'
+ ' if (strstr(arg, #name) { \\\n'
+ ' name##_ = !status; \\\n'
+ ' continue; \\\n'
+ ' }\n',
+ '')
+ self.assert_multi_line_lint(
+ '#define MyMacro(name, status) \\\n'
+ ' if (strstr(arg, #name) \\\n'
+ ' name##_ = !status; \\\n'
+ ' continue;\n',
+ 'Multi line control clauses should use braces. [whitespace/braces] [4]')
+ self.assert_multi_line_lint(
'if (condition) {\n'
' doSomething();\n'
' doSomethingAgain();\n'
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes