Index: third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py |
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py b/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py |
index c5fda9168636112c7124549b5cda3057896c9446..cfe3302ec2ea733a1ea9e6d26183ecc1d7422368 100644 |
--- a/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py |
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py |
@@ -1493,10 +1493,22 @@ def check_for_non_standard_constructs(clean_lines, line_number, |
classinfo.name.startswith('Expected')): |
args = match(r'\s*(\S+)\s+(\S+)\s*:\s*\d+\s*;', line) |
if args: |
- error(line_number, 'runtime/bitfields', 4, |
- 'Member %s of class %s defined as a bitfield of type %s. ' |
- 'Please declare all bitfields as unsigned.' |
- % (args.group(2), classinfo.name, args.group(1))) |
+ field_type = args.group(1) |
+ field_name = args.group(2) |
+ |
+ # Look for an unsigned assert for this type in this file. |
+ has_assert = False |
+ for other_line in clean_lines.lines: |
+ if match(r'\bstatic_assert(\s*IsEnumSafeToStoreInBitfield\s*<\s*(\S+)?' + field_type + r'>::value\s*);', other_line): |
+ has_assert = True |
+ break |
+ |
+ if not has_assert: |
+ error(line_number, 'runtime/bitfields', 4, |
+ 'Member %s of class %s defined as a bitfield of type %s. ' |
+ 'Please declare all bitfields as unsigned, or add ' |
+ 'static_assert(IsEnumSafeToStoreInBitfield<%s>::value).' |
+ % (field_name, classinfo.name, field_type, field_type)) |
def check_spacing_for_function_call(line, line_number, error): |