diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
commit | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (patch) | |
tree | b34b0daceb7c8e7fdde4b4ec43650ab7caadb0a9 /Tools/Scripts/webkitpy/style/checkers/cpp.py | |
parent | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (diff) | |
download | qtwebkit-ad0d549d4cc13433f77c1ac8f0ab379c83d93f28.tar.gz |
Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790)
Diffstat (limited to 'Tools/Scripts/webkitpy/style/checkers/cpp.py')
-rw-r--r-- | Tools/Scripts/webkitpy/style/checkers/cpp.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp.py b/Tools/Scripts/webkitpy/style/checkers/cpp.py index 27ffecaa8..f29361766 100644 --- a/Tools/Scripts/webkitpy/style/checkers/cpp.py +++ b/Tools/Scripts/webkitpy/style/checkers/cpp.py @@ -2077,6 +2077,29 @@ def check_max_min_macros(clean_lines, line_number, file_state, error): % (max_min_macro_lower, max_min_macro_lower, max_min_macro)) +def check_ctype_functions(clean_lines, line_number, file_state, error): + """Looks for use of the standard functions in ctype.h and suggest they be replaced + by use of equivilent ones in <wtf/ASCIICType.h>?. + + Args: + clean_lines: A CleansedLines instance containing the file. + line_number: The number of the line to check. + 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. + """ + + line = clean_lines.elided[line_number] # Get rid of comments and strings. + + ctype_function_search = search(r'\b(?P<ctype_function>(isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower|isprint|ispunct|isspace|isupper|isxdigit|toascii|tolower|toupper))\s*\(', line) + if not ctype_function_search: + return + + ctype_function = ctype_function_search.group('ctype_function') + error(line_number, 'runtime/ctype_function', 4, + 'Use equivelent function in <wtf/ASCIICType.h> instead of the %s() function.' + % (ctype_function)) + def check_switch_indentation(clean_lines, line_number, error): """Looks for indentation errors inside of switch statements. @@ -2540,6 +2563,7 @@ def check_style(clean_lines, line_number, file_extension, class_state, file_stat check_namespace_indentation(clean_lines, line_number, file_extension, file_state, error) check_using_std(clean_lines, line_number, file_state, error) check_max_min_macros(clean_lines, line_number, file_state, error) + check_ctype_functions(clean_lines, line_number, file_state, error) check_switch_indentation(clean_lines, line_number, error) check_braces(clean_lines, line_number, error) check_exit_statement_simplifications(clean_lines, line_number, error) @@ -2980,6 +3004,11 @@ def check_language(filename, clean_lines, line_number, file_extension, include_s check_identifier_name_in_declaration(filename, line_number, line, file_state, error) + # Check that we're not using static_cast<Text*>. + if search(r'\bstatic_cast<Text\*>', line): + error(line_number, 'readability/check', 4, + 'Consider using toText helper function in WebCore/dom/Text.h ' + 'instead of static_cast<Text*>') def check_identifier_name_in_declaration(filename, line_number, line, file_state, error): """Checks if identifier names contain any underscores. @@ -3523,6 +3552,7 @@ class CppChecker(object): 'runtime/arrays', 'runtime/bitfields', 'runtime/casting', + 'runtime/ctype_function', 'runtime/explicit', 'runtime/init', 'runtime/int', |