WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-57241-20130716123847.patch (text/plain), 4.14 KB, created by
Brian Holt
on 2013-07-16 04:38:50 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Brian Holt
Created:
2013-07-16 04:38:50 PDT
Size:
4.14 KB
patch
obsolete
>Subversion Revision: 152631 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 7f4197d54e6344d0567069fa6aef2c3492982abb..05ebfd6b8a656d372c04aab5d1d8523bc0f2d6cf 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2013-07-16 Brian Holt <brian.holt@samsung.com> >+ >+ check-webkit-style: "using namespace foo;" should be flagged as an error in headers >+ https://bugs.webkit.org/show_bug.cgi?id=57241 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added check for "using namespace foo" and unit test. >+ >+ * Scripts/webkitpy/style/checkers/cpp.py: >+ (check_using_namespace): >+ (check_style): >+ (CppChecker): >+ * Scripts/webkitpy/style/checkers/cpp_unittest.py: >+ (WebKitStyleTest.test_using_namespace): >+ > 2013-07-15 Xabier Rodriguez Calvar <calvaris@igalia.com> > > [GTK] Increase the JHBuild version of GStreamer to 1.0.7 >diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp.py b/Tools/Scripts/webkitpy/style/checkers/cpp.py >index ae2f153f0d106638070b177506da859b0c59699d..8be3bebbd2019ad40491b96885e96f993c7dfb7e 100644 >--- a/Tools/Scripts/webkitpy/style/checkers/cpp.py >+++ b/Tools/Scripts/webkitpy/style/checkers/cpp.py >@@ -2161,6 +2161,31 @@ def check_using_std(clean_lines, line_number, file_state, error): > "Use 'using namespace std;' instead of 'using std::%s;'." % method_name) > > >+def check_using_namespace(clean_lines, line_number, file_state, error): >+ """Looks for 'using namespace foo;' which should be removed. >+ >+ 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. >+ """ >+ >+ # This check doesn't apply to C or Objective-C implementation files. >+ if file_state.is_c_or_objective_c(): >+ return >+ >+ line = clean_lines.elided[line_number] # Get rid of comments and strings. >+ >+ using_namespace_match = match(r'\s*using\s+namespace\s+(?P<method_name>\S+)\s*;\s*$', line) >+ if not using_namespace_match: >+ return >+ >+ method_name = using_namespace_match.group('method_name') >+ error(line_number, 'build/using_namespace', 4, >+ "Do not use 'using namespace %s;'." % method_name) >+ > def check_max_min_macros(clean_lines, line_number, file_state, error): > """Looks use of MAX() and MIN() macros that should be replaced with std::max() and std::min(). > >@@ -2645,6 +2670,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_directive_indentation(clean_lines, line_number, file_state, error) > check_using_std(clean_lines, line_number, file_state, error) >+ check_using_namespace(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) >@@ -3630,6 +3656,7 @@ class CppChecker(object): > 'build/printf_format', > 'build/storage_class', > 'build/using_std', >+ 'build/using_namespace', > 'legal/copyright', > 'readability/braces', > 'readability/casting', >diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py b/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py >index 1bf949793d9a730c14e8b2819db1d82cd327b633..e10bbfefb6a9ee7fb47b7c6d16d431cf7fed049a 100644 >--- a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py >+++ b/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py >@@ -4490,6 +4490,13 @@ class WebKitStyleTest(CppStyleTestBase): > " [build/using_std] [4]", > 'foo.cpp') > >+ def test_using_namespace(self): >+ self.assert_lint( >+ 'using namespace foo;', >+ "Do not use 'using namespace foo;'." >+ " [build/using_namespace] [4]", >+ 'foo.cpp') >+ > def test_max_macro(self): > self.assert_lint( > 'int i = MAX(0, 1);',
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 57241
: 206762