-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove curly brace CPP Lint checks #2109
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3972,14 +3972,6 @@ def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error): | |
error(filename, linenum, 'whitespace/braces', 5, | ||
'Missing space before {') | ||
|
||
# Make sure '} else {' has spaces. | ||
# if Search(r'}else', line): | ||
# error(filename, linenum, 'whitespace/braces', 5, | ||
# 'Missing space before else') | ||
if (Search(r'^.*[^\s].*}$', line) or Search(r'^.*[^\s].*{$', line)) and not(Search(r'{[^}]*}', line)): | ||
error(filename, linenum, 'whitespace/braces', 5, | ||
'Put braces on a separate next line') | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this also remove the check for all compound statements such as loops, non-lambda function bodies, if/else? How about, instead of completely removing it, adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That doesn't work in the case of lambda with a return type: [] (T& t) -> optionalt<std::string> { ... Or with a lambda with omitted arguments (used in named scopes): auto value = [&] {
if (this)
return 1;
if (that)
return 2;
return 3;
}(); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wouldn't be very hard to add expressions for those, but I do worry about the various line breaks that could be used. |
||
# You shouldn't have a space before a semicolon at the end of the line. | ||
# There's a special case for "for" since the style guide allows space before | ||
# the semicolon there. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,54 +15,38 @@ Author: Daiva Naudziuniene, [email protected] | |
|
||
typet jsil_any_type() | ||
{ | ||
return jsil_union_typet({ // NOLINT(whitespace/braces) | ||
jsil_empty_type(), | ||
jsil_reference_type(), | ||
jsil_value_type() | ||
}); | ||
return jsil_union_typet( | ||
{jsil_empty_type(), jsil_reference_type(), jsil_value_type()}); | ||
} | ||
|
||
typet jsil_value_or_empty_type() | ||
{ | ||
return jsil_union_typet({ // NOLINT(whitespace/braces) | ||
jsil_value_type(), | ||
jsil_empty_type() | ||
}); | ||
return jsil_union_typet({jsil_value_type(), jsil_empty_type()}); | ||
} | ||
|
||
typet jsil_value_or_reference_type() | ||
{ | ||
return jsil_union_typet({ // NOLINT(whitespace/braces) | ||
jsil_value_type(), | ||
jsil_reference_type() | ||
}); | ||
return jsil_union_typet({jsil_value_type(), jsil_reference_type()}); | ||
} | ||
|
||
typet jsil_value_type() | ||
{ | ||
return jsil_union_typet({ // NOLINT(whitespace/braces) | ||
jsil_undefined_type(), | ||
jsil_null_type(), | ||
jsil_prim_type(), | ||
jsil_object_type() | ||
}); | ||
return jsil_union_typet( | ||
{jsil_undefined_type(), | ||
jsil_null_type(), | ||
jsil_prim_type(), | ||
jsil_object_type()}); | ||
} | ||
|
||
typet jsil_prim_type() | ||
{ | ||
return jsil_union_typet({ // NOLINT(whitespace/braces) | ||
floatbv_typet(), | ||
string_typet(), | ||
bool_typet() | ||
}); | ||
return jsil_union_typet({floatbv_typet(), string_typet(), bool_typet()}); | ||
} | ||
|
||
typet jsil_reference_type() | ||
{ | ||
return jsil_union_typet({ // NOLINT(whitespace/braces) | ||
jsil_member_reference_type(), | ||
jsil_variable_reference_type() | ||
}); | ||
return jsil_union_typet( | ||
{jsil_member_reference_type(), jsil_variable_reference_type()}); | ||
} | ||
|
||
typet jsil_member_reference_type() | ||
|
@@ -77,10 +61,8 @@ typet jsil_variable_reference_type() | |
|
||
typet jsil_object_type() | ||
{ | ||
return jsil_union_typet({ // NOLINT(whitespace/braces) | ||
jsil_user_object_type(), | ||
jsil_builtin_object_type() | ||
}); | ||
return jsil_union_typet( | ||
{jsil_user_object_type(), jsil_builtin_object_type()}); | ||
} | ||
|
||
typet jsil_user_object_type() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment on the rationale of this (convenience rule due to deficiencies of clang-format)? We should revert the rule once the clang-format bug is fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rule also doesn't apply to initializer lists.
sounds a bit strange to me. I'd remove thealso
- is it the rule (Put matching...) or the exception (except...) that doesn't apply... a bit confusing. Please reword.