Changeset 104995 in webkit
- Timestamp:
- Jan 13, 2012 2:58:00 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r104976 r104995 1 2012-01-13 David Levin <levin@chromium.org> 2 3 check-webkit-style: should encourage the use of Own* classes for Windows DC. 4 https://bugs.webkit.org/show_bug.cgi?id=76227 5 6 Reviewed by Dirk Pranke. 7 8 * wtf/win/HWndDCWin.h: 9 (WTF::HwndDC::HwndDC): Add a way to do GetDCEx. 10 There are no users, but I want to catch this in check-webkit-style 11 and tell any users to use HwndDC to avoid leaks. 12 1 13 2012-01-13 David Levin <levin@chromium.org> 2 14 -
trunk/Source/JavaScriptCore/wtf/win/HWndDCWin.h
r104976 r104995 39 39 } 40 40 41 HWndDC(HWND hwnd, HRGN hrgnClip, DWORD flags) 42 : m_hwnd(hwnd) 43 , m_hdc(::GetDCEx(hwnd, hrgnClip, flags)) 44 { 45 } 46 41 47 ~HWndDC() 42 48 { -
trunk/Tools/ChangeLog
r104982 r104995 1 2012-01-13 David Levin <levin@chromium.org> 2 3 check-webkit-style: should encourage the use of Own* classes for Windows DC. 4 https://bugs.webkit.org/show_bug.cgi?id=76227 5 6 Reviewed by Dirk Pranke. 7 8 * Scripts/webkitpy/style/checkers/cpp.py: 9 (check_for_leaky_patterns): The new check. 10 (process_line): Added a call to the new check. 11 (CppChecker): Added the new error type. 12 * Scripts/webkitpy/style/checkers/cpp_unittest.py: 13 (CppStyleTestBase): 14 (CppStyleTestBase.perform_leaky_pattern_check): 15 The check for only leaky pattern errors. 16 (LeakyPatternTest): Test cases. 17 1 18 2012-01-13 Dirk Pranke <dpranke@chromium.org> 2 19 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r104048 r104995 1661 1661 'Local variables should never be %s (see ' 1662 1662 'http://webkit.org/coding/RefPtr.html).' % type_name) 1663 1664 1665 def check_for_leaky_patterns(clean_lines, line_number, function_state, error): 1666 """Check for constructs known to be leak prone. 1667 Args: 1668 clean_lines: A CleansedLines instance containing the file. 1669 line_number: The number of the line to check. 1670 function_state: Current function name and lines in body so far. 1671 error: The function to call with any errors found. 1672 """ 1673 lines = clean_lines.lines 1674 line = lines[line_number] 1675 1676 matched_get_dc = search(r'\b(?P<function_name>GetDC(Ex)?)\s*\(', line) 1677 if matched_get_dc: 1678 error(line_number, 'runtime/leaky_pattern', 5, 1679 'Use the class HWndDC instead of calling %s to avoid potential ' 1680 'memory leaks.' % matched_get_dc.group('function_name')) 1681 1682 matched_create_dc = search(r'\b(?P<function_name>Create(Compatible)?DC)\s*\(', line) 1683 matched_own_dc = search(r'\bOwnPtr\<HDC\>\s+', line) 1684 if matched_create_dc and not matched_own_dc: 1685 error(line_number, 'runtime/leaky_pattern', 5, 1686 'Use OwnPtr<HDC> when calling %s to avoid potential ' 1687 'memory leaks.' % matched_create_dc.group('function_name')) 1663 1688 1664 1689 … … 3401 3426 check_function_definition(filename, file_extension, clean_lines, line, function_state, error) 3402 3427 check_pass_ptr_usage(clean_lines, line, function_state, error) 3428 check_for_leaky_patterns(clean_lines, line, function_state, error) 3403 3429 check_for_multiline_comments_and_strings(clean_lines, line, error) 3404 3430 check_style(clean_lines, line, file_extension, class_state, file_state, error) … … 3498 3524 'runtime/int', 3499 3525 'runtime/invalid_increment', 3526 'runtime/leaky_pattern', 3500 3527 'runtime/max_min_macros', 3501 3528 'runtime/memset', -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r100678 r104995 291 291 basic_error_rules = ('-', 292 292 '+readability/pass_ptr') 293 return self.perform_lint(code, 'test.cpp', basic_error_rules) 294 295 # Only keep leaky pattern errors. 296 def perform_leaky_pattern_check(self, code): 297 basic_error_rules = ('-', 298 '+runtime/leaky_pattern') 293 299 return self.perform_lint(code, 'test.cpp', basic_error_rules) 294 300 … … 3328 3334 3329 3335 3336 class LeakyPatternTest(CppStyleTestBase): 3337 3338 def assert_leaky_pattern_check(self, code, expected_message): 3339 """Check warnings for leaky patterns are as expected. 3340 3341 Args: 3342 code: C++ source code expected to generate a warning message. 3343 expected_message: Message expected to be generated by the C++ code. 3344 """ 3345 self.assertEquals(expected_message, 3346 self.perform_leaky_pattern_check(code)) 3347 3348 def test_get_dc(self): 3349 self.assert_leaky_pattern_check( 3350 'HDC hdc = GetDC(hwnd);', 3351 'Use the class HWndDC instead of calling GetDC to avoid potential ' 3352 'memory leaks. [runtime/leaky_pattern] [5]') 3353 3354 def test_get_dc(self): 3355 self.assert_leaky_pattern_check( 3356 'HDC hdc = GetDCEx(hwnd, 0, 0);', 3357 'Use the class HWndDC instead of calling GetDCEx to avoid potential ' 3358 'memory leaks. [runtime/leaky_pattern] [5]') 3359 3360 def test_own_get_dc(self): 3361 self.assert_leaky_pattern_check( 3362 'HWndDC hdc(hwnd);', 3363 '') 3364 3365 def test_create_dc(self): 3366 self.assert_leaky_pattern_check( 3367 'HDC dc2 = ::CreateDC();', 3368 'Use OwnPtr<HDC> when calling CreateDC to avoid potential ' 3369 'memory leaks. [runtime/leaky_pattern] [5]') 3370 3371 self.assert_leaky_pattern_check( 3372 'OwnPtr<HDC> dc2 = adoptPtr(CreateDC());', 3373 '') 3374 3375 def test_create_compatible_dc(self): 3376 self.assert_leaky_pattern_check( 3377 'HDC dc2 = CreateCompatibleDC(dc);', 3378 'Use OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential ' 3379 'memory leaks. [runtime/leaky_pattern] [5]') 3380 self.assert_leaky_pattern_check( 3381 'OwnPtr<HDC> dc2 = adoptPtr(CreateCompatibleDC(dc));', 3382 '') 3383 3384 3330 3385 class WebKitStyleTest(CppStyleTestBase): 3331 3386
Note: See TracChangeset
for help on using the changeset viewer.