@@ -3928,60 +3928,6 @@ def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error):
3928
3928
"""
3929
3929
line = clean_lines .elided [linenum ]
3930
3930
3931
- # Except after an opening paren, or after another opening brace (in case of
3932
- # an initializer list, for instance), you should have spaces before your
3933
- # braces when they are delimiting blocks, classes, namespaces etc.
3934
- # And since you should never have braces at the beginning of a line,
3935
- # this is an easy test. Except that braces used for initialization don't
3936
- # follow the same rule; we often don't want spaces before those.
3937
- match = Match (r'^(.*[^ ({>]){' , line )
3938
-
3939
- if match :
3940
- # Try a bit harder to check for brace initialization. This
3941
- # happens in one of the following forms:
3942
- # Constructor() : initializer_list_{} { ... }
3943
- # Constructor{}.MemberFunction()
3944
- # Type variable{};
3945
- # FunctionCall(type{}, ...);
3946
- # LastArgument(..., type{});
3947
- # LOG(INFO) << type{} << " ...";
3948
- # map_of_type[{...}] = ...;
3949
- # ternary = expr ? new type{} : nullptr;
3950
- # OuterTemplate<InnerTemplateConstructor<Type>{}>
3951
- #
3952
- # We check for the character following the closing brace, and
3953
- # silence the warning if it's one of those listed above, i.e.
3954
- # "{.;,)<>]:".
3955
- #
3956
- # To account for nested initializer list, we allow any number of
3957
- # closing braces up to "{;,)<". We can't simply silence the
3958
- # warning on first sight of closing brace, because that would
3959
- # cause false negatives for things that are not initializer lists.
3960
- # Silence this: But not this:
3961
- # Outer{ if (...) {
3962
- # Inner{...} if (...){ // Missing space before {
3963
- # }; }
3964
- #
3965
- # There is a false negative with this approach if people inserted
3966
- # spurious semicolons, e.g. "if (cond){};", but we will catch the
3967
- # spurious semicolon with a separate check.
3968
- leading_text = match .group (1 )
3969
- (endline , endlinenum , endpos ) = CloseExpression (
3970
- clean_lines , linenum , len (match .group (1 )))
3971
- trailing_text = ''
3972
- if endpos > - 1 :
3973
- trailing_text = endline [endpos :]
3974
- for offset in xrange (endlinenum + 1 ,
3975
- min (endlinenum + 3 , clean_lines .NumLines () - 1 )):
3976
- trailing_text += clean_lines .elided [offset ]
3977
- # We also suppress warnings for `uint64_t{expression}` etc., as the style
3978
- # guide recommends brace initialization for integral types to avoid
3979
- # overflow/truncation.
3980
- if (not Match (r'^[\s}]*[{.;,)<>\]:]' , trailing_text )
3981
- and not _IsType (clean_lines , nesting_state , leading_text )):
3982
- error (filename , linenum , 'whitespace/braces' , 5 ,
3983
- 'Missing space before {' )
3984
-
3985
3931
# You shouldn't have a space before a semicolon at the end of the line.
3986
3932
# There's a special case for "for" since the style guide allows space before
3987
3933
# the semicolon there.
0 commit comments