diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-18 15:53:33 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-18 15:53:33 +0200 |
commit | 6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2 (patch) | |
tree | d9c68d1cca0b3e352f1e438561f3e504e641a08f /Tools/Scripts/webkitpy/style/checkers/cpp.py | |
parent | d0424a769059c84ae20beb3c217812792ea6726b (diff) | |
download | qtwebkit-6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2.tar.gz |
Imported WebKit commit c7503cef7ecb236730d1309676ab9fc723fd061d (http://svn.webkit.org/repository/webkit/trunk@128886)
New snapshot with various build fixes
Diffstat (limited to 'Tools/Scripts/webkitpy/style/checkers/cpp.py')
-rw-r--r-- | Tools/Scripts/webkitpy/style/checkers/cpp.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp.py b/Tools/Scripts/webkitpy/style/checkers/cpp.py index c573482c0..a0051c979 100644 --- a/Tools/Scripts/webkitpy/style/checkers/cpp.py +++ b/Tools/Scripts/webkitpy/style/checkers/cpp.py @@ -2040,6 +2040,26 @@ def check_namespace_indentation(clean_lines, line_number, file_extension, file_s break; +def check_directive_indentation(clean_lines, line_number, file_state, error): + """Looks for indentation of preprocessor directives. + + 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. + + indented_preprocessor_directives = match(r'\s+#', line) + if not indented_preprocessor_directives: + return + + error(line_number, 'whitespace/indent', 4, 'preprocessor directives (e.g., #ifdef, #define, #import) should never be indented.') + + def check_using_std(clean_lines, line_number, file_state, error): """Looks for 'using std::foo;' statements which should be replaced with 'using namespace std;'. @@ -2567,7 +2587,10 @@ def check_style(clean_lines, line_number, file_extension, class_state, file_stat and not (match(r'.*\(.*\).*{.*.}', line) and class_state.classinfo_stack and line.count('{') == line.count('}')) - and not cleansed_line.startswith('#define ')): + and not cleansed_line.startswith('#define ') + # It's ok to use use WTF_MAKE_NONCOPYABLE and WTF_MAKE_FAST_ALLOCATED macros in 1 line + and not (cleansed_line.find("WTF_MAKE_NONCOPYABLE") != -1 + and cleansed_line.find("WTF_MAKE_FAST_ALLOCATED") != -1)): error(line_number, 'whitespace/newline', 4, 'More than one command on the same line') @@ -2578,6 +2601,7 @@ def check_style(clean_lines, line_number, file_extension, class_state, file_stat # Some more style checks check_namespace_indentation(clean_lines, line_number, file_extension, file_state, error) + check_directive_indentation(clean_lines, line_number, 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) |