[llvm-bugs] [Bug 26215] New: clang-format should insert braces for conditionals with a multi-line body
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 19 17:51:46 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26215
Bug ID: 26215
Summary: clang-format should insert braces for conditionals
with a multi-line body
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: dcheng at google.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Classification: Unclassified
>From http://google.github.io/styleguide/cppguide.html#Conditionals:
"In general, curly braces are not required for single-line statements, but they
are allowed if you like them; conditional or loop statements with complex
conditions or statements may be more readable with curly braces. Some projects
require that an if must always always have an accompanying brace."
The implication here seems to be that any conditional with a multi-line body
should use braces.
Right now, clang-format won't make any formatting changes to this snippet:
if (some_condition)
some_very_long_variable_name =
SomeVeryLongFunctionName(some_very_long_parameter_name);
But I believe that the style guide implies that properly formatted code should
look like this:
if (some_condition) {
some_very_long_variable_name =
SomeVeryLongFunctionName(some_very_long_parameter_name);
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160120/13e255e6/attachment.html>
More information about the llvm-bugs
mailing list