summaryrefslogtreecommitdiffstats
path: root/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/style/checkers/cpp.py')
-rw-r--r--WebKitTools/Scripts/webkitpy/style/checkers/cpp.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py b/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
index 611afdc..770ab40 100644
--- a/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
+++ b/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
@@ -1884,6 +1884,10 @@ def check_for_null(file_extension, clean_lines, line_number, error):
if search(r'\bg_str(join|concat)\b', line):
return
+ # Don't warn about NULL usage in gdk_pixbuf_save_to_*{join,concat}(). See Bug 43090.
+ if search(r'\bgdk_pixbuf_save_to\w+\b', line):
+ return
+
if search(r'\bNULL\b', line):
error(line_number, 'readability/null', 5, 'Use 0 instead of NULL.')
return
@@ -1916,7 +1920,7 @@ def get_line_width(line):
return len(line)
-def check_style(clean_lines, line_number, file_extension, file_state, error):
+def check_style(clean_lines, line_number, file_extension, class_state, file_state, error):
"""Checks rules from the 'C++ style rules' section of cppguide.html.
Most of these rules are hard to test (naming, comment style), but we
@@ -1927,6 +1931,8 @@ def check_style(clean_lines, line_number, file_extension, file_state, error):
clean_lines: A CleansedLines instance containing the file.
line_number: The number of the line to check.
file_extension: The extension (without the dot) of the filename.
+ class_state: A _ClassState instance which maintains information about
+ the current stack of nested class declarations being parsed.
file_state: A _FileState instance which maintains information about
the state of things in the file.
error: The function to call with any errors found.
@@ -1987,6 +1993,10 @@ def check_style(clean_lines, line_number, file_extension, file_state, error):
and not ((cleansed_line.find('case ') != -1
or cleansed_line.find('default:') != -1)
and cleansed_line.find('break;') != -1)
+ # Also it's ok to have many commands in trivial single-line accessors in class definitions.
+ and not (match(r'.*\(.*\).*{.*.}', line)
+ and class_state.classinfo_stack
+ and line.count('{') == line.count('}'))
and not cleansed_line.startswith('#define ')):
error(line_number, 'whitespace/newline', 4,
'More than one command on the same line')
@@ -2841,7 +2851,7 @@ def process_line(filename, file_extension,
if search(r'\bNOLINT\b', raw_lines[line]): # ignore nolint lines
return
check_for_multiline_comments_and_strings(clean_lines, line, error)
- check_style(clean_lines, line, file_extension, file_state, error)
+ check_style(clean_lines, line, file_extension, class_state, file_state, error)
check_language(filename, clean_lines, line, file_extension, include_state,
error)
check_for_non_standard_constructs(clean_lines, line, class_state, error)