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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to