WebKit Bugzilla
Attachment 357818 Details for
Bug 192931
: Add style script rule to check for uses of std::optional<>
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192931-20181220093618.patch (text/plain), 2.68 KB, created by
Chris Dumez
on 2018-12-20 09:36:20 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2018-12-20 09:36:20 PST
Size:
2.68 KB
patch
obsolete
>Subversion Revision: 239428 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 1ead344e3bf9420f09c9db706e46060e7aad47a4..b197892c2b414d9241d9e01535aaef61125ad164 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2018-12-20 Chris Dumez <cdumez@apple.com> >+ >+ Add style script rule to check for uses of std::optional<> >+ https://bugs.webkit.org/show_bug.cgi?id=192931 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Scripts/webkitpy/style/checkers/cpp.py: >+ (check_wtf_optional): >+ (check_style): >+ > 2018-12-20 Chris Dumez <cdumez@apple.com> > > Use Optional::valueOr() instead of Optional::value_or() >diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp.py b/Tools/Scripts/webkitpy/style/checkers/cpp.py >index eca69fd53a34d0f308dade36cd544bad2a2d1fca..133350f1854d01e193803cdb91ceaf0bda869074 100644 >--- a/Tools/Scripts/webkitpy/style/checkers/cpp.py >+++ b/Tools/Scripts/webkitpy/style/checkers/cpp.py >@@ -2378,6 +2378,26 @@ def check_wtf_move(clean_lines, line_number, file_state, error): > error(line_number, 'runtime/wtf_move', 4, "Use 'WTFMove()' instead of 'std::move()'.") > > >+def check_wtf_optional(clean_lines, line_number, file_state, error): >+ """Looks for use of 'std::optional<>' which should be replaced with 'WTF::Optional<>'. >+ >+ 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. >+ >+ using_std_optional = search(r'\boptional\s*\<', line) >+ if not using_std_optional: >+ return >+ >+ error(line_number, 'runtime/wtf_optional', 4, "Use 'WTF::Optional<>' instead of 'std::optional<>'.") >+ >+ > 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>?. >@@ -2915,6 +2935,7 @@ def check_style(clean_lines, line_number, file_extension, class_state, file_stat > check_using_namespace(clean_lines, line_number, file_extension, error) > check_max_min_macros(clean_lines, line_number, file_state, error) > check_wtf_move(clean_lines, line_number, file_state, error) >+ check_wtf_optional(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, file_state, error)
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 192931
:
357814
|
357818
|
357838